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

Function StartPPWithDoH

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

Source from the content-addressed store, hash-verified

42}
43
44func StartPPWithDoH(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup) {
45 defer wg.Done()
46
47 if tcp == nil {
48 log.Print("Exiting pp doh")
49 return
50 }
51
52 if stls := relay.NewTlsListener(tcp, accept); stls != nil {
53 log.Print("mode: relay + DoH ", tcp.Addr().String())
54
55 mux := http.NewServeMux()
56 mux.HandleFunc("/", doh.DohHandler())
57 dnsserver := &http.Server{
58 Handler: mux,
59 ReadTimeout: conntimeout,
60 WriteTimeout: conntimeout,
61 }
62
63 // http.Server takes ownership of stls
64 err := dnsserver.Serve(stls)
65 log.Print("exit doh+relay:", err)
66 } else {
67 log.Print("mode: relay only ", tcp.Addr().String())
68
69 h := &sync.WaitGroup{}
70 h.Add(1)
71 StartPP(tcp, h)
72 h.Wait()
73 }
74}
75
76func StartPPWithDoT(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup) {
77 defer wg.Done()

Callers 1

mainFunction · 0.92

Calls 4

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

Tested by

no test coverage detected