From 9bf52083d15702645e7185a4e727e95c79631ce2 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 23 Aug 2015 08:03:13 +0100 Subject: [PATCH] golint fixes --- dns.go | 4 +--- edns.go | 9 +++++---- msg.go | 1 + privaterr.go | 2 ++ server_test.go | 2 +- types.go | 4 ++-- udp.go | 3 +++ zscan_rr.go | 20 +++++++++++--------- 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/dns.go b/dns.go index 1c37a09d..a3e4a0ef 100644 --- a/dns.go +++ b/dns.go @@ -36,9 +36,7 @@ type RR interface { len() int } -// DNS resource records. -// There are many types of RRs, -// but they all share the same header. +// RR_Header is the header all DNS resource records share. type RR_Header struct { Name string `dns:"cdomain-name"` Rrtype uint16 diff --git a/edns.go b/edns.go index 5314c543..87c8affe 100644 --- a/edns.go +++ b/edns.go @@ -30,6 +30,7 @@ type OPT struct { Option []EDNS0 `dns:"opt"` } +// Header implements the RR interface. func (rr *OPT) Header() *RR_Header { return &rr.Hdr } @@ -176,7 +177,7 @@ func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil } func (e *EDNS0_NSID) String() string { return string(e.Nsid) } -// The subnet EDNS0 option is used to give the remote nameserver +// EDNS0_SUBNET is the subnet option that is used to give the remote nameserver // an idea of where the client lives. It can then give back a different // answer depending on the location or network topology. // Basic use pattern for creating an subnet option: @@ -291,7 +292,7 @@ func (e *EDNS0_SUBNET) String() (s string) { return } -// The UL (Update Lease) EDNS0 (draft RFC) option is used to tell the server to set +// The EDNS0_UL (Update Lease) (draft RFC) option is used to tell the server to set // an expiration on an update RR. This is helpful for clients that cannot clean // up after themselves. This is a draft RFC and more information can be found at // http://files.dns-sd.org/draft-sekar-dns-ul.txt @@ -329,7 +330,7 @@ func (e *EDNS0_UL) unpack(b []byte) error { return nil } -// Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01 +// EDNS0_LLQ stands for Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01 // Implemented for completeness, as the EDNS0 type code is assigned. type EDNS0_LLQ struct { Code uint16 // Always EDNS0LLQ @@ -471,7 +472,7 @@ func (e *EDNS0_EXPIRE) unpack(b []byte) error { return nil } -// The local EDNS0 option is used for local/experimental purposes. The option +// The EDNS0_LOCAL option is used for local/experimental purposes. The option // code is recommended to be within the range [EDNS0LOCALSTART, EDNS0LOCALEND] // (RFC6891), although any unassigned code can actually be used. The content of // the option is made available in Data, unaltered. diff --git a/msg.go b/msg.go index eb7c0f2f..59a6ede9 100644 --- a/msg.go +++ b/msg.go @@ -37,6 +37,7 @@ var ( ErrFqdn error = &Error{err: "domain must be fully qualified"} // ErrId indicates there is a mismatch with the message's ID. ErrId error = &Error{err: "id mismatch"} + // ErrKeyAlg indicates that the algorithm in the key is not valid. ErrKeyAlg error = &Error{err: "bad key algorithm"} ErrKey error = &Error{err: "bad key"} ErrKeySize error = &Error{err: "bad key size"} diff --git a/privaterr.go b/privaterr.go index a3baa065..4b9c325b 100644 --- a/privaterr.go +++ b/privaterr.go @@ -46,7 +46,9 @@ func mkPrivateRR(rrtype uint16) *PrivateRR { panic(fmt.Sprintf("dns: RR is not a PrivateRR, typeToRR[%d] generator returned %T", rrtype, anyrr)) } +// Header return the RR header of r. func (r *PrivateRR) Header() *RR_Header { return &r.Hdr } + func (r *PrivateRR) String() string { return r.Hdr.String() + r.Data.String() } // Private len and copy parts to satisfy RR interface. diff --git a/server_test.go b/server_test.go index 2ff606ac..9e0a1832 100644 --- a/server_test.go +++ b/server_test.go @@ -20,7 +20,7 @@ func HelloServer(w ResponseWriter, req *Msg) { func HelloServerBadId(w ResponseWriter, req *Msg) { m := new(Msg) m.SetReply(req) - m.Id += 1 + m.Id++ m.Extra = make([]RR, 1) m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} diff --git a/types.go b/types.go index 98912e46..16afe29f 100644 --- a/types.go +++ b/types.go @@ -701,7 +701,7 @@ func (rr *NAPTR) len() int { len(rr.Regexp) + 1 + len(rr.Replacement) + 1 } -// See RFC 4398. +// The CERT resource record, see RFC 4398. type CERT struct { Hdr RR_Header Type uint16 @@ -737,7 +737,7 @@ func (rr *CERT) len() int { base64.StdEncoding.DecodedLen(len(rr.Certificate)) } -// See RFC 2672. +// The DNAME resource record, see RFC 2672. type DNAME struct { Hdr RR_Header Target string `dns:"domain-name"` diff --git a/udp.go b/udp.go index 5430e84e..fc865637 100644 --- a/udp.go +++ b/udp.go @@ -7,11 +7,14 @@ import ( "syscall" ) +// SessionUDP holds the remote address and the associated +// out-of-band data. type SessionUDP struct { raddr *net.UDPAddr context []byte } +// RemoteAddr returns the remote network address. func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } // setUDPSocketOptions sets the UDP socket options. diff --git a/zscan_rr.go b/zscan_rr.go index 32e79586..a2db008f 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -896,22 +896,24 @@ func setLOC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { if l.length == 0 { return rr, nil, "" } - if i, e := strconv.Atoi(l.token); e != nil || l.err { + i, e := strconv.Atoi(l.token) + if e != nil || l.err { return nil, &ParseError{f, "bad LOC Latitude", l}, "" - } else { - rr.Latitude = 1000 * 60 * 60 * uint32(i) } + rr.Latitude = 1000 * 60 * 60 * uint32(i) + <-c // zBlank // Either number, 'N' or 'S' l = <-c if rr.Latitude, ok = locCheckNorth(l.token, rr.Latitude); ok { goto East } - if i, e := strconv.Atoi(l.token); e != nil || l.err { + i, e = strconv.Atoi(l.token) + if e != nil || l.err { return nil, &ParseError{f, "bad LOC Latitude minutes", l}, "" - } else { - rr.Latitude += 1000 * 60 * uint32(i) } + rr.Latitude += 1000 * 60 * uint32(i) + <-c // zBlank l = <-c if i, e := strconv.ParseFloat(l.token, 32); e != nil || l.err { @@ -1484,11 +1486,11 @@ func setWKS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { // Ok case zString: if k, err = net.LookupPort(proto, l.token); err != nil { - if i, e := strconv.Atoi(l.token); e != nil { // If a number use that + i, e := strconv.Atoi(l.token) // If a number use that + if e != nil { return nil, &ParseError{f, "bad WKS BitMap", l}, "" - } else { - rr.BitMap = append(rr.BitMap, uint16(i)) } + rr.BitMap = append(rr.BitMap, uint16(i)) } rr.BitMap = append(rr.BitMap, uint16(k)) default: