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
This commit is contained in:
Spoike 2022-04-16 20:28:18 +00:00
parent 2ac548e17f
commit 27c32fc1a0
3 changed files with 18 additions and 2 deletions

View file

@ -4123,6 +4123,11 @@ void CL_ReadPacket(void)
return; return;
#endif #endif
#if defined(SUPPORT_ICE)
if (ICE_WasStun(cls.sockets))
return;
#endif
#ifdef NQPROT #ifdef NQPROT
if (cls.demoplayback == DPB_NETQUAKE) if (cls.demoplayback == DPB_NETQUAKE)
{ {

View file

@ -26,6 +26,7 @@ typedef struct
#endif #endif
#ifdef SUPPORT_ICE #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_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) Interactive Connectivity Establishment (rfc 5245)
find out your peer's potential ports. 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 { //sends offer
char buf[256]; char buf[256];
struct icestate_s *ice; struct icestate_s *ice;
qboolean usewebrtc;
if (*ret) if (*ret)
iceapi.ICE_Close(*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) if (!*ret)
return; //some kind of error?!? return; //some kind of error?!?
iceapi.ICE_Set(ice, "controller", b->generic.islisten?"0":"1"); iceapi.ICE_Set(ice, "controller", b->generic.islisten?"0":"1");

View file

@ -150,7 +150,7 @@ cvar_t net_enable_websockets = CVARD("net_enable_websockets", "1", "If enabled,
#endif #endif
#endif #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_DTLS)
#if defined(HAVE_SERVER) #if defined(HAVE_SERVER)
static void QDECL NET_Enable_DTLS_Changed(struct cvar_s *var, char *oldvalue) static void QDECL NET_Enable_DTLS_Changed(struct cvar_s *var, char *oldvalue)
@ -8943,6 +8943,7 @@ void NET_Init (void)
#ifdef SUPPORT_ICE #ifdef SUPPORT_ICE
Cvar_Register(&net_ice_exchangeprivateips, "networking"); Cvar_Register(&net_ice_exchangeprivateips, "networking");
Cvar_Register(&net_ice_usewebrtc, "networking");
#endif #endif
#if defined(HAVE_CLIENT)||defined(HAVE_SERVER) #if defined(HAVE_CLIENT)||defined(HAVE_SERVER)