Skip to content

Commit

Permalink
RequestSend: Using system DSN resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Apr 24, 2022
1 parent 1043ba0 commit 1e369f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions network/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package network

import (
"bytes"
"context"
"crypto/tls"
"fmt"
"io/ioutil"
"net"
"net/http"
"strings"

Expand Down Expand Up @@ -94,13 +96,18 @@ func RequestSend(method string, url string, params map[string]interface{}, data
}
}

// Https
var client *http.Client = &http.Client{}
// Force using system DSN resolver
var dialer = &net.Dialer{Resolver: &net.Resolver{PreferGo: false}}
var dialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return dialer.DialContext(ctx, network, addr)
}
var client *http.Client = &http.Client{Transport: &http.Transport{DialContext: dialContext}}

// SkipVerify false
// Https SkipVerify false
if strings.HasPrefix(url, "https://") {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DialContext: dialContext,
}
client = &http.Client{Transport: tr}
}
Expand Down

0 comments on commit 1e369f7

Please sign in to comment.