Skip to content

Commit

Permalink
Merge pull request #475 from zmap/build/fix-linter-errcheck
Browse files Browse the repository at this point in the history
build(ci): fix linter errcheck errors
  • Loading branch information
phillip-stephens authored Nov 12, 2024
2 parents 0350588 + ca7dc81 commit 87b078f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ linters-settings:
# Default: false
strict: false


linters:
disable-all: true
enable:
Expand All @@ -58,4 +57,9 @@ issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 50
max-same-issues: 50
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
6 changes: 3 additions & 3 deletions src/zdns/answers.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func makeEDNSAnswer(cAns *dns.OPT) EDNSAnswer {
KeyLease: opt.KeyLease,
}
case *dns.EDNS0_NSID: //OPT 3
hexDecoded, err := hex.DecodeString(o.(*dns.EDNS0_NSID).Nsid)
hexDecoded, err := hex.DecodeString(opt.Nsid)
if err != nil {
continue
}
Expand Down Expand Up @@ -443,15 +443,15 @@ func makeEDNSAnswer(cAns *dns.OPT) EDNSAnswer {
Expire: opt.Expire,
}
case *dns.EDNS0_COOKIE: //OPT 11
optRes.Cookie = &Edns0Cookie{Cookie: o.(*dns.EDNS0_COOKIE).Cookie}
optRes.Cookie = &Edns0Cookie{Cookie: opt.Cookie}
case *dns.EDNS0_TCP_KEEPALIVE: //OPT 11
optRes.TCPKeepalive = &Edns0TCPKeepalive{
Code: opt.Code,
Timeout: opt.Timeout,
Length: opt.Length, // deprecated, always equal to 0, keeping it here for a better readability
}
case *dns.EDNS0_PADDING: //OPT 12
optRes.Padding = &Edns0Padding{Padding: o.(*dns.EDNS0_PADDING).String()}
optRes.Padding = &Edns0Padding{Padding: opt.String()}
case *dns.EDNS0_EDE: //OPT 15
optRes.EDE = append(optRes.EDE, &Edns0Ede{
InfoCode: opt.InfoCode,
Expand Down
8 changes: 7 additions & 1 deletion src/zdns/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,13 @@ func (r *Resolver) getConnectionInfo(nameServer *NameServer) (*ConnectionInfo, e
if err != nil {
return nil, fmt.Errorf("unable to find default IP address to open socket: %w", err)
}
localAddr = &conn.LocalAddr().(*net.UDPAddr).IP

localUDPAddr, ok := conn.LocalAddr().(*net.UDPAddr)
if !ok {
return nil, errors.New("unable to get local address from connection")
}
localAddr = &localUDPAddr.IP

// cleanup socket
if err = conn.Close(); err != nil {
log.Error("unable to close test connection to Google public DNS: ", err)
Expand Down

0 comments on commit 87b078f

Please sign in to comment.