From 2415ae5e5fbfda16c562508878c086fc7eceb8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 20 Mar 2025 16:48:57 +0000 Subject: [PATCH] Rename --- app/dns/config.pb.go | 13 ++++++------- app/dns/config.proto | 2 +- app/dns/nameserver.go | 10 +++++----- infra/conf/dns.go | 8 ++++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 4196f85c..7f6888a3 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -136,7 +136,7 @@ type NameServer struct { OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` AllowUnexpectedIPs bool `protobuf:"varint,8,opt,name=allowUnexpectedIPs,proto3" json:"allowUnexpectedIPs,omitempty"` - TagOverride string `protobuf:"bytes,9,opt,name=tagOverride,proto3" json:"tagOverride,omitempty"` + Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` } func (x *NameServer) Reset() { @@ -225,9 +225,9 @@ func (x *NameServer) GetAllowUnexpectedIPs() bool { return false } -func (x *NameServer) GetTagOverride() string { +func (x *NameServer) GetTag() string { if x != nil { - return x.TagOverride + return x.Tag } return "" } @@ -524,7 +524,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x84, 0x05, 0x0a, 0x0a, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x04, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, @@ -553,9 +553,8 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x61, 0x67, 0x4f, - 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, - 0x61, 0x67, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, diff --git a/app/dns/config.proto b/app/dns/config.proto index 5d2a3011..03c8a333 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -29,7 +29,7 @@ message NameServer { repeated OriginalRule original_rules = 4; QueryStrategy query_strategy = 7; bool allowUnexpectedIPs = 8; - string tagOverride = 9; + string tag = 9; } enum DomainMatchingType { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 180a0cc9..d46c00b7 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -32,7 +32,7 @@ type Client struct { domains []string expectIPs []*router.GeoIPMatcher allowUnexpectedIPs bool - tagOverride string + tag string } var errExpectedIPNonMatch = errors.New("expectIPs not match") @@ -170,7 +170,7 @@ func NewClient( client.domains = rules client.expectIPs = matchers client.allowUnexpectedIPs = ns.AllowUnexpectedIPs - client.tagOverride = ns.TagOverride + client.tag = ns.Tag return nil }) return client, err @@ -184,12 +184,12 @@ func (c *Client) Name() string { // QueryIP sends DNS query to the name server with the client's IP. func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) { ctx, cancel := context.WithTimeout(ctx, 4*time.Second) - if len(c.tagOverride) != 0 { + if len(c.tag) != 0 { content := session.InboundFromContext(ctx) - errors.LogDebug(ctx, "DNS: client override tag from ", content.Tag, " to ", c.tagOverride) + errors.LogDebug(ctx, "DNS: client override tag from ", content.Tag, " to ", c.tag) // create a new context to override the tag // do not direct set *content.Tag, it might be used by other clients - ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tagOverride}) + ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tag}) } ips, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache) cancel() diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 9452f2ab..f2e91573 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -20,7 +20,7 @@ type NameServerConfig struct { ExpectIPs StringList `json:"expectIps"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` - TagOverride string `json:"tagOverride"` + Tag string `json:"tag"` } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { @@ -39,7 +39,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { ExpectIPs StringList `json:"expectIps"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` - TagOverride string `json:"tagOverride"` + Tag string `json:"tag"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -50,7 +50,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.ExpectIPs = advanced.ExpectIPs c.QueryStrategy = advanced.QueryStrategy c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs - c.TagOverride = advanced.TagOverride + c.Tag = advanced.Tag return nil } @@ -124,7 +124,7 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { OriginalRules: originalRules, QueryStrategy: resolveQueryStrategy(c.QueryStrategy), AllowUnexpectedIPs: c.AllowUnexpectedIPs, - TagOverride: c.TagOverride, + Tag: c.Tag, }, nil }