Skip to content

Commit

Permalink
small cleans from go report card (#1268)
Browse files Browse the repository at this point in the history
I went through the list and cleaned things up here and there.

Signed-off-by: Miek Gieben <[email protected]>
  • Loading branch information
miekg authored Jun 17, 2021
1 parent 9922549 commit ce48a4b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
1 change: 1 addition & 0 deletions acceptfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc
// MsgAcceptAction represents the action to be taken.
type MsgAcceptAction int

// Allowed returned values from a MsgAcceptFunc.
const (
MsgAccept MsgAcceptAction = iota // Accept the message
MsgReject // Reject the message with a RcodeFormatError
Expand Down
6 changes: 3 additions & 3 deletions dnssec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
_ "crypto/sha1"
_ "crypto/sha256"
_ "crypto/sha512"
_ "crypto/sha1" // need its init function
_ "crypto/sha256" // need its init function
_ "crypto/sha512" // need its init function
"encoding/asn1"
"encoding/binary"
"encoding/hex"
Expand Down
4 changes: 2 additions & 2 deletions edns.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (*OPT) parse(c *zlexer, origin string) *ParseError {
return &ParseError{err: "OPT records do not have a presentation format"}
}

func (r1 *OPT) isDuplicate(r2 RR) bool { return false }
func (rr *OPT) isDuplicate(r2 RR) bool { return false }

// return the old value -> delete SetVersion?

Expand Down Expand Up @@ -465,7 +465,7 @@ func (e *EDNS0_LLQ) copy() EDNS0 {
return &EDNS0_LLQ{e.Code, e.Version, e.Opcode, e.Error, e.Id, e.LeaseLife}
}

// EDNS0_DUA implements the EDNS0 "DNSSEC Algorithm Understood" option. See RFC 6975.
// EDNS0_DAU implements the EDNS0 "DNSSEC Algorithm Understood" option. See RFC 6975.
type EDNS0_DAU struct {
Code uint16 // Always EDNS0DAU
AlgCode []uint8
Expand Down
2 changes: 1 addition & 1 deletion privaterr.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Fetch:
return nil
}

func (r1 *PrivateRR) isDuplicate(r2 RR) bool { return false }
func (r *PrivateRR) isDuplicate(r2 RR) bool { return false }

// PrivateHandle registers a private resource record type. It requires
// string and numeric representation of private RR type and generator function as argument.
Expand Down
2 changes: 1 addition & 1 deletion scan_rr.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func (rr *HIP) parse(c *zlexer, o string) *ParseError {
}
rr.PublicKey = l.token // This cannot contain spaces
decodedPK, decodedPKerr := base64.StdEncoding.DecodeString(rr.PublicKey)
if decodedPKerr != nil{
if decodedPKerr != nil {
return &ParseError{"", "bad HIP PublicKey", l}
}
rr.PublicKeyLength = uint16(len(decodedPK))
Expand Down
1 change: 1 addition & 0 deletions svcb.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
)

// SVCBKey is the type of the keys used in the SVCB RR.
type SVCBKey uint16

// Keys defined in draft-ietf-dnsop-svcb-https-01 Section 12.3.2.
Expand Down
12 changes: 6 additions & 6 deletions tsig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ func TestTSIGHMAC224And384(t *testing.T) {
const testGoodKeyName = "goodkey."

var (
testErrBadKey = errors.New("this is an intentional error")
testGoodMAC = []byte{0, 1, 2, 3}
errBadKey = errors.New("this is an intentional error")
testGoodMAC = []byte{0, 1, 2, 3}
)

// testProvider always generates the same MAC and only accepts the one signature
Expand All @@ -255,14 +255,14 @@ func (provider *testProvider) Generate(_ []byte, t *TSIG) ([]byte, error) {
if t.Hdr.Name == testGoodKeyName || provider.GenerateAllKeys {
return testGoodMAC, nil
}
return nil, testErrBadKey
return nil, errBadKey
}

func (*testProvider) Verify(_ []byte, t *TSIG) error {
if t.Hdr.Name == testGoodKeyName {
return nil
}
return testErrBadKey
return errBadKey
}

func TestTsigGenerateProvider(t *testing.T) {
Expand All @@ -279,7 +279,7 @@ func TestTsigGenerateProvider(t *testing.T) {
{
"badkey.",
nil,
testErrBadKey,
errBadKey,
},
}

Expand Down Expand Up @@ -321,7 +321,7 @@ func TestTsigVerifyProvider(t *testing.T) {
},
{
"badkey.",
testErrBadKey,
errBadKey,
},
}

Expand Down
29 changes: 13 additions & 16 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,9 @@ const (
)

// Used in ZONEMD https://tools.ietf.org/html/rfc8976

const (
// ZoneMD Accepted Schemes
ZoneMDSchemeSimple = 1

// ZoneMD Hash Algorithms
ZoneMDHashAlgSHA384 = 1
ZoneMDHashAlgSHA512 = 2
)
Expand Down Expand Up @@ -1416,13 +1413,13 @@ func (rr *APL) String() string {
}

// str returns presentation form of the APL prefix.
func (p *APLPrefix) str() string {
func (a *APLPrefix) str() string {
var sb strings.Builder
if p.Negation {
if a.Negation {
sb.WriteByte('!')
}

switch len(p.Network.IP) {
switch len(a.Network.IP) {
case net.IPv4len:
sb.WriteByte('1')
case net.IPv6len:
Expand All @@ -1431,20 +1428,20 @@ func (p *APLPrefix) str() string {

sb.WriteByte(':')

switch len(p.Network.IP) {
switch len(a.Network.IP) {
case net.IPv4len:
sb.WriteString(p.Network.IP.String())
sb.WriteString(a.Network.IP.String())
case net.IPv6len:
// add prefix for IPv4-mapped IPv6
if v4 := p.Network.IP.To4(); v4 != nil {
if v4 := a.Network.IP.To4(); v4 != nil {
sb.WriteString("::ffff:")
}
sb.WriteString(p.Network.IP.String())
sb.WriteString(a.Network.IP.String())
}

sb.WriteByte('/')

prefix, _ := p.Network.Mask.Size()
prefix, _ := a.Network.Mask.Size()
sb.WriteString(strconv.Itoa(prefix))

return sb.String()
Expand All @@ -1458,17 +1455,17 @@ func (a *APLPrefix) equals(b *APLPrefix) bool {
}

// copy returns a copy of the APL prefix.
func (p *APLPrefix) copy() APLPrefix {
func (a *APLPrefix) copy() APLPrefix {
return APLPrefix{
Negation: p.Negation,
Network: copyNet(p.Network),
Negation: a.Negation,
Network: copyNet(a.Network),
}
}

// len returns size of the prefix in wire format.
func (p *APLPrefix) len() int {
func (a *APLPrefix) len() int {
// 4-byte header and the network address prefix (see Section 4 of RFC 3123)
prefix, _ := p.Network.Mask.Size()
prefix, _ := a.Network.Mask.Size()
return 4 + (prefix+7)/8
}

Expand Down

0 comments on commit ce48a4b

Please sign in to comment.