mirror of
https://github.com/qdm12/gluetun.git
synced 2025-12-11 04:38:54 -06:00
chore(health): add ip address to error messages for small checks
This commit is contained in:
parent
a445ba072c
commit
1abc90970d
@ -56,10 +56,10 @@ func (c *Client) Check(ctx context.Context) error {
|
|||||||
switch {
|
switch {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
c.dnsIPIndex = (c.dnsIPIndex + 1) % len(c.serverAddrs)
|
c.dnsIPIndex = (c.dnsIPIndex + 1) % len(c.serverAddrs)
|
||||||
return err
|
return fmt.Errorf("with DNS server %s: %w", dnsAddr, err)
|
||||||
case len(ips) == 0:
|
case len(ips) == 0:
|
||||||
c.dnsIPIndex = (c.dnsIPIndex + 1) % len(c.serverAddrs)
|
c.dnsIPIndex = (c.dnsIPIndex + 1) % len(c.serverAddrs)
|
||||||
return fmt.Errorf("%w", ErrLookupNoIPs)
|
return fmt.Errorf("with DNS server %s: %w", dnsAddr, ErrLookupNoIPs)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,7 @@ func (i *Echoer) Echo(ctx context.Context, ip netip.Addr) (err error) {
|
|||||||
if strings.HasSuffix(err.Error(), "sendto: operation not permitted") {
|
if strings.HasSuffix(err.Error(), "sendto: operation not permitted") {
|
||||||
err = fmt.Errorf("%w", ErrNotPermitted)
|
err = fmt.Errorf("%w", ErrNotPermitted)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("writing ICMP message: %w", err)
|
return fmt.Errorf("writing ICMP message to %s: %w", ip, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedData, err := receiveEchoReply(conn, id, i.buffer, ipVersion, i.logger)
|
receivedData, err := receiveEchoReply(conn, id, i.buffer, ipVersion, i.logger)
|
||||||
@ -90,12 +90,12 @@ func (i *Echoer) Echo(ctx context.Context, ip netip.Addr) (err error) {
|
|||||||
if errors.Is(err, net.ErrClosed) && ctx.Err() != nil {
|
if errors.Is(err, net.ErrClosed) && ctx.Err() != nil {
|
||||||
return fmt.Errorf("%w from %s", ErrTimedOut, ip)
|
return fmt.Errorf("%w from %s", ErrTimedOut, ip)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("receiving ICMP echo reply: %w", err)
|
return fmt.Errorf("receiving ICMP echo reply from %s: %w", ip, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sentData := message.Body.(*icmp.Echo).Data //nolint:forcetypeassert
|
sentData := message.Body.(*icmp.Echo).Data //nolint:forcetypeassert
|
||||||
if !bytes.Equal(receivedData, sentData) {
|
if !bytes.Equal(receivedData, sentData) {
|
||||||
return fmt.Errorf("%w: sent %x and received %x", ErrICMPEchoDataMismatch, sentData, receivedData)
|
return fmt.Errorf("%w: sent %x to %s and received %x", ErrICMPEchoDataMismatch, sentData, ip, receivedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user