From 27c32fc1a0074b24fc0aeeb6c3fcde4c7103eb2f Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 16 Apr 2022 20:28:18 +0000 Subject: [PATCH] Add a new net_ice_usewebrtc cvar for people that want to skip the extra overheads/bugs of webrtc. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6230 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_main.c | 5 +++++ engine/common/net_ice.c | 12 +++++++++++- engine/common/net_wins.c | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index f6b92102b..08c50cf59 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -4123,6 +4123,11 @@ void CL_ReadPacket(void) return; #endif +#if defined(SUPPORT_ICE) + if (ICE_WasStun(cls.sockets)) + return; +#endif + #ifdef NQPROT if (cls.demoplayback == DPB_NETQUAKE) { diff --git a/engine/common/net_ice.c b/engine/common/net_ice.c index 2ab6b8227..5458386f5 100644 --- a/engine/common/net_ice.c +++ b/engine/common/net_ice.c @@ -26,6 +26,7 @@ typedef struct #endif #ifdef SUPPORT_ICE cvar_t net_ice_exchangeprivateips = CVARFD("net_ice_exchangeprivateips", "", CVAR_NOTFROMSERVER, "Boolean. When set to 0, hides private IP addresses from your peers. Only addresses determined from the other side of your router will be shared. Setting it to 0 may be desirable but it can cause connections to fail when your router does not support hairpinning, whereas 1 fixes that at the cost of exposing private IP addresses."); +cvar_t net_ice_usewebrtc = CVARFD("net_ice_usewebrtc", "", CVAR_NOTFROMSERVER, "Use webrtc's extra overheads rather than simple ICE. This makes packets larger and is slower to connect, but is compatible with the web port."); /* Interactive Connectivity Establishment (rfc 5245) find out your peer's potential ports. @@ -2928,9 +2929,18 @@ static void FTENET_ICE_Establish(ftenet_ice_connection_t *b, int cl, struct ices { //sends offer char buf[256]; struct icestate_s *ice; + qboolean usewebrtc; if (*ret) iceapi.ICE_Close(*ret); - ice = *ret = iceapi.ICE_Create(b, NULL, b->generic.islisten?NULL:va("/%s", b->gamename), ICEM_WEBRTC, b->generic.islisten?ICEP_QWSERVER:ICEP_QWCLIENT); +#ifndef HAVE_DTLS + usewebrtc = false; +#else + if (!*net_ice_usewebrtc.string) + usewebrtc = b->generic.islisten; //its broken for clients right now, apparently. don't break browsers connecting to servers though. + else + usewebrtc = net_ice_usewebrtc.ival; +#endif + ice = *ret = iceapi.ICE_Create(b, NULL, b->generic.islisten?NULL:va("/%s", b->gamename), usewebrtc?ICEM_WEBRTC:ICEM_ICE, b->generic.islisten?ICEP_QWSERVER:ICEP_QWCLIENT); if (!*ret) return; //some kind of error?!? iceapi.ICE_Set(ice, "controller", b->generic.islisten?"0":"1"); diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index 6cacd3ec4..5841d3ff3 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -150,7 +150,7 @@ cvar_t net_enable_websockets = CVARD("net_enable_websockets", "1", "If enabled, #endif #endif #endif -extern cvar_t net_ice_exchangeprivateips; +extern cvar_t net_ice_exchangeprivateips, net_ice_usewebrtc; #if defined(HAVE_DTLS) #if defined(HAVE_SERVER) static void QDECL NET_Enable_DTLS_Changed(struct cvar_s *var, char *oldvalue) @@ -8943,6 +8943,7 @@ void NET_Init (void) #ifdef SUPPORT_ICE Cvar_Register(&net_ice_exchangeprivateips, "networking"); + Cvar_Register(&net_ice_usewebrtc, "networking"); #endif #if defined(HAVE_CLIENT)||defined(HAVE_SERVER)