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

Method respond

proxy/server.go:140–168  ·  view source on GitHub ↗

respond writes the specified response to the client (or does nothing if d.Res is empty)

(ctx context.Context, d *DNSContext)

Source from the content-addressed store, hash-verified

138
139// respond writes the specified response to the client (or does nothing if d.Res is empty)
140func (p *Proxy) respond(ctx context.Context, d *DNSContext) {
141 // d.Conn can be nil in the case of a DoH request.
142 if d.Conn != nil {
143 _ = d.Conn.SetWriteDeadline(p.time.Now().Add(defaultTimeout))
144 }
145
146 var err error
147
148 switch d.Proto {
149 case ProtoUDP:
150 err = p.respondUDP(d)
151 case ProtoTCP:
152 err = p.respondTCP(d)
153 case ProtoTLS:
154 err = p.respondTCP(d)
155 case ProtoHTTPS:
156 err = p.respondHTTPS(d)
157 case ProtoQUIC:
158 err = p.respondQUIC(d)
159 case ProtoDNSCrypt:
160 err = p.respondDNSCrypt(ctx, d)
161 default:
162 err = fmt.Errorf("SHOULD NOT HAPPEN - unknown protocol: %s", d.Proto)
163 }
164
165 if err != nil {
166 logWithNonCrit(ctx, err, "responding request", d.Proto, p.logger)
167 }
168}
169
170// setMinMaxTTL sets the TTL values of all records according to the proxy
171// settings. r must not be nil.

Callers 1

handleDNSRequestMethod · 0.95

Calls 6

respondUDPMethod · 0.95
respondTCPMethod · 0.95
respondHTTPSMethod · 0.95
respondQUICMethod · 0.95
respondDNSCryptMethod · 0.95
logWithNonCritFunction · 0.85

Tested by

no test coverage detected