1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-02 23:35:40 -05:00

DNS: refine code (#1193)

This commit is contained in:
Loyalsoldier
2021-08-10 11:08:05 +08:00
committed by GitHub
parent 73470e8dd8
commit a783cd5f08
2 changed files with 6 additions and 6 deletions

View File

@@ -32,7 +32,7 @@ type DNS struct {
clients []*Client
ctx context.Context
domainMatcher strmatcher.IndexMatcher
matcherInfos []DomainMatcherInfo
matcherInfos []*DomainMatcherInfo
}
// DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
@@ -92,7 +92,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
}
// MatcherInfos is ensured to cover the maximum index domainMatcher could return, where matcher's index starts from 1
matcherInfos := make([]DomainMatcherInfo, domainRuleCount+1)
matcherInfos := make([]*DomainMatcherInfo, domainRuleCount+1)
domainMatcher := &strmatcher.MatcherGroup{}
geoipContainer := router.GeoIPMatcherContainer{}
@@ -107,9 +107,9 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
for _, ns := range config.NameServer {
clientIdx := len(clients)
updateDomain := func(domainRule strmatcher.Matcher, originalRuleIdx int, matcherInfos []DomainMatcherInfo) error {
updateDomain := func(domainRule strmatcher.Matcher, originalRuleIdx int, matcherInfos []*DomainMatcherInfo) error {
midx := domainMatcher.Add(domainRule)
matcherInfos[midx] = DomainMatcherInfo{
matcherInfos[midx] = &DomainMatcherInfo{
clientIdx: uint16(clientIdx),
domainRuleIdx: uint16(originalRuleIdx),
}