config.proto 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/net/port.proto";
  8. import "common/net/network.proto";
  9. // Domain for routing decision.
  10. message Domain {
  11. // Type of domain value.
  12. enum Type {
  13. // The value is used as is.
  14. Plain = 0;
  15. // The value is used as a regular expression.
  16. Regex = 1;
  17. // The value is a root domain.
  18. Domain = 2;
  19. // The value is a domain.
  20. Full = 3;
  21. }
  22. // Domain matching type.
  23. Type type = 1;
  24. // Domain value.
  25. string value = 2;
  26. message Attribute {
  27. string key = 1;
  28. oneof typed_value {
  29. bool bool_value = 2;
  30. int64 int_value = 3;
  31. }
  32. }
  33. // Attributes of this domain. May be used for filtering.
  34. repeated Attribute attribute = 3;
  35. }
  36. // IP for routing decision, in CIDR form.
  37. message CIDR {
  38. // IP address, should be either 4 or 16 bytes.
  39. bytes ip = 1;
  40. // Number of leading ones in the network mask.
  41. uint32 prefix = 2;
  42. }
  43. message GeoIP {
  44. string country_code = 1;
  45. repeated CIDR cidr = 2;
  46. bool reverse_match = 3;
  47. }
  48. message GeoIPList {
  49. repeated GeoIP entry = 1;
  50. }
  51. message GeoSite {
  52. string country_code = 1;
  53. repeated Domain domain = 2;
  54. }
  55. message GeoSiteList {
  56. repeated GeoSite entry = 1;
  57. }
  58. message RoutingRule {
  59. oneof target_tag {
  60. // Tag of outbound that this rule is pointing to.
  61. string tag = 1;
  62. // Tag of routing balancer.
  63. string balancing_tag = 12;
  64. }
  65. // List of domains for target domain matching.
  66. repeated Domain domain = 2;
  67. // List of CIDRs for target IP address matching.
  68. // Deprecated. Use geoip below.
  69. repeated CIDR cidr = 3 [deprecated = true];
  70. // List of GeoIPs for target IP address matching. If this entry exists, the
  71. // cidr above will have no effect. GeoIP fields with the same country code are
  72. // supposed to contain exactly same content. They will be merged during
  73. // runtime. For customized GeoIPs, please leave country code empty.
  74. repeated GeoIP geoip = 10;
  75. // A range of port [from, to]. If the destination port is in this range, this
  76. // rule takes effect. Deprecated. Use port_list.
  77. xray.common.net.PortRange port_range = 4 [deprecated = true];
  78. // List of ports.
  79. xray.common.net.PortList port_list = 14;
  80. // List of networks. Deprecated. Use networks.
  81. xray.common.net.NetworkList network_list = 5 [deprecated = true];
  82. // List of networks for matching.
  83. repeated xray.common.net.Network networks = 13;
  84. // List of CIDRs for source IP address matching.
  85. repeated CIDR source_cidr = 6 [deprecated = true];
  86. // List of GeoIPs for source IP address matching. If this entry exists, the
  87. // source_cidr above will have no effect.
  88. repeated GeoIP source_geoip = 11;
  89. // List of ports for source port matching.
  90. xray.common.net.PortList source_port_list = 16;
  91. repeated string user_email = 7;
  92. repeated string inbound_tag = 8;
  93. repeated string protocol = 9;
  94. string attributes = 15;
  95. string domain_matcher = 17;
  96. }
  97. message BalancingRule {
  98. string tag = 1;
  99. repeated string outbound_selector = 2;
  100. }
  101. message Config {
  102. enum DomainStrategy {
  103. // Use domain as is.
  104. AsIs = 0;
  105. // Always resolve IP for domains.
  106. UseIp = 1;
  107. // Resolve to IP if the domain doesn't match any rules.
  108. IpIfNonMatch = 2;
  109. // Resolve to IP if any rule requires IP matching.
  110. IpOnDemand = 3;
  111. }
  112. DomainStrategy domain_strategy = 1;
  113. repeated RoutingRule rule = 2;
  114. repeated BalancingRule balancing_rule = 3;
  115. }