-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto_quic.go
43 lines (36 loc) · 845 Bytes
/
to_quic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"crypto/tls"
"crypto/x509"
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/http3"
"log"
"net/http"
"time"
)
type toQuicProxy struct {
remoteAddress string
verbose bool
}
func (proxy *toQuicProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
pool, err := x509.SystemCertPool()
if err != nil {
log.Fatal(err)
}
roundTripper := &http3.RoundTripper{
TLSClientConfig: &tls.Config{
RootCAs: pool,
InsecureSkipVerify: true,
},
QuicConfig: &quic.Config{},
}
defer roundTripper.Close()
var client = &http.Client{
Timeout: time.Second * 10,
Transport: roundTripper,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
proxying(w, r, client, ``, proxy.remoteAddress+r.RequestURI, proxy.verbose)
}