diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.cpp index 9e07853..ea41361 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.cpp @@ -110,7 +110,9 @@ CSteamNetworkConnectionP2P::CSteamNetworkConnectionP2P( CSteamNetworkingSockets m_pCurrentTransportP2P = nullptr; #ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR m_pTransportP2PSDR = nullptr; - m_pTransportToSDRServer = nullptr; + #ifdef SDR_ENABLE_HOSTED_CLIENT + m_pTransportToSDRServer = nullptr; + #endif #ifdef SDR_ENABLE_HOSTED_SERVER m_pTransportFromSDRClient = nullptr; #endif @@ -813,11 +815,13 @@ void CSteamNetworkConnectionP2P::DestroyTransport() #ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR Assert( m_pTransportP2PSDR == nullptr ); // Should have been nuked above - if ( m_pTransportToSDRServer ) - { - m_pTransportToSDRServer->TransportDestroySelfNow(); - m_pTransportToSDRServer = nullptr; - } + #ifdef SDR_ENABLE_HOSTED_CLIENT + if ( m_pTransportToSDRServer ) + { + m_pTransportToSDRServer->TransportDestroySelfNow(); + m_pTransportToSDRServer = nullptr; + } + #endif #ifdef SDR_ENABLE_HOSTED_SERVER if ( m_pTransportFromSDRClient ) @@ -1690,12 +1694,17 @@ bool CSteamNetworkConnectionP2P::ProcessSignal( const CMsgSteamNetworkingP2PRend // Check for SDR hosted server telling us to contact them via the special protocol if ( msg.has_hosted_server_ticket() ) { - if ( !IsSDRHostedServerClient() ) - { - SpewMsgGroup( LogLevel_P2PRendezvous(), "[%s] Peer sent hosted_server_ticket. Switching to SDR client transport\n", GetDescription() ); - if ( !BSelectTransportToSDRServerFromSignal( msg ) ) - return false; - } + #ifdef SDR_ENABLE_HOSTED_CLIENT + if ( !IsSDRHostedServerClient() ) + { + SpewMsgGroup( LogLevel_P2PRendezvous(), "[%s] Peer sent hosted_server_ticket. Switching to SDR client transport\n", GetDescription() ); + if ( !BSelectTransportToSDRServerFromSignal( msg ) ) + return false; + } + #else + ConnectionState_ProblemDetectedLocally( k_ESteamNetConnectionEnd_Misc_P2P_Rendezvous, "Peer is a hosted dedicated server. Not supported." ); + return false; + #endif } // Go ahead and process the SDR P2P routes, if they are sending them @@ -1910,7 +1919,7 @@ ESteamNetConnectionEnd CSteamNetworkConnectionP2P::CheckRemoteCert( const CertAu // If ticket was bound to a data center, then make sure the cert chain authorizes // them to send us there. - #ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR + #ifdef SDR_ENABLE_HOSTED_CLIENT if ( m_pTransportToSDRServer ) { SteamNetworkingPOPID popIDTicket = m_pTransportToSDRServer->m_authTicket.m_ticket.m_routing.GetPopID(); diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.h b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.h index 7efa064..fc36946 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.h +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_p2p.h @@ -267,14 +267,16 @@ public: // Peer to peer, over SDR CConnectionTransportP2PSDR *m_pTransportP2PSDR; CMsgSteamNetworkingP2PSDRRoutingSummary m_msgSDRRoutingSummary; + #endif - // Client connecting to hosted dedicated server over SDR. These are not really - // "Peer to peer" connections. In a previous iteration of the code these were - // a totally separate connection class, because we always knew when initiating - // the connection that it was going to be this type. However, now these connections - // may begin their life as an ordinary P2P connection, and only discover from a signal - // from the peer that it is a server in a hosted data center. Then they will switch to - // use the special-case optimized transport. + // Client connecting to hosted dedicated server over SDR. These are not really + // "Peer to peer" connections. In a previous iteration of the code these were + // a totally separate connection class, because we always knew when initiating + // the connection that it was going to be this type. However, now these connections + // may begin their life as an ordinary P2P connection, and only discover from a signal + // from the peer that it is a server in a hosted data center. Then they will switch to + // use the special-case optimized transport. + #ifdef SDR_ENABLE_HOSTED_CLIENT CConnectionTransportToSDRServer *m_pTransportToSDRServer; bool BInitConnectToSDRServer( const SteamNetworkingIdentity &identityTarget, int nRemoteVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions, SteamNetworkingErrMsg &errMsg ); bool BSelectTransportToSDRServerFromSignal( const CMsgSteamNetworkingP2PRendezvous &msg ); @@ -288,25 +290,23 @@ public: } return false; } - - // We are the server in special hosted data center - #ifdef SDR_ENABLE_HOSTED_SERVER - CConnectionTransportFromSDRClient *m_pTransportFromSDRClient; - inline bool IsSDRHostedServer() const - { - if ( m_pTransportFromSDRClient ) - { - Assert( m_vecAvailableTransports.empty() ); - return true; - } - return false; - } - #else - inline bool IsSDRHostedServer() const { return false; } - #endif - #else inline bool IsSDRHostedServerClient() const { return false; } + #endif + + // We are the server in special hosted data center + #ifdef SDR_ENABLE_HOSTED_SERVER + CConnectionTransportFromSDRClient *m_pTransportFromSDRClient; + inline bool IsSDRHostedServer() const + { + if ( m_pTransportFromSDRClient ) + { + Assert( m_vecAvailableTransports.empty() ); + return true; + } + return false; + } + #else inline bool IsSDRHostedServer() const { return false; } #endif diff --git a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h index 31b612e..97e6008 100644 --- a/src/steamnetworkingsockets/steamnetworkingsockets_internal.h +++ b/src/steamnetworkingsockets/steamnetworkingsockets_internal.h @@ -85,10 +85,10 @@ #define STEAMNETWORKINGSOCKETS_CAN_REQUEST_CERT #endif -// Always #define STEAMNETWORKINGSOCKETS_ENABLE_ICE, except in the opensource build. -// There, it must go on the command line +// Always #define STEAMNETWORKINGSOCKETS_ENABLE_ICE in a few places. +// You can also define it on the command line #ifndef STEAMNETWORKINGSOCKETS_ENABLE_ICE - #ifndef STEAMNETWORKINGSOCKETS_OPENSOURCE + #if defined( STEAMNETWORKINGSOCKETS_STEAMCLIENT ) || defined( STEAMNETWORKINGSOCKETS_STREAMINGCLIENT ) #define STEAMNETWORKINGSOCKETS_ENABLE_ICE #endif #endif