ref: github.com/thrawn01/h2c-golang-example
(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup)
| 133 | |
| 134 | // ref: github.com/thrawn01/h2c-golang-example |
| 135 | func StartPPWithDoHCleartext(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup) { |
| 136 | defer wg.Done() |
| 137 | |
| 138 | if tcp == nil { |
| 139 | log.Print("Exiting pp doh") |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | log.Print("mode: DoH cleartext ", tcp.Addr().String()) |
| 144 | |
| 145 | h2svc := &http2.Server{} |
| 146 | // debug h2c with GODEBUG="http2debug=1" env |
| 147 | // ref: cs.opensource.google/go/x/net/+/290c469a:http2/h2c/h2c.go;drc=c6fcb2dbf98596caad8f56c0c398c1c6ff1fcff9;l=35 |
| 148 | dohh2c := http.HandlerFunc(doh.DohHandler()) |
| 149 | dnsfn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 150 | if r.URL.Path == "/h/w" { |
| 151 | fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil) |
| 152 | return |
| 153 | } |
| 154 | dohh2c.ServeHTTP(w, r) |
| 155 | }) |
| 156 | |
| 157 | dnsserver := &http.Server{ |
| 158 | // h2c-handler embed in a http.NewServerMux doesn't work |
| 159 | Handler: h2c.NewHandler(dnsfn, h2svc), |
| 160 | ReadTimeout: conntimeout, |
| 161 | WriteTimeout: conntimeout, |
| 162 | } |
| 163 | |
| 164 | err := dnsserver.Serve(tcp) |
| 165 | log.Print("exit doh cleartext:", err) |
| 166 | } |
| 167 | |
| 168 | func StartPPWithDoTCleartext(tcp *proxyproto.Listener, doh DohResolver, wg *sync.WaitGroup) { |
| 169 | defer wg.Done() |
no test coverage detected