test: h2client custom dialer for testing
All checks were successful
CI / build (push) Successful in 59s

This commit is contained in:
Fijxu 2025-02-17 02:01:25 -03:00
parent 273067973f
commit b9f02ddbea
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4

23
main.go
View file

@ -40,8 +40,7 @@ var h3client = &http.Client{
} }
var dialer = &net.Dialer{ var dialer = &net.Dialer{
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
} }
var proxy string var proxy string
@ -49,19 +48,19 @@ var proxy string
// http/2 client // http/2 client
var h2client = &http.Client{ var h2client = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
Dial: func(network, addr string) (net.Conn, error) { // Dial: func(network, addr string) (net.Conn, error) {
var net string // var net string
if ipv6_only { // if ipv6_only {
net = "tcp6" // net = "tcp6"
} else { // } else {
net = "tcp4" // net = "tcp4"
} // }
return dialer.Dial(net, addr) // return dialer.Dial(net, addr)
}, // },
TLSHandshakeTimeout: 10 * time.Second, TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 20 * time.Second, ResponseHeaderTimeout: 20 * time.Second,
ExpectContinueTimeout: 1 * time.Second, ExpectContinueTimeout: 1 * time.Second,
IdleConnTimeout: 30 * time.Second, IdleConnTimeout: 20 * time.Second,
ReadBufferSize: 16 * 1024, ReadBufferSize: 16 * 1024,
ForceAttemptHTTP2: true, ForceAttemptHTTP2: true,
MaxConnsPerHost: 0, MaxConnsPerHost: 0,