Change network to accept DialFunc

This commit is contained in:
9seconds
2021-03-11 06:08:15 +03:00
parent 6b28488fbd
commit d6566e5dfb
18 changed files with 67 additions and 117 deletions
+5 -4
View File
@@ -11,7 +11,6 @@ import (
const (
DefaultTimeout = 10 * time.Second
DefaultIdleTimeout = time.Minute
DefaultHTTPTimeout = 5 * time.Second
DefaultBufferSize = 4096
ProxyDialerOpenThreshold = 5
@@ -20,7 +19,8 @@ const (
DefaultDOHHostname = "9.9.9.9"
DNSTimeout = 5 * time.Second
DNSTimeout = 5 * time.Second
HTTPTimeout = 10 * time.Second
)
var (
@@ -28,6 +28,8 @@ var (
ErrCannotDialWithAllProxies = errors.New("cannot dial with all proxies")
)
type DialFunc func(ctx context.Context, protocol, address string) (net.Conn, error)
type Dialer interface {
Dial(network, address string) (net.Conn, error)
DialContext(ctx context.Context, network, address string) (net.Conn, error)
@@ -37,7 +39,6 @@ type Network interface {
Dialer
DNSResolve(network, hostname string) (ips []string, err error)
MakeHTTPClient(timeout time.Duration) *http.Client
MakeHTTPClient(DialFunc) *http.Client
IdleTimeout() time.Duration
PrepareHTTPClient(*http.Client)
}