MCPcopy Create free account
hub / github.com/celzero/midway / StartPPWithDoT

Function StartPPWithDoT

midway/server.go:76–107  ·  view source on GitHub ↗
(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

74}
75
76func StartPPWithDoT(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup) {
77 defer wg.Done()
78
79 if tcp == nil {
80 log.Print("Exiting pp dot")
81 return
82 }
83
84 if stls := relay.NewTlsListener(tcp, accept); stls != nil {
85 log.Print("mode: relay + DoT ", tcp.Addr().String())
86
87 // ref: github.com/miekg/dns/blob/dedee46/server.go#L192
88 // usage: github.com/folbricht/routedns/blob/7b8e284/dotlistener.go#L29
89 dnsserver := &dns.Server{
90 Net: "tcp-tls", // unused
91 Listener: stls,
92 MaxTCPQueries: int(maxInflightQueries),
93 Handler: doh.DnsHandler(),
94 }
95
96 // ref: github.com/miekg/dns/blob/dedee46/server.go#L133
97 err := dnsserver.ActivateAndServe()
98 log.Print("exit dot+relay:", err)
99 } else {
100 log.Print("mode: relay only ", tcp.Addr().String())
101
102 h := &sync.WaitGroup{}
103 h.Add(1)
104 StartPP(tcp, h)
105 h.Wait()
106 }
107}
108
109func StartPP(tcp *proxyproto.Listener, wg *sync.WaitGroup) {
110 defer wg.Done()

Callers 1

mainFunction · 0.92

Calls 4

NewTlsListenerFunction · 0.92
StartPPFunction · 0.85
AddrMethod · 0.80
DnsHandlerMethod · 0.65

Tested by

no test coverage detected