config.proto 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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/v5/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. import "app/router/routercommon/common.proto";
  12. message RoutingRule {
  13. oneof target_tag {
  14. // Tag of outbound that this rule is pointing to.
  15. string tag = 1;
  16. // Tag of routing balancer.
  17. string balancing_tag = 12;
  18. }
  19. // List of domains for target domain matching.
  20. repeated v2ray.core.app.router.routercommon.Domain domain = 2;
  21. // List of CIDRs for target IP address matching.
  22. // Deprecated. Use geoip below.
  23. repeated v2ray.core.app.router.routercommon.CIDR cidr = 3 [deprecated = true];
  24. // List of GeoIPs for target IP address matching. If this entry exists, the
  25. // cidr above will have no effect. GeoIP fields with the same country code are
  26. // supposed to contain exactly same content. They will be merged during
  27. // runtime. For customized GeoIPs, please leave country code empty.
  28. repeated v2ray.core.app.router.routercommon.GeoIP geoip = 10;
  29. // A range of port [from, to]. If the destination port is in this range, this
  30. // rule takes effect. Deprecated. Use port_list.
  31. v2ray.core.common.net.PortRange port_range = 4 [deprecated = true];
  32. // List of ports.
  33. v2ray.core.common.net.PortList port_list = 14;
  34. // List of networks. Deprecated. Use networks.
  35. v2ray.core.common.net.NetworkList network_list = 5 [deprecated = true];
  36. // List of networks for matching.
  37. repeated v2ray.core.common.net.Network networks = 13;
  38. // List of CIDRs for source IP address matching.
  39. repeated v2ray.core.app.router.routercommon.CIDR source_cidr = 6 [deprecated = true];
  40. // List of GeoIPs for source IP address matching. If this entry exists, the
  41. // source_cidr above will have no effect.
  42. repeated v2ray.core.app.router.routercommon.GeoIP source_geoip = 11;
  43. // List of ports for source port matching.
  44. v2ray.core.common.net.PortList source_port_list = 16;
  45. repeated string user_email = 7;
  46. repeated string inbound_tag = 8;
  47. repeated string protocol = 9;
  48. string attributes = 15;
  49. string domain_matcher = 17;
  50. // geo_domain instruct simplified config loader to load geo domain rule and fill in domain field.
  51. repeated v2ray.core.app.router.routercommon.GeoSite geo_domain = 68001;
  52. }
  53. message BalancingRule {
  54. string tag = 1;
  55. repeated string outbound_selector = 2;
  56. string strategy = 3;
  57. google.protobuf.Any strategy_settings = 4;
  58. string fallback_tag = 5;
  59. }
  60. message StrategyWeight {
  61. bool regexp = 1;
  62. string match = 2;
  63. float value = 3;
  64. }
  65. message StrategyRandomConfig {
  66. option (v2ray.core.common.protoext.message_opt).type = "balancer";
  67. option (v2ray.core.common.protoext.message_opt).short_name = "random";
  68. string observer_tag = 7;
  69. bool alive_only = 8;
  70. }
  71. message StrategyLeastPingConfig {
  72. option (v2ray.core.common.protoext.message_opt).type = "balancer";
  73. option (v2ray.core.common.protoext.message_opt).short_name = "leastping";
  74. string observer_tag = 7;
  75. }
  76. message StrategyLeastLoadConfig {
  77. option (v2ray.core.common.protoext.message_opt).type = "balancer";
  78. option (v2ray.core.common.protoext.message_opt).short_name = "leastload";
  79. // weight settings
  80. repeated StrategyWeight costs = 2;
  81. // RTT baselines for selecting, int64 values of time.Duration
  82. repeated int64 baselines = 3;
  83. // expected nodes count to select
  84. int32 expected = 4;
  85. // max acceptable rtt, filter away high delay nodes. defalut 0
  86. int64 maxRTT = 5;
  87. // acceptable failure rate
  88. float tolerance = 6;
  89. string observer_tag = 7;
  90. }
  91. enum DomainStrategy {
  92. // Use domain as is.
  93. AsIs = 0;
  94. // Always resolve IP for domains.
  95. UseIp = 1;
  96. // Resolve to IP if the domain doesn't match any rules.
  97. IpIfNonMatch = 2;
  98. // Resolve to IP if any rule requires IP matching.
  99. IpOnDemand = 3;
  100. }
  101. message Config {
  102. DomainStrategy domain_strategy = 1;
  103. repeated RoutingRule rule = 2;
  104. repeated BalancingRule balancing_rule = 3;
  105. }
  106. message SimplifiedRoutingRule {
  107. oneof target_tag {
  108. // Tag of outbound that this rule is pointing to.
  109. string tag = 1;
  110. // Tag of routing balancer.
  111. string balancing_tag = 12;
  112. }
  113. // List of domains for target domain matching.
  114. repeated v2ray.core.app.router.routercommon.Domain domain = 2;
  115. // List of GeoIPs for target IP address matching. If this entry exists, the
  116. // cidr above will have no effect. GeoIP fields with the same country code are
  117. // supposed to contain exactly same content. They will be merged during
  118. // runtime. For customized GeoIPs, please leave country code empty.
  119. repeated v2ray.core.app.router.routercommon.GeoIP geoip = 10;
  120. // List of ports.
  121. string port_list = 14;
  122. // List of networks for matching.
  123. v2ray.core.common.net.NetworkList networks = 13;
  124. // List of GeoIPs for source IP address matching. If this entry exists, the
  125. // source_cidr above will have no effect.
  126. repeated v2ray.core.app.router.routercommon.GeoIP source_geoip = 11;
  127. // List of ports for source port matching.
  128. string source_port_list = 16;
  129. repeated string user_email = 7;
  130. repeated string inbound_tag = 8;
  131. repeated string protocol = 9;
  132. string attributes = 15;
  133. string domain_matcher = 17;
  134. // geo_domain instruct simplified config loader to load geo domain rule and fill in domain field.
  135. repeated v2ray.core.app.router.routercommon.GeoSite geo_domain = 68001;
  136. }
  137. message SimplifiedConfig {
  138. option (v2ray.core.common.protoext.message_opt).type = "service";
  139. option (v2ray.core.common.protoext.message_opt).short_name = "router";
  140. DomainStrategy domain_strategy = 1;
  141. repeated SimplifiedRoutingRule rule = 2;
  142. repeated BalancingRule balancing_rule = 3;
  143. }