From b3f495e50f50d98852c19a4850e37b1e00da5556 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 21 Mar 2018 02:58:06 +0800 Subject: [PATCH] Use round for TTL values --- doh-client/ietf.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doh-client/ietf.go b/doh-client/ietf.go index 9fac35f..33b69b7 100644 --- a/doh-client/ietf.go +++ b/doh-client/ietf.go @@ -170,7 +170,7 @@ func (c *Client) handlerFuncIETF(w dns.ResponseWriter, r *dns.Msg, isTCP bool) { if lastModified == "" { lastModified = resp.Header.Get("Date") } - now := time.Now() + now := time.Now().UTC() lastModifiedDate, err := time.Parse(http.TimeFormat, lastModified) if err != nil { log.Println(err) @@ -227,8 +227,8 @@ func fixRecordTTL(rr dns.RR, delta time.Duration) dns.RR { rrHeader := rr.Header() oldTTL := time.Duration(rrHeader.Ttl) * time.Second newTTL := oldTTL - delta - if newTTL >= 0 { - rrHeader.Ttl = uint32(newTTL / time.Second) + if newTTL > 0 { + rrHeader.Ttl = uint32((newTTL + time.Second/2) / time.Second) } else { rrHeader.Ttl = 0 }