@@ -588,6 +588,7 @@ var unixEpoch = time.Unix(0, 0)
588
588
// the Wireguard layer. It's the callers responsibility to provide a timeout, otherwise this function will block
589
589
// forever.
590
590
func (c * Conn ) AwaitReachable (ctx context.Context , ip netip.Addr ) bool {
591
+ logger := c .logger .With (slog .F ("ip" , ip ))
591
592
rightAway := make (chan struct {}, 1 )
592
593
rightAway <- struct {}{}
593
594
tkr := time .NewTicker (50 * time .Millisecond )
@@ -603,7 +604,7 @@ func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool {
603
604
604
605
nKeys := c .getNodeKeysForIP (ip )
605
606
if len (nKeys ) == 0 {
606
- c . logger .Debug (ctx , "missing node(s) for IP" , slog .F ("ip" , ip .String ()))
607
+ logger .Debug (ctx , "missing node(s) for IP" , slog .F ("ip" , ip .String ()))
607
608
continue
608
609
}
609
610
s := c .Status ()
@@ -613,9 +614,13 @@ func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool {
613
614
c .logger .Debug (ctx , "missing status for node" , slog .F ("node" , nKey .ShortString ()))
614
615
continue
615
616
}
617
+ logger .Debug (ctx , "checking peer for handshake" ,
618
+ slog .F ("peer" , ps .PublicKey .ShortString ()), slog .F ("last_handshake" , ps .LastHandshake ))
616
619
// Note that wireguard initializes the last handshake to the Unix Epoch until there is at least one
617
620
// handshake
618
621
if ps .LastHandshake .After (unixEpoch ) {
622
+ //nolint: gocritic
623
+ logger .Debug (ctx , "IP is now reachable" , slog .F ("peer" , ps .PublicKey .ShortString ()))
619
624
return true
620
625
}
621
626
}
0 commit comments