mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 15:22:20 +00:00
Don't accept hole punch requests to local network
This commit is contained in:
parent
eab8f99eab
commit
0f122fd5dd
1 changed files with 27 additions and 1 deletions
28
src/i_tcp.c
28
src/i_tcp.c
|
@ -599,11 +599,37 @@ void Command_Numnodes(void)
|
|||
#endif
|
||||
|
||||
#ifndef NONET
|
||||
/* not one of the reserved "local" addresses */
|
||||
static boolean
|
||||
is_external_address (UINT32 p)
|
||||
{
|
||||
UINT8 a = (p & 255);
|
||||
UINT8 b = ((p >> 8) & 255);
|
||||
|
||||
if (p == (UINT32)~0)/* 255.255.255.255 */
|
||||
return 0;
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case 0:
|
||||
case 10:
|
||||
case 127:
|
||||
return false;
|
||||
case 172:
|
||||
return (b & ~15) != 16;/* 16 - 31 */
|
||||
case 192:
|
||||
return b != 168;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean hole_punch(ssize_t c)
|
||||
{
|
||||
/* See ../doc/Holepunch-Protocol.txt */
|
||||
if (cv_rendezvousserver.string[0] &&
|
||||
c == 10 && holepunchpacket->magic == hole_punch_magic)
|
||||
c == 10 && holepunchpacket->magic == hole_punch_magic &&
|
||||
is_external_address(ntohl(holepunchpacket->addr)))
|
||||
{
|
||||
mysockaddr_t addr;
|
||||
addr.ip4.sin_family = AF_INET;
|
||||
|
|
Loading…
Reference in a new issue