config.proto 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 GeoIPs for target IP address matching. If this entry exists, the
  70. // cidr above will have no effect. GeoIP fields with the same country code are
  71. // supposed to contain exactly same content. They will be merged during
  72. // runtime. For customized GeoIPs, please leave country code empty.
  73. repeated GeoIP geoip = 10;
  74. // List of ports.
  75. xray.common.net.PortList port_list = 14;
  76. // List of networks for matching.
  77. repeated xray.common.net.Network networks = 13;
  78. // List of GeoIPs for source IP address matching. If this entry exists, the
  79. // source_cidr above will have no effect.
  80. repeated GeoIP source_geoip = 11;
  81. // List of ports for source port matching.
  82. xray.common.net.PortList source_port_list = 16;
  83. repeated string user_email = 7;
  84. repeated string inbound_tag = 8;
  85. repeated string protocol = 9;
  86. map<string, string> attributes = 15;
  87. string domain_matcher = 17;
  88. }
  89. message BalancingRule {
  90. string tag = 1;
  91. repeated string outbound_selector = 2;
  92. string strategy = 3;
  93. xray.common.serial.TypedMessage strategy_settings = 4;
  94. string fallback_tag = 5;
  95. }
  96. message StrategyWeight {
  97. bool regexp = 1;
  98. string match = 2;
  99. float value =3;
  100. }
  101. message StrategyLeastLoadConfig {
  102. // weight settings
  103. repeated StrategyWeight costs = 2;
  104. // RTT baselines for selecting, int64 values of time.Duration
  105. repeated int64 baselines = 3;
  106. // expected nodes count to select
  107. int32 expected = 4;
  108. // max acceptable rtt, filter away high delay nodes. default 0
  109. int64 maxRTT = 5;
  110. // acceptable failure rate
  111. float tolerance = 6;
  112. }
  113. message Config {
  114. enum DomainStrategy {
  115. // Use domain as is.
  116. AsIs = 0;
  117. // Always resolve IP for domains.
  118. UseIp = 1;
  119. // Resolve to IP if the domain doesn't match any rules.
  120. IpIfNonMatch = 2;
  121. // Resolve to IP if any rule requires IP matching.
  122. IpOnDemand = 3;
  123. }
  124. DomainStrategy domain_strategy = 1;
  125. repeated RoutingRule rule = 2;
  126. repeated BalancingRule balancing_rule = 3;
  127. }