Directly initialize DefaultClient
This commit is contained in:
parent
7ccf75ad43
commit
365e94f06e
@ -41,20 +41,18 @@ const (
|
|||||||
// DefaultClient is the default client. It is used by Send.
|
// DefaultClient is the default client. It is used by Send.
|
||||||
//
|
//
|
||||||
// On the first request, DefaultClient will load the default list of known hosts.
|
// On the first request, DefaultClient will load the default list of known hosts.
|
||||||
var DefaultClient *Client
|
var DefaultClient = &Client{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
crlf = []byte("\r\n")
|
crlf = []byte("\r\n")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
DefaultClient = &Client{
|
DefaultClient.TrustCertificate = func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error {
|
||||||
TrustCertificate: func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error {
|
|
||||||
// Load the hosts only once. This is so that the hosts don't have to be loaded
|
// Load the hosts only once. This is so that the hosts don't have to be loaded
|
||||||
// for those using their own clients.
|
// for those using their own clients.
|
||||||
setupDefaultClientOnce.Do(setupDefaultClient)
|
setupDefaultClientOnce.Do(setupDefaultClient)
|
||||||
return knownHosts.Lookup(hostname, cert)
|
return knownHosts.Lookup(hostname, cert)
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user