mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
a503f0cf40
* ddns: store configuation in database Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com> * feat: split domain with soa lookup * switch to libdns interface * ddns: add unit test * ddns: skip TestSplitDomainSOA on ci network is not steady * fix error handling * fix error handling --------- Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com>
50 lines
906 B
Go
50 lines
906 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
HttpClientSkipTlsVerify *http.Client
|
|
HttpClient *http.Client
|
|
)
|
|
|
|
func init() {
|
|
HttpClientSkipTlsVerify = httpClient(_httpClient{
|
|
Transport: httpTransport(_httpTransport{
|
|
SkipVerifySSL: true,
|
|
}),
|
|
})
|
|
HttpClient = httpClient(_httpClient{
|
|
Transport: httpTransport(_httpTransport{
|
|
SkipVerifySSL: false,
|
|
}),
|
|
})
|
|
|
|
http.DefaultClient.Timeout = time.Minute * 10
|
|
}
|
|
|
|
type _httpTransport struct {
|
|
SkipVerifySSL bool
|
|
}
|
|
|
|
func httpTransport(conf _httpTransport) *http.Transport {
|
|
return &http.Transport{
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.SkipVerifySSL},
|
|
Proxy: http.ProxyFromEnvironment,
|
|
}
|
|
}
|
|
|
|
type _httpClient struct {
|
|
Transport *http.Transport
|
|
}
|
|
|
|
func httpClient(conf _httpClient) *http.Client {
|
|
return &http.Client{
|
|
Transport: conf.Transport,
|
|
Timeout: time.Minute * 10,
|
|
}
|
|
}
|