Skip to content

Commit

Permalink
feat: set upstream proxy for http connections
Browse files Browse the repository at this point in the history
  • Loading branch information
LyleMi committed Jan 12, 2024
1 parent eb56875 commit a0bbd7a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"net"
"net/http"
"net/url"
"time"

Expand All @@ -28,6 +29,13 @@ func NewUpstreamDialer(socksAddr string, timeout time.Duration) (*UpstreamDialer
return nil, err
}
dialer = socksDialer

// set upstream proxy for http connections
defaultTransport := http.DefaultTransport.(*http.Transport).Clone()
defaultTransport.Proxy = func(req *http.Request) (*url.URL, error) {
return parsedURL, nil
}
http.DefaultTransport = defaultTransport
} else {
dialer = &net.Dialer{Timeout: timeout}
}
Expand Down

0 comments on commit a0bbd7a

Please sign in to comment.