config.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. syntax = "proto3";
  2. package xray.app.router;
  3. option csharp_namespace = "Xray.App.Router";
  4. option go_package = "github.com/xtls/xray-core/app/router";
  5. option java_package = "com.xray.app.router";
  6. option java_multiple_files = true;
  7. import "common/serial/typed_message.proto";
  8. import "common/net/port.proto";
  9. import "common/net/network.proto";
  10. // Domain for routing decision.
  11. message Domain {
  12. // Type of domain value.
  13. enum Type {
  14. // The value is used as is.
  15. Plain = 0;
  16. // The value is used as a regular expression.
  17. Regex = 1;
  18. // The value is a root domain.
  19. Domain = 2;
  20. // The value is a domain.
  21. Full = 3;
  22. }
  23. // Domain matching type.
  24. Type type = 1;
  25. // Domain value.
  26. string value = 2;
  27. message Attribute {
  28. string key = 1;
  29. oneof typed_value {
  30. bool bool_value = 2;
  31. int64 int_value = 3;
  32. }
  33. }
  34. // Attributes of this domain. May be used for filtering.
  35. repeated Attribute attribute = 3;
  36. }
  37. // IP for routing decision, in CIDR form.
  38. message CIDR {
  39. // IP address, should be either 4 or 16 bytes.
  40. bytes ip = 1;
  41. // Number of leading ones in the network mask.
  42. uint32 prefix = 2;
  43. }
  44. message GeoIP {
  45. string country_code = 1;
  46. repeated CIDR cidr = 2;
  47. bool reverse_match = 3;
  48. }
  49. message GeoIPList {
  50. repeated GeoIP entry = 1;
  51. }
  52. message GeoSite {
  53. string country_code = 1;
  54. repeated Domain domain = 2;
  55. }
  56. message GeoSiteList {
  57. repeated GeoSite entry = 1;
  58. }
  59. message RoutingRule {
  60. oneof target_tag {
  61. // Tag of outbound that this rule is pointing to.
  62. string tag = 1;
  63. // Tag of routing balancer.
  64. string balancing_tag = 12;
  65. }
  66. string rule_tag = 18;
  67. // List of domains for target domain matching.
  68. repeated Domain domain = 2;
  69. // List of CIDRs for target IP address matching.
  70. // Deprecated. Use geoip below.
  71. repeated CIDR cidr = 3 [deprecated = true];
  72. // List of GeoIPs for target IP address matching. If this entry exists, the
  73. // cidr above will have no effect. GeoIP fields with the same country code are
  74. // supposed to contain exactly same content. They will be merged during
  75. // runtime. For customized GeoIPs, please leave country code empty.
  76. repeated GeoIP geoip = 10;
  77. // A range of port [from, to]. If the destination port is in this range, this
  78. // rule takes effect. Deprecated. Use port_list.
  79. xray.common.net.PortRange port_range = 4 [deprecated = true];
  80. // List of ports.
  81. xray.common.net.PortList port_list = 14;
  82. // List of networks. Deprecated. Use networks.
  83. xray.common.net.NetworkList network_list = 5 [deprecated = true];
  84. // List of networks for matching.
  85. repeated xray.common.net.Network networks = 13;
  86. // List of CIDRs for source IP address matching.
  87. repeated CIDR source_cidr = 6 [deprecated = true];
  88. // List of GeoIPs for source IP address matching. If this entry exists, the
  89. // source_cidr above will have no effect.
  90. repeated GeoIP source_geoip = 11;
  91. // List of ports for source port matching.
  92. xray.common.net.PortList source_port_list = 16;
  93. repeated string user_email = 7;
  94. repeated string inbound_tag = 8;
  95. repeated string protocol = 9;
  96. map<string, string> attributes = 15;
  97. string domain_matcher = 17;
  98. }
  99. message BalancingRule {
  100. string tag = 1;
  101. repeated string outbound_selector = 2;
  102. string strategy = 3;
  103. xray.common.serial.TypedMessage strategy_settings = 4;
  104. string fallback_tag = 5;
  105. }
  106. message StrategyWeight {
  107. bool regexp = 1;
  108. string match = 2;
  109. float value =3;
  110. }
  111. message StrategyLeastLoadConfig {
  112. // weight settings
  113. repeated StrategyWeight costs = 2;
  114. // RTT baselines for selecting, int64 values of time.Duration
  115. repeated int64 baselines = 3;
  116. // expected nodes count to select
  117. int32 expected = 4;
  118. // max acceptable rtt, filter away high delay nodes. default 0
  119. int64 maxRTT = 5;
  120. // acceptable failure rate
  121. float tolerance = 6;
  122. }
  123. message Config {
  124. enum DomainStrategy {
  125. // Use domain as is.
  126. AsIs = 0;
  127. // Always resolve IP for domains.
  128. UseIp = 1;
  129. // Resolve to IP if the domain doesn't match any rules.
  130. IpIfNonMatch = 2;
  131. // Resolve to IP if any rule requires IP matching.
  132. IpOnDemand = 3;
  133. }
  134. DomainStrategy domain_strategy = 1;
  135. repeated RoutingRule rule = 2;
  136. repeated BalancingRule balancing_rule = 3;
  137. }