@@ -447,15 +447,18 @@ func (px *proxifier) removeProxy(id string, force bool) bool {
447447// May return both a Proxy and an error, in which case, the error
448448// denotes that while the Proxy is not healthy, it is still registered.
449449func (px * proxifier ) ProxyTo (ipp netip.AddrPort , uid string , pids []string ) (_ Proxy , err error ) {
450+ ippstr := ipp .String ()
451+ e := func (err error ) error {
452+ return fmt .Errorf ("%v for %s to %s among %v" , err , uid , ippstr , pids )
453+ }
450454 if len (pids ) <= 0 || firstEmpty (pids ) {
451- return nil , errMissingProxyID
455+ return nil , e ( errMissingProxyID )
452456 }
453457 if ! ipp .IsValid () {
454- return nil , errMissingAddress
458+ return nil , e ( errMissingAddress )
455459 }
456460
457461 stalledSec := uint32 (0 )
458- ippstr := ipp .String ()
459462
460463 if len (pids ) == 1 { // there's no other pid to choose from
461464 p , err := px .pinID (uid , ipp , pids [0 ]) // repin
@@ -468,7 +471,7 @@ func (px *proxifier) ProxyTo(ipp netip.AddrPort, uid string, pids []string) (_ P
468471 if p != nil {
469472 if ! hasroute (p , ippstr ) {
470473 px .delpin (uid , ipp )
471- return nil , errProxyRoute
474+ return nil , e ( core . JoinErr ( err , errProxyRoute ))
472475 } // there is only one pid to route to
473476
474477 // alwaysPin is set to true, so wipe out err; return p, even if err is not nil
@@ -477,7 +480,7 @@ func (px *proxifier) ProxyTo(ipp netip.AddrPort, uid string, pids []string) (_ P
477480 return p , nil
478481 }
479482 }
480- return nil , err
483+ return nil , e ( err )
481484 }
482485
483486 var lopinned string
@@ -516,8 +519,8 @@ func (px *proxifier) ProxyTo(ipp netip.AddrPort, uid string, pids []string) (_ P
516519 }
517520
518521 defer func () {
519- logev (err )("proxy: pin: %s+%s; stalled? %ds; miss: %v; notok: %v; noroute: %v; paused %v; ended %v" ,
520- uid , ipp , stalledSec , missproxies , notokproxies , norouteproxies , pausedproxies , endproxies )
522+ logev (err )("proxy: pin: %s+%s; stalled? %ds; local: %v; miss: %v; notok: %v; noroute: %v; paused %v; ended %v" ,
523+ uid , ipp , stalledSec , loproxies , missproxies , notokproxies , norouteproxies , pausedproxies , endproxies )
521524 }()
522525
523526 for _ , pid := range pids {
@@ -584,18 +587,18 @@ func (px *proxifier) ProxyTo(ipp netip.AddrPort, uid string, pids []string) (_ P
584587 stalledSec = px .stall (uid + ippstr )
585588
586589 if len (notokproxies ) > 0 {
587- return nil , errNoProxyHealthy
590+ return nil , e ( errNoProxyHealthy )
588591 } else if len (missproxies ) > 0 {
589- return nil , errProxyNotFound
592+ return nil , e ( errProxyNotFound )
590593 } else if len (norouteproxies ) > 0 {
591- return nil , errProxyRoute
594+ return nil , e ( errProxyRoute )
592595 } else if len (endproxies ) > 0 {
593- return nil , errProxyStopped
596+ return nil , e ( errProxyStopped )
594597 } else if len (pausedproxies ) > 0 {
595- return nil , errProxyPaused
598+ return nil , e ( errProxyPaused )
596599 }
597600
598- return nil , errProxyAllDown
601+ return nil , e ( errProxyAllDown )
599602}
600603
601604func (px * proxifier ) stall (k string ) (secs uint32 ) {
0 commit comments