config.proto 5.1 KB

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