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