Files
gluetun/internal/pmtud/errors.go

26 lines
691 B
Go
Raw Normal View History

2025-08-19 20:04:22 +00:00
package pmtud
import (
"context"
2025-08-19 20:04:22 +00:00
"errors"
"fmt"
"net"
"time"
2025-08-19 20:04:22 +00:00
)
var (
ErrICMPDestinationUnreachable = errors.New("ICMP destination unreachable")
ErrICMPCommunicationAdministrativelyProhibited = errors.New("communication administratively prohibited")
ErrICMPBodyUnsupported = errors.New("ICMP body type is not supported")
2025-08-19 20:04:22 +00:00
)
func wrapConnErr(err error, timedCtx context.Context, pingTimeout time.Duration) error { //nolint:revive
switch {
case errors.Is(timedCtx.Err(), context.DeadlineExceeded):
err = fmt.Errorf("%w (timed out after %s)", net.ErrClosed, pingTimeout)
case timedCtx.Err() != nil:
err = timedCtx.Err()
}
return err
}