doc: update for custom dnsrecord

This commit is contained in:
nadoo committed 2018-08-01 00:36:11 +08:00
1 parent a226637bfb
commit 04c6f74343
4 files changed
+39 -14

No files matched your search

+5 -7
View File
@@ -97,7 +97,7 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string) ([]byte, error) {
return respBytes, err
}
ttl := 0
ttl := DefaultTTL
ips := []string{}
for _, answer := range resp.Answers {
if answer.TYPE == QTypeA || answer.TYPE == QTypeAAAA {
@@ -109,16 +109,14 @@ func (c *Client) Exchange(reqBytes []byte, clientAddr string) ([]byte, error) {
ips = append(ips, answer.IP)
}
ttl = int(answer.TTL)
if answer.TTL != 0 {
ttl = int(answer.TTL)
}
}
}
// if ttl in packet is 0, set it to default value
if ttl == 0 {
ttl = DefaultTTL
}
// add to cache
c.cache.Put(getKey(resp.Question), respBytes, ttl)