mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 16:25:39 +00:00
Use time.Since to replace time.Now().Sub
This commit is contained in:
@@ -153,7 +153,7 @@ func NewClient(conf *config) (c *Client, err error) {
|
||||
func (c *Client) newHTTPClient() error {
|
||||
c.httpClientMux.Lock()
|
||||
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
|
||||
}
|
||||
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)
|
||||
defer cancel()
|
||||
|
||||
if r.Response == true {
|
||||
if r.Response {
|
||||
log.Println("Received a response packet")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user