mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 11:24:02 +03:00
Make network as a separae interface
This commit is contained in:
+13
-2
@@ -4,13 +4,14 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultTimeout = 10 * time.Second
|
||||
DefaultDNSTimeout = time.Second
|
||||
DefaultHTTPTimeout = DefaultTimeout
|
||||
DefaultIdleTimeout = time.Minute
|
||||
DefaultHTTPTimeout = 5 * time.Second
|
||||
DefaultBufferSize = 4096
|
||||
|
||||
ProxyDialerOpenThreshold = 5
|
||||
@@ -18,6 +19,8 @@ const (
|
||||
ProxyDialerResetFailuresTimeout = 10 * time.Second
|
||||
|
||||
DefaultDOHHostname = "9.9.9.9"
|
||||
|
||||
DNSTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -29,3 +32,11 @@ type Dialer interface {
|
||||
Dial(network, address string) (net.Conn, error)
|
||||
DialContext(ctx context.Context, network, address string) (net.Conn, error)
|
||||
}
|
||||
|
||||
type Network interface {
|
||||
Dialer
|
||||
|
||||
DNSResolve(network, hostname string) (ips []string, err error)
|
||||
MakeHTTPClient(timeout time.Duration) *http.Client
|
||||
IdleTimeout() time.Duration
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user