Skip to content

Commit

Permalink
fix: add comment explaining about both err handling approaches
Browse files Browse the repository at this point in the history
  • Loading branch information
WendelHime committed Nov 4, 2024
1 parent 34ef0a4 commit 18aa1f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fronted.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,12 @@ func (f *fronted) doDial(m MasqueradeInterface) (conn net.Conn, retriable bool,
func isNetworkUnreachable(err error) bool {
var opErr *net.OpError
if errors.As(err, &opErr) {
// The following error verifications look for errors that generally happen at Linux/Unix devices
if errors.Is(opErr.Err, syscall.ENETUNREACH) || errors.Is(opErr.Err, syscall.EHOSTUNREACH) {
return true
}

// Fallback to message-based checking (works for Windows and Unix-like systems)
// The string verification errors use a broader approach with errors from windows and also linux/unix devices
errMsg := opErr.Err.Error()
if strings.Contains(errMsg, "network is unreachable") ||
strings.Contains(errMsg, "no route to host") ||
Expand Down

0 comments on commit 18aa1f1

Please sign in to comment.