From 6cdfbc35525a366df6ff5090922bba4d8e69b305 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Thu, 2 Aug 2018 13:28:01 +0800 Subject: [PATCH] dns: change non-expired ttl to 50years to avoid int overflow on 32bit os --- dns/cache.go | 4 ++-- dns/client.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dns/cache.go b/dns/cache.go index 03be604..87aa2aa 100644 --- a/dns/cache.go +++ b/dns/cache.go @@ -5,8 +5,8 @@ import ( "time" ) -// HundredYears is one hundred years duration in seconds, used for none-expired items -const HundredYears = 100 * 365 * 24 * 3600 +// LongTTL is 50 years duration in seconds, used for none-expired items +const LongTTL = 50 * 365 * 24 * 3600 type item struct { value []byte diff --git a/dns/client.go b/dns/client.go index 7f633f9..3c61889 100644 --- a/dns/client.go +++ b/dns/client.go @@ -218,7 +218,7 @@ func (c *Client) AddRecord(record string) error { binary.Write(&buf, binary.BigEndian, uint16(len(b))) buf.Write(b) - c.cache.Put(getKey(m.Question), buf.Bytes(), HundredYears) + c.cache.Put(getKey(m.Question), buf.Bytes(), LongTTL) return nil }