From 69d8d5aa86773c24da2ea84719b3fb95c48c8516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Fri, 21 Jun 2024 19:13:41 +0200 Subject: [PATCH] Fix the active conn type logic --- client/internal/peer/conn.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 783f6cba4..3f7003187 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -89,8 +89,9 @@ type Conn struct { onConnected func(remoteWireGuardKey string, remoteRosenpassPubKey []byte, wireGuardIP string, remoteRosenpassAddr string) onDisconnected func(remotePeer string, wgIP string) - statusRelay ConnStatus - statusICE ConnStatus + statusRelay ConnStatus + statusICE ConnStatus + currentConnType ConnPriority workerICE *WorkerICE workerRelay *WorkerRelay @@ -99,8 +100,6 @@ type Conn struct { beforeAddPeerHooks []BeforeAddPeerHookFunc afterRemovePeerHooks []AfterRemovePeerHookFunc - currentConnType ConnPriority - endpointRelay *net.UDPAddr } @@ -366,8 +365,12 @@ func (conn *Conn) relayConnectionIsReady(rci RelayConnInfo) { conn.statusRelay = stateConnected + // todo review this condition if conn.currentConnType > connPriorityRelay { - return + if conn.statusICE == StatusConnected { + log.Debugf("do not switch to relay because current priority is: %v", conn.currentConnType) + return + } } if conn.currentConnType != 0 { @@ -430,6 +433,7 @@ func (conn *Conn) iCEConnectionIsReady(priority ConnPriority, iceConnInfo ICECon conn.statusICE = stateConnected + // todo review this condition if conn.currentConnType > priority { return }