Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Add option to disable ipv6.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Jun 27, 2022
1 parent cae96be commit 0816001
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ var h3client = &http.Client{
Transport: &http3.RoundTripper{},
}

var dialer = &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}

// http/2 client
var h2client = &http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
Dial: func(network, addr string) (net.Conn, error) {
if disable_ipv6 {
network = "tcp4"
}
return dialer.Dial(network, addr)
},
TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 20 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
Expand Down Expand Up @@ -70,6 +77,8 @@ var path_prefix = ""

var manifest_re = regexp.MustCompile(`(?m)URI="([^"]+)"`)

var disable_ipv6 = false

type requesthandler struct{}

func (*requesthandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -292,6 +301,8 @@ func RelativeUrl(in string) (newurl string) {
func main() {
path_prefix = os.Getenv("PREFIX_PATH")

disable_ipv6 = os.Getenv("DISABLE_IPV6") == "1"

socket := "socket" + string(os.PathSeparator) + "http-proxy.sock"
syscall.Unlink(socket)
listener, err := net.Listen("unix", socket)
Expand Down

0 comments on commit 0816001

Please sign in to comment.