config.proto 5.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/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. }
  69. message StrategyLeastPingConfig {
  70. option (v2ray.core.common.protoext.message_opt).type = "balancer";
  71. option (v2ray.core.common.protoext.message_opt).short_name = "leastping";
  72. string observer_tag = 7;
  73. }
  74. message StrategyLeastLoadConfig {
  75. option (v2ray.core.common.protoext.message_opt).type = "balancer";
  76. option (v2ray.core.common.protoext.message_opt).short_name = "leastload";
  77. // weight settings
  78. repeated StrategyWeight costs = 2;
  79. // RTT baselines for selecting, int64 values of time.Duration
  80. repeated int64 baselines = 3;
  81. // expected nodes count to select
  82. int32 expected = 4;
  83. // max acceptable rtt, filter away high delay nodes. defalut 0
  84. int64 maxRTT = 5;
  85. // acceptable failure rate
  86. float tolerance = 6;
  87. string observer_tag = 7;
  88. }
  89. enum DomainStrategy {
  90. // Use domain as is.
  91. AsIs = 0;
  92. // Always resolve IP for domains.
  93. UseIp = 1;
  94. // Resolve to IP if the domain doesn't match any rules.
  95. IpIfNonMatch = 2;
  96. // Resolve to IP if any rule requires IP matching.
  97. IpOnDemand = 3;
  98. }
  99. message Config {
  100. DomainStrategy domain_strategy = 1;
  101. repeated RoutingRule rule = 2;
  102. repeated BalancingRule balancing_rule = 3;
  103. }
  104. message SimplifiedRoutingRule {
  105. oneof target_tag {
  106. // Tag of outbound that this rule is pointing to.
  107. string tag = 1;
  108. // Tag of routing balancer.
  109. string balancing_tag = 12;
  110. }
  111. // List of domains for target domain matching.
  112. repeated v2ray.core.app.router.routercommon.Domain domain = 2;
  113. // List of GeoIPs for target IP address matching. If this entry exists, the
  114. // cidr above will have no effect. GeoIP fields with the same country code are
  115. // supposed to contain exactly same content. They will be merged during
  116. // runtime. For customized GeoIPs, please leave country code empty.
  117. repeated v2ray.core.app.router.routercommon.GeoIP geoip = 10;
  118. // List of ports.
  119. string port_list = 14;
  120. // List of networks for matching.
  121. v2ray.core.common.net.NetworkList networks = 13;
  122. // List of GeoIPs for source IP address matching. If this entry exists, the
  123. // source_cidr above will have no effect.
  124. repeated v2ray.core.app.router.routercommon.GeoIP source_geoip = 11;
  125. // List of ports for source port matching.
  126. string source_port_list = 16;
  127. repeated string user_email = 7;
  128. repeated string inbound_tag = 8;
  129. repeated string protocol = 9;
  130. string attributes = 15;
  131. string domain_matcher = 17;
  132. // geo_domain instruct simplified config loader to load geo domain rule and fill in domain field.
  133. repeated v2ray.core.app.router.routercommon.GeoSite geo_domain = 68001;
  134. }
  135. message SimplifiedConfig {
  136. option (v2ray.core.common.protoext.message_opt).type = "service";
  137. option (v2ray.core.common.protoext.message_opt).short_name = "router";
  138. DomainStrategy domain_strategy = 1;
  139. repeated SimplifiedRoutingRule rule = 2;
  140. repeated BalancingRule balancing_rule = 3;
  141. }