Increase default TTL to 10 seconds. Fixes #3.

This commit is contained in:
Armon Dadgar 2014-05-23 10:34:25 -07:00
parent 847afc6720
commit 70462deb06

15
zone.go
View File

@ -7,6 +7,11 @@ import (
"strings" "strings"
) )
const (
// defaultTtl controls how long we set the TTL for records
defaultTTL = 10
)
// Zone is the interface used to integrate with the server and // Zone is the interface used to integrate with the server and
// to serve records dynamically // to serve records dynamically
type Zone interface { type Zone interface {
@ -83,7 +88,7 @@ func (m *MDNSService) serviceRecords(q dns.Question) []dns.RR {
Name: q.Name, Name: q.Name,
Rrtype: dns.TypePTR, Rrtype: dns.TypePTR,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 0, Ttl: defaultTTL,
}, },
Ptr: m.instanceAddr, Ptr: m.instanceAddr,
} }
@ -130,7 +135,7 @@ func (m *MDNSService) instanceRecords(q dns.Question) []dns.RR {
Name: q.Name, Name: q.Name,
Rrtype: dns.TypeA, Rrtype: dns.TypeA,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 0, Ttl: defaultTTL,
}, },
A: ipv4, A: ipv4,
} }
@ -147,7 +152,7 @@ func (m *MDNSService) instanceRecords(q dns.Question) []dns.RR {
Name: q.Name, Name: q.Name,
Rrtype: dns.TypeAAAA, Rrtype: dns.TypeAAAA,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 0, Ttl: defaultTTL,
}, },
AAAA: ipv6, AAAA: ipv6,
} }
@ -160,7 +165,7 @@ func (m *MDNSService) instanceRecords(q dns.Question) []dns.RR {
Name: q.Name, Name: q.Name,
Rrtype: dns.TypeSRV, Rrtype: dns.TypeSRV,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 0, Ttl: defaultTTL,
}, },
Priority: 10, Priority: 10,
Weight: 1, Weight: 1,
@ -188,7 +193,7 @@ func (m *MDNSService) instanceRecords(q dns.Question) []dns.RR {
Name: q.Name, Name: q.Name,
Rrtype: dns.TypeTXT, Rrtype: dns.TypeTXT,
Class: dns.ClassINET, Class: dns.ClassINET,
Ttl: 0, Ttl: defaultTTL,
}, },
Txt: []string{m.Info}, Txt: []string{m.Info},
} }