From 6776f82e78826e2d34778c716d69493f18ef9871 Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Wed, 27 May 2026 20:50:34 -0700 Subject: [PATCH] ICE client: Fix route determination It needs the local candidate (with the relay, if present), not just the interface. And check for either candidate being relayed, then route is relayed. --- .../clientlib/steamnetworkingsockets_ice_client.cpp | 11 +++++++---- .../clientlib/steamnetworkingsockets_ice_client.h | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.cpp index baeee63..ab487de 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.cpp @@ -1269,7 +1269,7 @@ void CSteamNetworkingICESession::SetSelectedCandidatePair( ICECandidatePair *pPa SpewMsg( "\n\nSelected candidate %s -> %s.\n\n", SteamNetworkingIPAddrRender( pPair->m_localCandidate.m_pInterface->m_pSocket->m_boundAddr ).c_str(), SteamNetworkingIPAddrRender( pPair->m_remoteCandidate.m_addr ).c_str() ); m_pSelectedCandidatePair = pPair; if ( m_pCallbacks ) - m_pCallbacks->OnConnectionSelected( *pPair->m_localCandidate.m_pInterface, pPair->m_remoteCandidate ); + m_pCallbacks->OnConnectionSelected( pPair->m_localCandidate, pPair->m_remoteCandidate ); } void CSteamNetworkingICESession::InternalDeleteCandidatePair( ICECandidatePair *pPair ) @@ -2437,14 +2437,17 @@ void CConnectionTransportP2PICE_Valve::OnLocalCandidateDiscovered( EICECandidate LocalCandidateGathered( type, std::move( c ) ); } -void CConnectionTransportP2PICE_Valve::OnConnectionSelected( const ICESessionInterface& localInterface, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) +void CConnectionTransportP2PICE_Valve::OnConnectionSelected( const ICELocalCandidate& localCandidate, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) { ConnectionScopeLock lock( Connection(), "CConnectionTransportP2PICE_Valve::OnConnectionSelected"); m_currentRouteRemoteAddress = remoteCandidate.m_addr; - m_eCurrentRouteKind = k_ESteamNetTransport_UDP; - if ( IsRemoteAddressOnLocalSubnet( localInterface.m_pSocket->m_boundAddr, localInterface.m_nPrefixLen, remoteCandidate.m_addr ) ) + if ( localCandidate.IsRelay() || remoteCandidate.m_type == ICECandidateKind::Relayed ) + m_eCurrentRouteKind = k_ESteamNetTransport_TURN; + else if ( IsRemoteAddressOnLocalSubnet( localCandidate.m_pInterface->m_pSocket->m_boundAddr, localCandidate.m_pInterface->m_nPrefixLen, remoteCandidate.m_addr ) ) m_eCurrentRouteKind = k_ESteamNetTransport_UDPProbablyLocal; + else + m_eCurrentRouteKind = k_ESteamNetTransport_UDP; m_pingEndToEnd.Reset(); m_pingEndToEnd.ReceivedPing( m_pICESession->GetPing(), SteamNetworkingSockets_GetLocalTimestamp() ); Connection().TransportEndToEndConnectivityChanged( this, SteamNetworkingSockets_GetLocalTimestamp() ); diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.h b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.h index 398c240..bdfcb4b 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.h +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_ice_client.h @@ -452,7 +452,7 @@ namespace SteamNetworkingSocketsLib { public: virtual void OnLocalCandidateDiscovered( EICECandidateType type, const char *pszCandidateStr ) {} virtual void OnPacketReceived( const RecvPktInfo_t &info ) {} - virtual void OnConnectionSelected( const ICESessionInterface& localInterface, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) {} + virtual void OnConnectionSelected( const ICELocalCandidate& localCandidate, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) {} }; @@ -479,7 +479,7 @@ namespace SteamNetworkingSocketsLib { protected: virtual void OnLocalCandidateDiscovered( EICECandidateType type, const char *pszCandidateStr ) override; virtual void OnPacketReceived( const RecvPktInfo_t &info ) override; - virtual void OnConnectionSelected( const ICESessionInterface& localInterface, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) override; + virtual void OnConnectionSelected( const ICELocalCandidate& localCandidate, const CSteamNetworkingICESession::ICECandidateBase& remoteCandidate ) override; }; } // namespace SteamNetworkingSocketsLib