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.

(cherry picked from commit 6776f82e78)
This commit is contained in:
Fletcher Dunn
2026-05-27 20:50:34 -07:00
parent 256f4fe076
commit 94fc4a809f
2 changed files with 9 additions and 6 deletions
@@ -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() );
@@ -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