Skip to content

Commit

Permalink
Linting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
atomirex committed Dec 22, 2024
1 parent a4e7e38 commit 4204667
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ const (
)

var (
errNoPositiveMTUFound = errors.New("no positive MTU found")
errNoPacketConn = errors.New("must supply at least a multicast IPv4 or IPv6 PacketConn")
errNoUsableInterfaces = errors.New("no usable interfaces found for mDNS")
errFailedToClose = errors.New("failed to close mDNS Conn")
errNoPositiveMTUFound = errors.New("no positive MTU found")
errNoPacketConn = errors.New("must supply at least a multicast IPv4 or IPv6 PacketConn")
errNoUsableInterfaces = errors.New("no usable interfaces found for mDNS")
errFailedToClose = errors.New("failed to close mDNS Conn")
errFailedToDecodeAddrFromAResource = errors.New("failed to decode netip.Addr from A type Resource")
errFailedToDecodeAddrFromAAAAResource = errors.New("failed to decode netip.Addr from AAAA type Resource")
errUnhandledAnswerHeaderType = errors.New("header for Answer had unhandled type")
)

type netInterface struct {
Expand Down Expand Up @@ -1163,7 +1166,6 @@ func (c *Conn) start(started chan<- struct{}, inboundBufferSize int, config *Con
}
}

//nolint:all
func addrFromAnswerHeader(answer dnsmessage.Resource) (*netip.Addr, error) {
switch answer.Header.Type {
case dnsmessage.TypeA:
Expand All @@ -1175,7 +1177,7 @@ func addrFromAnswerHeader(answer dnsmessage.Resource) (*netip.Addr, error) {
}
}

return nil, fmt.Errorf("failed to create netip.Addr from TypeA resource")
return nil, errFailedToDecodeAddrFromAResource

Check warning on line 1180 in conn.go

View check run for this annotation

Codecov / codecov/patch

conn.go#L1180

Added line #L1180 was not covered by tests
case dnsmessage.TypeAAAA:
if a, ok := answer.Body.(*dnsmessage.AAAAResource); ok {
addr, ok := netip.AddrFromSlice(a.AAAA[:])
Expand All @@ -1184,9 +1186,9 @@ func addrFromAnswerHeader(answer dnsmessage.Resource) (*netip.Addr, error) {
}
}

return nil, fmt.Errorf("failed to create netip.Addr from TypeAAAA resource")
return nil, errFailedToDecodeAddrFromAAAAResource
default:
return nil, fmt.Errorf("unhandled resource type in answer")
return nil, errUnhandledAnswerHeaderType

Check warning on line 1191 in conn.go

View check run for this annotation

Codecov / codecov/patch

conn.go#L1189-L1191

Added lines #L1189 - L1191 were not covered by tests
}
}

Expand Down

0 comments on commit 4204667

Please sign in to comment.