gofmt
This commit is contained in:
parent
9b48d4b899
commit
0509df509e
|
@ -27,7 +27,7 @@ func helloMiek(w RequestWriter, r *Msg) {
|
||||||
|
|
||||||
func TestClientASync(t *testing.T) {
|
func TestClientASync(t *testing.T) {
|
||||||
HandleQueryFunc("miek.nl.", helloMiek) // All queries for miek.nl will be handled by HelloMiek
|
HandleQueryFunc("miek.nl.", helloMiek) // All queries for miek.nl will be handled by HelloMiek
|
||||||
ListenAndQuery(nil, nil) // Detect if this isn't running
|
ListenAndQuery(nil, nil) // Detect if this isn't running
|
||||||
|
|
||||||
m := new(Msg)
|
m := new(Msg)
|
||||||
m.SetQuestion("miek.nl.", TypeSOA)
|
m.SetQuestion("miek.nl.", TypeSOA)
|
||||||
|
@ -83,7 +83,7 @@ func TestClientTsigAXFR(t *testing.T) {
|
||||||
if err := c.XfrReceive(m, "85.223.71.124:53"); err != nil {
|
if err := c.XfrReceive(m, "85.223.71.124:53"); err != nil {
|
||||||
t.Log("Failed to setup axfr" + err.Error())
|
t.Log("Failed to setup axfr" + err.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
ex := <-c.ReplyChan
|
ex := <-c.ReplyChan
|
||||||
|
@ -91,14 +91,14 @@ func TestClientTsigAXFR(t *testing.T) {
|
||||||
if ex.Error == ErrXfrLast {
|
if ex.Error == ErrXfrLast {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ex.Error != nil {
|
if ex.Error != nil {
|
||||||
t.Logf("Error %s\n", ex.Error.Error())
|
t.Logf("Error %s\n", ex.Error.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ex.Reply.Rcode != RcodeSuccess {
|
if ex.Reply.Rcode != RcodeSuccess {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func TestClientAXFRMultipleMessages(t *testing.T) {
|
||||||
if err := c.XfrReceive(m, "85.223.71.124:53"); err != nil {
|
if err := c.XfrReceive(m, "85.223.71.124:53"); err != nil {
|
||||||
t.Log("Failed to setup axfr" + err.Error())
|
t.Log("Failed to setup axfr" + err.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
ex := <-c.ReplyChan
|
ex := <-c.ReplyChan
|
||||||
|
@ -120,13 +120,13 @@ func TestClientAXFRMultipleMessages(t *testing.T) {
|
||||||
if ex.Error == ErrXfrLast {
|
if ex.Error == ErrXfrLast {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ex.Error != nil {
|
if ex.Error != nil {
|
||||||
t.Logf("Error %s\n", ex.Error.Error())
|
t.Logf("Error %s\n", ex.Error.Error())
|
||||||
t.Fail()
|
t.Fail()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ex.Reply.Rcode != RcodeSuccess {
|
if ex.Reply.Rcode != RcodeSuccess {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
dns.go
8
dns.go
|
@ -69,7 +69,7 @@ import (
|
||||||
const (
|
const (
|
||||||
Year68 = 2 << (32 - 1) // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
|
Year68 = 2 << (32 - 1) // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
|
||||||
DefaultMsgSize = 4096 // A standard default for larger than 512 packets.
|
DefaultMsgSize = 4096 // A standard default for larger than 512 packets.
|
||||||
UDPMsgSize = 1024 // A nice default for servers receiving UDP packets.
|
UDPMsgSize = 1024 // A nice default for servers receiving UDP packets.
|
||||||
MaxMsgSize = 65536 // Largest possible DNS packet.
|
MaxMsgSize = 65536 // Largest possible DNS packet.
|
||||||
DefaultTtl = 3600 // Default TTL.
|
DefaultTtl = 3600 // Default TTL.
|
||||||
)
|
)
|
||||||
|
@ -215,9 +215,9 @@ func (h *RR_Header) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RR_Header) Len() int {
|
func (h *RR_Header) Len() int {
|
||||||
l := len(h.Name) + 1
|
l := len(h.Name) + 1
|
||||||
l += 10 // rrtype(2) + class(2) + ttl(4) + rdlength(2)
|
l += 10 // rrtype(2) + class(2) + ttl(4) + rdlength(2)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func zoneMatch(pattern, zone string) (ok bool) {
|
func zoneMatch(pattern, zone string) (ok bool) {
|
||||||
|
|
|
@ -48,8 +48,8 @@ func TestPackUnpack2(t *testing.T) {
|
||||||
m := new(Msg)
|
m := new(Msg)
|
||||||
m.Extra = make([]RR, 1)
|
m.Extra = make([]RR, 1)
|
||||||
m.Answer = make([]RR, 1)
|
m.Answer = make([]RR, 1)
|
||||||
dom := "miek.nl."
|
dom := "miek.nl."
|
||||||
rr := new(RR_A)
|
rr := new(RR_A)
|
||||||
rr.Hdr = RR_Header{Name: dom, Rrtype: TypeA, Class: ClassINET, Ttl: 0}
|
rr.Hdr = RR_Header{Name: dom, Rrtype: TypeA, Class: ClassINET, Ttl: 0}
|
||||||
rr.A = net.IPv4(127, 0, 0, 1)
|
rr.A = net.IPv4(127, 0, 0, 1)
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) error {
|
||||||
s.OrigTtl = rrset[0].Header().Ttl
|
s.OrigTtl = rrset[0].Header().Ttl
|
||||||
s.TypeCovered = rrset[0].Header().Rrtype
|
s.TypeCovered = rrset[0].Header().Rrtype
|
||||||
s.TypeCovered = rrset[0].Header().Rrtype
|
s.TypeCovered = rrset[0].Header().Rrtype
|
||||||
s.Labels, _ = IsDomainName(rrset[0].Header().Name)
|
s.Labels, _ = IsDomainName(rrset[0].Header().Name)
|
||||||
if strings.HasPrefix(rrset[0].Header().Name, "*") {
|
if strings.HasPrefix(rrset[0].Header().Name, "*") {
|
||||||
s.Labels-- // wildcard, remove from label count
|
s.Labels-- // wildcard, remove from label count
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,26 +5,26 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCompareLabels(t *testing.T) {
|
func TestCompareLabels(t *testing.T) {
|
||||||
s1 := "www.miek.nl."
|
s1 := "www.miek.nl."
|
||||||
s2 := "miek.nl."
|
s2 := "miek.nl."
|
||||||
s3 := "www.bla.nl."
|
s3 := "www.bla.nl."
|
||||||
s4 := "nl.www.bla."
|
s4 := "nl.www.bla."
|
||||||
s5 := "nl"
|
s5 := "nl"
|
||||||
|
|
||||||
if CompareLabels(s1, s2) != 2 {
|
if CompareLabels(s1, s2) != 2 {
|
||||||
t.Logf("%s with %s should be %d", s1, s2, 2)
|
t.Logf("%s with %s should be %d", s1, s2, 2)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if CompareLabels(s1, s3) != 1 {
|
if CompareLabels(s1, s3) != 1 {
|
||||||
t.Logf("%s with %s should be %d", s1, s3, 1)
|
t.Logf("%s with %s should be %d", s1, s3, 1)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if CompareLabels(s3, s4) != 0 {
|
if CompareLabels(s3, s4) != 0 {
|
||||||
t.Logf("%s with %s should be %d", s3, s4, 0)
|
t.Logf("%s with %s should be %d", s3, s4, 0)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if CompareLabels(s1, s5) != 1 {
|
if CompareLabels(s1, s5) != 1 {
|
||||||
t.Logf("%s with %s should be %d", s1, s5, 1)
|
t.Logf("%s with %s should be %d", s1, s5, 1)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func NewUpdate(zone string, class uint16) *Msg {
|
||||||
u := new(Msg)
|
u := new(Msg)
|
||||||
u.MsgHdr.Response = false
|
u.MsgHdr.Response = false
|
||||||
u.MsgHdr.Opcode = OpcodeUpdate
|
u.MsgHdr.Opcode = OpcodeUpdate
|
||||||
u.Compress = false // Seems BIND9 at least cannot handle compressed update pkgs
|
u.Compress = false // Seems BIND9 at least cannot handle compressed update pkgs
|
||||||
u.Question = make([]Question, 1)
|
u.Question = make([]Question, 1)
|
||||||
u.Question[0] = Question{zone, TypeSOA, class}
|
u.Question[0] = Question{zone, TypeSOA, class}
|
||||||
return u
|
return u
|
||||||
|
|
Loading…
Reference in New Issue