mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-04-01 09:35:52 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93b70f3941 | ||
|
|
76c40fb4dc | ||
|
|
174a465ac8 |
@@ -4,6 +4,10 @@ This Changelog records major changes between versions.
|
|||||||
|
|
||||||
Not all changes are recorded. Please check git log for details.
|
Not all changes are recorded. Please check git log for details.
|
||||||
|
|
||||||
|
## Version 1.3.5
|
||||||
|
|
||||||
|
- Limit the frequency of creating HTTP client on bad network condition
|
||||||
|
|
||||||
## Version 1.3.4
|
## Version 1.3.4
|
||||||
|
|
||||||
- doh-client now silently fails in case of network error to prevent caching of SERVFAIL
|
- doh-client now silently fails in case of network error to prevent caching of SERVFAIL
|
||||||
|
|||||||
@@ -40,15 +40,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
conf *config
|
conf *config
|
||||||
bootstrap []string
|
bootstrap []string
|
||||||
udpServers []*dns.Server
|
udpServers []*dns.Server
|
||||||
tcpServers []*dns.Server
|
tcpServers []*dns.Server
|
||||||
bootstrapResolver *net.Resolver
|
bootstrapResolver *net.Resolver
|
||||||
cookieJar *cookiejar.Jar
|
cookieJar *cookiejar.Jar
|
||||||
httpClientMux *sync.RWMutex
|
httpClientMux *sync.RWMutex
|
||||||
httpTransport *http.Transport
|
httpTransport *http.Transport
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
|
httpClientLastCreate time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type DNSRequest struct {
|
type DNSRequest struct {
|
||||||
@@ -124,6 +125,9 @@ func NewClient(conf *config) (c *Client, err error) {
|
|||||||
func (c *Client) newHTTPClient() error {
|
func (c *Client) newHTTPClient() error {
|
||||||
c.httpClientMux.Lock()
|
c.httpClientMux.Lock()
|
||||||
defer c.httpClientMux.Unlock()
|
defer c.httpClientMux.Unlock()
|
||||||
|
if !c.httpClientLastCreate.IsZero() && time.Now().Sub(c.httpClientLastCreate) < time.Duration(c.conf.Timeout)*time.Second {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if c.httpTransport != nil {
|
if c.httpTransport != nil {
|
||||||
c.httpTransport.CloseIdleConnections()
|
c.httpTransport.CloseIdleConnections()
|
||||||
}
|
}
|
||||||
@@ -150,6 +154,7 @@ func (c *Client) newHTTPClient() error {
|
|||||||
Transport: c.httpTransport,
|
Transport: c.httpTransport,
|
||||||
Jar: c.cookieJar,
|
Jar: c.cookieJar,
|
||||||
}
|
}
|
||||||
|
c.httpClientLastCreate = time.Now()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "1.3.4"
|
VERSION = "1.3.5"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "1.3.4"
|
VERSION = "1.3.5"
|
||||||
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user