mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-25 13:21:36 +00:00
Fix '+set tls_provider foo' not working properly. Fixes https://github.com/fte-team/fteqw/issues/162
This commit is contained in:
parent
f8962b6c47
commit
d97fd1bfc9
2 changed files with 31 additions and 32 deletions
|
@ -897,6 +897,7 @@ Cvar_Set
|
|||
static cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
||||
{ //fixme: force should probably be a latch bitmask
|
||||
char *latch=NULL;
|
||||
qboolean changed;
|
||||
|
||||
COM_AssertMainThread("Cvar_SetCore");
|
||||
|
||||
|
@ -1002,12 +1003,14 @@ static cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
|||
|
||||
latch = var->string;//save off the old value (so cvar_set(var, var->string) works)
|
||||
|
||||
var->string = (char*)Z_Malloc (Q_strlen(value)+1);
|
||||
Q_strcpy (var->string, value);
|
||||
var->value = Q_atof (var->string);
|
||||
var->ival = Q_atoi (var->string);
|
||||
changed = (!latch) || strcmp(latch, value);
|
||||
|
||||
var->flags &= ~CVAR_TEAMPLAYTAINT;
|
||||
if (changed)
|
||||
{
|
||||
var->string = Z_StrDup (value);
|
||||
var->value = Q_atof (var->string);
|
||||
var->ival = Q_atoi (var->string);
|
||||
|
||||
{
|
||||
char *str = COM_Parse(var->string);
|
||||
|
@ -1026,9 +1029,7 @@ static cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
|||
}
|
||||
|
||||
if (latch)
|
||||
{
|
||||
if (strcmp(latch, value))
|
||||
{
|
||||
{ //don't do this on registration.
|
||||
var->modified=true; //only modified if it changed.
|
||||
var->modifiedcount++;
|
||||
if (var->callback)
|
||||
|
@ -1049,6 +1050,7 @@ static cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if ((var->flags & CVAR_ARCHIVE) && !(var->flags & CVAR_SERVEROVERRIDE) && cl_warncmd.ival)
|
||||
{
|
||||
if (var->latched_string)
|
||||
|
@ -1058,12 +1060,11 @@ static cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(latch, value))
|
||||
if (!latch || strcmp(latch, value))
|
||||
Cvar_ConfigChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Z_Free (latch); // free the old value string
|
||||
}
|
||||
|
||||
|
|
|
@ -160,16 +160,11 @@ static void QDECL NET_Enable_DTLS_Changed(struct cvar_s *var, char *oldvalue)
|
|||
if (!*var->string)
|
||||
var->ival = 0; //FIXME: change to 1 then 2 when better tested.
|
||||
|
||||
if (var->ival && svs.sockets)
|
||||
if (svs.sockets)
|
||||
{
|
||||
if (!svs.sockets->dtlsfuncs)
|
||||
svs.sockets->dtlsfuncs = DTLS_InitServer();
|
||||
if (!svs.sockets->dtlsfuncs)
|
||||
{
|
||||
if (var->ival >= 2)
|
||||
svs.sockets->dtlsfuncs = (var->ival)?DTLS_InitServer():NULL;
|
||||
if (!svs.sockets->dtlsfuncs && var->ival >= 2)
|
||||
Con_Printf("%sUnable to set %s to \"%s\", no DTLS provider available.\n", (var->ival >= 2)?CON_ERROR:CON_WARNING, var->name, var->string);
|
||||
var->ival = 0; //disable the cvar (internally) if we don't have a usable certificate. this allows us to default the cvar to enabled without it breaking otherwise.
|
||||
}
|
||||
}
|
||||
}
|
||||
cvar_t net_enable_dtls = CVARAFCD("net_enable_dtls", "", "sv_listen_dtls", 0, NET_Enable_DTLS_Changed, "Controls serverside dtls support.\n0: dtls blocked, not advertised.\n1: clientside choice.\n2: used where possible (recommended setting).\n3: disallow non-dtls clients (sv_port_tcp should be eg tls://[::]:27500 to also disallow unencrypted tcp connections).");
|
||||
|
@ -253,6 +248,7 @@ static void NET_TLS_Provider_Changed(struct cvar_s *var, char *oldvalue)
|
|||
}
|
||||
|
||||
#if defined(HAVE_DTLS) && defined(HAVE_SERVER)
|
||||
if (net_enable_dtls.string) //might not be registered yet...
|
||||
Cvar_ForceCallback(&net_enable_dtls);
|
||||
#endif
|
||||
}
|
||||
|
@ -2133,6 +2129,8 @@ qboolean NET_StringToAdrMasked (const char *s, qboolean allowdns, netadr_t *a, n
|
|||
|
||||
qboolean NET_IsEncrypted(netadr_t *adr)
|
||||
{
|
||||
if (adr->type == NA_LOOPBACK)
|
||||
return true; //might as well claim it, others can't snoop on it so...
|
||||
#ifdef SUPPORT_ICE
|
||||
if (adr->type == NA_ICE && ICE_IsEncrypted(adr))
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue