This commit is contained in:
9seconds
2022-03-18 14:58:08 +03:00
parent 9375552180
commit e0850869ba
10 changed files with 34 additions and 20 deletions
+6 -3
View File
@@ -61,7 +61,8 @@ func (n *network) DialContext(ctx context.Context, protocol, address string) (es
}
func (n *network) MakeHTTPClient(dialFunc func(ctx context.Context,
network, address string) (essentials.Conn, error)) *http.Client {
network, address string) (essentials.Conn, error),
) *http.Client {
if dialFunc == nil {
dialFunc = n.DialContext
}
@@ -123,7 +124,8 @@ func (n *network) dnsResolve(protocol, address string) ([]string, error) {
// It brings simple DNS cache and DNS-Over-HTTPS when necessary.
func NewNetwork(dialer Dialer,
userAgent, dohHostname string,
httpTimeout time.Duration) (mtglib.Network, error) {
httpTimeout time.Duration,
) (mtglib.Network, error) {
switch {
case httpTimeout < 0:
return nil, fmt.Errorf("timeout should be positive number %s", httpTimeout)
@@ -146,7 +148,8 @@ func NewNetwork(dialer Dialer,
func makeHTTPClient(userAgent string,
timeout time.Duration,
dialFunc func(ctx context.Context, network, address string) (essentials.Conn, error)) *http.Client {
dialFunc func(ctx context.Context, network, address string) (essentials.Conn, error),
) *http.Client {
return &http.Client{
Timeout: timeout,
Transport: networkHTTPTransport{