mirror of https://github.com/v2ray/v2ray-core
minor changes to dns from pr #2037
parent
905ac82bb1
commit
fa30713e76
|
@ -109,18 +109,16 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
|||
|
||||
if len(config.NameServers) > 0 {
|
||||
features.PrintDeprecatedFeatureWarning("simple DNS server")
|
||||
for _, destPB := range config.NameServers {
|
||||
addNameServer(destPB)
|
||||
}
|
||||
}
|
||||
|
||||
for _, destPB := range config.NameServers {
|
||||
addNameServer(destPB)
|
||||
}
|
||||
|
||||
var geoIPMatcherContainer router.GeoIPMatcherContainer
|
||||
|
||||
if len(config.NameServer) > 0 {
|
||||
domainMatcher := &strmatcher.MatcherGroup{}
|
||||
domainIndexMap := make(map[uint32]uint32)
|
||||
ipIndexMap := make(map[uint32]*MultiGeoIPMatcher)
|
||||
var geoIPMatcherContainer router.GeoIPMatcherContainer
|
||||
|
||||
for _, ns := range config.NameServer {
|
||||
idx := addNameServer(ns.Address)
|
||||
|
@ -141,7 +139,6 @@ func New(ctx context.Context, config *Config) (*Server, error) {
|
|||
return nil, newError("failed to create ip matcher").Base(err).AtWarning()
|
||||
}
|
||||
matchers = append(matchers, matcher)
|
||||
|
||||
}
|
||||
matcher := &MultiGeoIPMatcher{matchers: matchers}
|
||||
ipIndexMap[uint32(idx)] = matcher
|
||||
|
@ -182,12 +179,12 @@ func (s *Server) IsOwnLink(ctx context.Context) bool {
|
|||
// Match check dns ip match geoip
|
||||
func (s *Server) Match(idx uint32, client Client, domain string, ips []net.IP) ([]net.IP, error) {
|
||||
matcher, exist := s.ipIndexMap[idx]
|
||||
if exist == false {
|
||||
if !exist {
|
||||
newError("domain ", domain, " server not in ipIndexMap: ", client.Name(), " idx:", idx, " just return").AtDebug().WriteToLog()
|
||||
return ips, nil
|
||||
}
|
||||
|
||||
if matcher.HasMatcher() == false {
|
||||
if !matcher.HasMatcher() {
|
||||
newError("domain ", domain, " server has not valid matcher: ", client.Name(), " idx:", idx, " just return").AtDebug().WriteToLog()
|
||||
return ips, nil
|
||||
}
|
||||
|
|
|
@ -444,17 +444,6 @@ func TestIPMatch(t *testing.T) {
|
|||
config := &core.Config{
|
||||
App: []*serial.TypedMessage{
|
||||
serial.ToTypedMessage(&Config{
|
||||
NameServers: []*net.Endpoint{
|
||||
{
|
||||
Network: net.Network_UDP,
|
||||
Address: &net.IPOrDomain{
|
||||
Address: &net.IPOrDomain_Ip{
|
||||
Ip: []byte{127, 0, 0, 1},
|
||||
},
|
||||
},
|
||||
Port: 9999, /* unreachable */
|
||||
},
|
||||
},
|
||||
NameServer: []*NameServer{
|
||||
// private dns, not match
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue