mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-27 19:50:51 +00:00
Do not query DNS for holepunchserver more than once per tic
This commit is contained in:
parent
2f17fdca6c
commit
1551e4572d
1 changed files with 19 additions and 7 deletions
26
src/i_tcp.c
26
src/i_tcp.c
|
@ -175,6 +175,7 @@ static UINT8 UPNP_support = TRUE;
|
||||||
#endif // !NONET
|
#endif // !NONET
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
|
#include "i_time.h"
|
||||||
#include "i_net.h"
|
#include "i_net.h"
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "d_netfil.h"
|
#include "d_netfil.h"
|
||||||
|
@ -1517,18 +1518,29 @@ static void rendezvous(int size)
|
||||||
char *host = strtok(addrs, ":");
|
char *host = strtok(addrs, ":");
|
||||||
char *port = strtok(NULL, ":");
|
char *port = strtok(NULL, ":");
|
||||||
|
|
||||||
mysockaddr_t rzv;
|
static mysockaddr_t rzv;
|
||||||
|
static tic_t refreshtic = (tic_t)-1;
|
||||||
|
|
||||||
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
|
tic_t tic = I_GetTime();
|
||||||
|
|
||||||
|
if (tic != refreshtic)
|
||||||
|
{
|
||||||
|
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
|
||||||
|
{
|
||||||
|
refreshtic = tic;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_ERROR, "Failed to contact rendezvous server (%s).\n",
|
||||||
|
cv_rendezvousserver.string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tic == refreshtic)
|
||||||
{
|
{
|
||||||
holepunchpacket->magic = hole_punch_magic;
|
holepunchpacket->magic = hole_punch_magic;
|
||||||
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
|
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
CONS_Alert(CONS_ERROR, "Failed to contact rendezvous server (%s).\n",
|
|
||||||
cv_rendezvousserver.string);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(addrs);
|
free(addrs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue