small cleans from go report card (#1268)
I went through the list and cleaned things up here and there. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
9922549621
commit
ce48a4b9ef
@ -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
|
||||
|
@ -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"
|
||||
|
4
edns.go
4
edns.go
@ -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?
|
||||
|
||||
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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))
|
||||
|
1
svcb.go
1
svcb.go
@ -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.
|
||||
|
12
tsig_test.go
12
tsig_test.go
@ -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
|
||||
@ -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) {
|
||||
@ -279,7 +279,7 @@ func TestTsigGenerateProvider(t *testing.T) {
|
||||
{
|
||||
"badkey.",
|
||||
nil,
|
||||
testErrBadKey,
|
||||
errBadKey,
|
||||
},
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ func TestTsigVerifyProvider(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"badkey.",
|
||||
testErrBadKey,
|
||||
errBadKey,
|
||||
},
|
||||
}
|
||||
|
||||
|
29
types.go
29
types.go
@ -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
|
||||
)
|
||||
@ -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:
|
||||
@ -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()
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user