mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-10-23 23:52:54 +00:00
Use time.Since to replace time.Now().Sub
This commit is contained in:
1 parent
35ddf43505
commit
95fe3e3b4e
1 file changed
+2
-2
@@ -153,7 +153,7 @@ 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 {
|
if !c.httpClientLastCreate.IsZero() && time.Since(c.httpClientLastCreate) < time.Duration(c.conf.Timeout)*time.Second {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if c.httpTransport != nil {
|
if c.httpTransport != nil {
|
||||||
@@ -220,7 +220,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(c.conf.Timeout)*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(c.conf.Timeout)*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if r.Response == true {
|
if r.Response {
|
||||||
log.Println("Received a response packet")
|
log.Println("Received a response packet")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user