|
|
@ -27,6 +27,9 @@ func init() { |
|
|
|
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { |
|
|
|
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { |
|
|
|
h := new(Handler) |
|
|
|
h := new(Handler) |
|
|
|
if err := core.RequireFeatures(ctx, func(dnsClient dns.Client, policyManager policy.Manager) error { |
|
|
|
if err := core.RequireFeatures(ctx, func(dnsClient dns.Client, policyManager policy.Manager) error { |
|
|
|
|
|
|
|
core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { |
|
|
|
|
|
|
|
h.fdns = fdns |
|
|
|
|
|
|
|
}) |
|
|
|
return h.Init(config.(*Config), dnsClient, policyManager) |
|
|
|
return h.Init(config.(*Config), dnsClient, policyManager) |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
@ -41,6 +44,7 @@ type ownLinkVerifier interface { |
|
|
|
|
|
|
|
|
|
|
|
type Handler struct { |
|
|
|
type Handler struct { |
|
|
|
client dns.Client |
|
|
|
client dns.Client |
|
|
|
|
|
|
|
fdns dns.FakeDNSEngine |
|
|
|
ownLinkVerifier ownLinkVerifier |
|
|
|
ownLinkVerifier ownLinkVerifier |
|
|
|
server net.Destination |
|
|
|
server net.Destination |
|
|
|
timeout time.Duration |
|
|
|
timeout time.Duration |
|
|
@ -179,7 +183,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. |
|
|
|
if isIPQuery { |
|
|
|
if isIPQuery { |
|
|
|
go h.handleIPQuery(id, qType, domain, writer) |
|
|
|
go h.handleIPQuery(id, qType, domain, writer) |
|
|
|
} |
|
|
|
} |
|
|
|
if isIPQuery || h.nonIPQuery == "drop" { |
|
|
|
if isIPQuery || h.nonIPQuery == "drop" || qType == 65 { |
|
|
|
b.Release() |
|
|
|
b.Release() |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
@ -244,6 +248,10 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if fkr0, ok := h.fdns.(dns.FakeDNSEngineRev0); ok && len(ips) > 0 && fkr0.IsIPInIPPool(net.IPAddress(ips[0])) { |
|
|
|
|
|
|
|
ttl = 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch qType { |
|
|
|
switch qType { |
|
|
|
case dnsmessage.TypeA: |
|
|
|
case dnsmessage.TypeA: |
|
|
|
for i, ip := range ips { |
|
|
|
for i, ip := range ips { |
|
|
|