dns: change non-expired ttl to 50years to avoid int overflow on 32bit os

This commit is contained in:
nadoo 2018-08-02 13:28:01 +08:00
parent c049b75b64
commit 6cdfbc3552
2 changed files with 3 additions and 3 deletions

View File

@ -5,8 +5,8 @@ import (
"time" "time"
) )
// HundredYears is one hundred years duration in seconds, used for none-expired items // LongTTL is 50 years duration in seconds, used for none-expired items
const HundredYears = 100 * 365 * 24 * 3600 const LongTTL = 50 * 365 * 24 * 3600
type item struct { type item struct {
value []byte value []byte

View File

@ -218,7 +218,7 @@ func (c *Client) AddRecord(record string) error {
binary.Write(&buf, binary.BigEndian, uint16(len(b))) binary.Write(&buf, binary.BigEndian, uint16(len(b)))
buf.Write(b) buf.Write(b)
c.cache.Put(getKey(m.Question), buf.Bytes(), HundredYears) c.cache.Put(getKey(m.Question), buf.Bytes(), LongTTL)
return nil return nil
} }