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

Method Addr

proxy/proxy.go:524–544  ·  view source on GitHub ↗

Addr returns the first listen address for the specified proto or nil if the proxy does not listen to it. proto must be one of [Proto]: [ProtoTCP], [ProtoUDP], [ProtoTLS], [ProtoHTTPS], [ProtoQUIC], or [ProtoDNSCrypt].

(proto Proto)

Source from the content-addressed store, hash-verified

522// proxy does not listen to it. proto must be one of [Proto]: [ProtoTCP],
523// [ProtoUDP], [ProtoTLS], [ProtoHTTPS], [ProtoQUIC], or [ProtoDNSCrypt].
524func (p *Proxy) Addr(proto Proto) (addr net.Addr) {
525 p.RLock()
526 defer p.RUnlock()
527
528 switch proto {
529 case ProtoTCP:
530 return firstAddr(p.tcpListen, net.Listener.Addr)
531 case ProtoTLS:
532 return firstAddr(p.tlsListen, net.Listener.Addr)
533 case ProtoHTTPS:
534 return firstAddr(p.httpsListen, net.Listener.Addr)
535 case ProtoUDP:
536 return firstAddr(p.udpListen, (*net.UDPConn).LocalAddr)
537 case ProtoQUIC:
538 return firstAddr(p.quicListen, (*quic.EarlyListener).Addr)
539 case ProtoDNSCrypt:
540 return firstAddr(p.dnsCryptServers, (*dnscrypt.Server).LocalAddr)
541 default:
542 panic("proto must be 'tcp', 'tls', 'https', 'quic', 'dnscrypt' or 'udp'")
543 }
544}
545
546// selectUpstreams returns the upstreams to use for the specified host. It
547// firstly considers custom upstreams if those aren't empty and then the

Callers 15

startDoHServerFunction · 0.80
startDoTServerFunction · 0.80
BenchmarkDoTUpstreamFunction · 0.80
startDoQServerFunction · 0.80
TestDNSCryptProxyFunction · 0.80
handleDNSRequestMethod · 0.80
isForbiddenARPAMethod · 0.80
processECSMethod · 0.80
TestDNS64RaceFunction · 0.80
listenQUICMethod · 0.80

Calls 1

firstAddrFunction · 0.85

Tested by 15

startDoHServerFunction · 0.64
startDoTServerFunction · 0.64
BenchmarkDoTUpstreamFunction · 0.64
startDoQServerFunction · 0.64
TestDNSCryptProxyFunction · 0.64
TestDNS64RaceFunction · 0.64
TestProxy_quicFunction · 0.64
TestProxy_trustedProxiesFunction · 0.64