Skip to content

Commit

Permalink
ipn/auto: elaborate err msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Nov 22, 2024
1 parent ee5b040 commit bb6b9ee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions intra/ipn/auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package ipn

import (
"context"
"fmt"
"net"
"net/netip"
"strconv"
Expand Down Expand Up @@ -91,7 +92,7 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
tlsHandshakeTimeout,
func(ctx context.Context) (protect.Conn, error) {
const myidx = 0
if exit == nil {
if exit == nil { // exit must always be present
return nil, exerr
}
if recent {
Expand Down Expand Up @@ -169,7 +170,7 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
h.exp.Put(remote, who)
}
maybeKeepAlive(c)
log.I("proxy: auto: w(%d) pin(%t/%d), dial(%s) %s; err? %v",
logeif(err != nil)("proxy: auto: w(%d) pin(%t/%d), dial(%s) %s; err? %v",
who, recent, previdx, network, remote, err)
return c, err
}
Expand Down Expand Up @@ -317,20 +318,20 @@ func (h *auto) Stop() error {

func (h *auto) dialIfReachable(p Proxy, network, local, remote string) (net.Conn, error) {
if !hasroute(p, remote) {
return nil, errNoRouteToHost
return nil, fmt.Errorf("auto; %s: %v", p.ID(), errNoRouteToHost)
}
ipp, _ := netip.ParseAddrPort(remote)
if reachable, err := h.ba.DoIt(baID(p, remote), icmpReachesWork(p, ipp)); err != nil {
return nil, err
return nil, fmt.Errorf("auto; %s ping %s: %v", p.ID(), remote, err)
} else if !reachable {
return nil, errUnreachable
return nil, fmt.Errorf("auto; %s: %v: %s", p.ID(), errNoRouteToHost, remote)
}
return h.dialIfHealthy(p, network, local, remote)
}

func (*auto) dialIfHealthy(p Proxy, network, local, remote string) (net.Conn, error) {
if err := healthy(p); err != nil {
return nil, err
return nil, fmt.Errorf("auto; %s not ok; %v: %s", p.ID(), err, remote)
}
if len(local) > 0 {
return p.Dialer().DialBind(network, local, remote)
Expand Down

0 comments on commit bb6b9ee

Please sign in to comment.