From a4ebf5429023d66103ceb77e3d45b025c680b915 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 28 Aug 2024 21:46:18 +1100 Subject: [PATCH 1/2] Add printing of WireguardPeerEvent events Signed-off-by: NikitaSkrynnik --- pkg/networkservice/up/peerup/common.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/networkservice/up/peerup/common.go b/pkg/networkservice/up/peerup/common.go index 62cb7ad4..864f5a3b 100644 --- a/pkg/networkservice/up/peerup/common.go +++ b/pkg/networkservice/up/peerup/common.go @@ -89,8 +89,9 @@ func waitForPeerUp(ctx context.Context, vppConn api.Connection, pubKey string, i log.FromContext(ctx).Infof("failed to get any WireguardPeerEvents: %s", ctx.Err()) return errors.Wrap(ctx.Err(), "provided context is done") case rawMsg := <-watcher.Events(): - log.FromContext(ctx).Infof("got WireguardPeerEvent: %v, %v", rawMsg.GetMessageName(), rawMsg.GetMessageType()) - if msg, ok := rawMsg.(*wireguard.WireguardPeerEvent); ok && + msg, ok := rawMsg.(*wireguard.WireguardPeerEvent) + log.FromContext(ctx).Infof("got WireguardPeerEvent: %v", msg) + if ok && msg.PeerIndex == peerIndex && msg.Flags&wireguard.WIREGUARD_PEER_ESTABLISHED != 0 { log.FromContext(ctx). From 50fe25ef82b8f5c7e40e1b1072b8f6ba7dc00dc5 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 28 Aug 2024 22:49:26 +1100 Subject: [PATCH 2/2] apply review comments Signed-off-by: NikitaSkrynnik --- pkg/networkservice/up/peerup/common.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/networkservice/up/peerup/common.go b/pkg/networkservice/up/peerup/common.go index 864f5a3b..40b5685d 100644 --- a/pkg/networkservice/up/peerup/common.go +++ b/pkg/networkservice/up/peerup/common.go @@ -89,9 +89,8 @@ func waitForPeerUp(ctx context.Context, vppConn api.Connection, pubKey string, i log.FromContext(ctx).Infof("failed to get any WireguardPeerEvents: %s", ctx.Err()) return errors.Wrap(ctx.Err(), "provided context is done") case rawMsg := <-watcher.Events(): - msg, ok := rawMsg.(*wireguard.WireguardPeerEvent) - log.FromContext(ctx).Infof("got WireguardPeerEvent: %v", msg) - if ok && + log.FromContext(ctx).Infof("received WireguardPeerEvent: %v", rawMsg) + if msg, ok := rawMsg.(*wireguard.WireguardPeerEvent); ok && msg.PeerIndex == peerIndex && msg.Flags&wireguard.WIREGUARD_PEER_ESTABLISHED != 0 { log.FromContext(ctx).