config.proto 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 "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. // List of domains for target domain matching.
  67. repeated Domain domain = 2;
  68. // List of CIDRs for target IP address matching.
  69. // Deprecated. Use geoip below.
  70. repeated CIDR cidr = 3 [deprecated = true];
  71. // List of GeoIPs for target IP address matching. If this entry exists, the
  72. // cidr above will have no effect. GeoIP fields with the same country code are
  73. // supposed to contain exactly same content. They will be merged during
  74. // runtime. For customized GeoIPs, please leave country code empty.
  75. repeated GeoIP geoip = 10;
  76. // A range of port [from, to]. If the destination port is in this range, this
  77. // rule takes effect. Deprecated. Use port_list.
  78. v2ray.core.common.net.PortRange port_range = 4 [deprecated = true];
  79. // List of ports.
  80. v2ray.core.common.net.PortList port_list = 14;
  81. // List of networks. Deprecated. Use networks.
  82. v2ray.core.common.net.NetworkList network_list = 5 [deprecated = true];
  83. // List of networks for matching.
  84. repeated v2ray.core.common.net.Network networks = 13;
  85. // List of CIDRs for source IP address matching.
  86. repeated CIDR source_cidr = 6 [deprecated = true];
  87. // List of GeoIPs for source IP address matching. If this entry exists, the
  88. // source_cidr above will have no effect.
  89. repeated GeoIP source_geoip = 11;
  90. // List of ports for source port matching.
  91. v2ray.core.common.net.PortList source_port_list = 16;
  92. repeated string user_email = 7;
  93. repeated string inbound_tag = 8;
  94. repeated string protocol = 9;
  95. string attributes = 15;
  96. string domain_matcher = 17;
  97. }
  98. message BalancingRule {
  99. string tag = 1;
  100. repeated string outbound_selector = 2;
  101. string strategy = 3;
  102. v2ray.core.common.serial.TypedMessage strategy_settings = 4;
  103. string fallback_tag = 5;
  104. }
  105. message StrategyWeight {
  106. bool regexp = 1;
  107. string match = 2;
  108. float value =3;
  109. }
  110. message StrategyLeastLoadConfig {
  111. HealthPingConfig healthCheck = 1;
  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. defalut 0
  119. int64 maxRTT = 5;
  120. // acceptable failure rate
  121. float tolerance = 6;
  122. }
  123. message HealthPingConfig {
  124. // destination url, need 204 for success return
  125. // default http://www.google.com/gen_204
  126. string destination = 1;
  127. // connectivity check url
  128. string connectivity = 2;
  129. // health check interval, int64 values of time.Duration
  130. int64 interval = 3;
  131. // samplingcount is the amount of recent ping results which are kept for calculation
  132. int32 samplingCount = 4;
  133. // ping timeout, int64 values of time.Duration
  134. int64 timeout = 5;
  135. }
  136. message Config {
  137. enum DomainStrategy {
  138. // Use domain as is.
  139. AsIs = 0;
  140. // Always resolve IP for domains.
  141. UseIp = 1;
  142. // Resolve to IP if the domain doesn't match any rules.
  143. IpIfNonMatch = 2;
  144. // Resolve to IP if any rule requires IP matching.
  145. IpOnDemand = 3;
  146. }
  147. DomainStrategy domain_strategy = 1;
  148. repeated RoutingRule rule = 2;
  149. repeated BalancingRule balancing_rule = 3;
  150. }