mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 17:54:01 +03:00
Change network to accept DialFunc
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user