MCPcopy
hub / github.com/AdguardTeam/dnsproxy / handleDNSRequest

Method handleDNSRequest

proxy/server.go:79–105  ·  view source on GitHub ↗

handleDNSRequest processes the context. The only error it returns is the one from the [Handler].

(ctx context.Context, d *DNSContext)

Source from the content-addressed store, hash-verified

77// handleDNSRequest processes the context. The only error it returns is the one
78// from the [Handler].
79func (p *Proxy) handleDNSRequest(ctx context.Context, d *DNSContext) (err error) {
80 p.logDNSMessage(ctx, d.Req)
81
82 if d.Req.Response {
83 p.logger.DebugContext(ctx, "dropping incoming response packet", "addr", d.Addr)
84
85 return nil
86 }
87
88 ip := d.Addr.Addr()
89 d.IsPrivateClient = p.privateNets.Contains(ip)
90
91 // TODO(d.kolyshev): Consider moving validation to a new middleware.
92 d.Res = p.validateRequest(d)
93 if d.Res == nil {
94 err = p.requestHandler.ServeDNS(ctx, p, d)
95 if errors.Is(err, ErrDrop) {
96 // Don't reply to dropped clients.
97 return nil
98 }
99 }
100
101 p.logDNSMessage(ctx, d.Res)
102 p.respond(ctx, d)
103
104 return err
105}
106
107// isForbiddenARPA returns true if dctx contains a PTR, SOA, or NS request for
108// some private address and client's address is not within the private network.

Callers 6

handleQUICStreamMethod · 0.95
ServeHTTPMethod · 0.95
handleTCPConnectionMethod · 0.95
udpHandlePacketMethod · 0.95
ServeDNSMethod · 0.80
TestProxy_Resolve_dns64Function · 0.80

Calls 5

logDNSMessageMethod · 0.95
validateRequestMethod · 0.95
respondMethod · 0.95
AddrMethod · 0.80
ServeDNSMethod · 0.65

Tested by 1

TestProxy_Resolve_dns64Function · 0.64