Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(ci): fix linter errcheck errors #475

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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