ignore proxies if they claim to be able to ping a lan, because it probably won't be yours.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4934 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
6f5f8c3e34
commit
67786a2601
4 changed files with 80 additions and 54 deletions
|
@ -2784,8 +2784,8 @@ int CL_ReadServerInfo(char *msg, enum masterprotocol_e prototype, qboolean favor
|
|||
NET_AdrToString(adr, sizeof(adr), &info->adr);
|
||||
|
||||
Z_Free(info->peers);
|
||||
info->numpeers = remaining;
|
||||
peer = info->peers = Z_Malloc(sizeof(*peer)*info->numpeers);
|
||||
info->numpeers = 0;
|
||||
peer = info->peers = Z_Malloc(sizeof(*peer)*remaining);
|
||||
|
||||
while (remaining --> 0)
|
||||
{
|
||||
|
@ -2800,20 +2800,24 @@ int CL_ReadServerInfo(char *msg, enum masterprotocol_e prototype, qboolean favor
|
|||
peer->ping = *ptr++;
|
||||
peer->ping |= *ptr++<<8;
|
||||
|
||||
peer->peer = Master_InfoForServer(&pa);
|
||||
if (!peer->peer)
|
||||
if (NET_ClassifyAddress(&pa, NULL) >= ASCOPE_NET)
|
||||
{
|
||||
//generate some lame peer node that we can use.
|
||||
peer->peer = Z_Malloc(sizeof(serverinfo_t));
|
||||
peer->peer->adr = pa;
|
||||
peer->peer->sends = 1;
|
||||
peer->peer->special = 0;
|
||||
peer->peer->refreshtime = 0;
|
||||
peer->peer->ping = 0xffff;
|
||||
peer->peer->next = firstserver;
|
||||
firstserver = peer->peer;
|
||||
peer->peer = Master_InfoForServer(&pa);
|
||||
if (!peer->peer)
|
||||
{
|
||||
//generate some lame peer node that we can use.
|
||||
peer->peer = Z_Malloc(sizeof(serverinfo_t));
|
||||
peer->peer->adr = pa;
|
||||
peer->peer->sends = 1;
|
||||
peer->peer->special = 0;
|
||||
peer->peer->refreshtime = 0;
|
||||
peer->peer->ping = 0xffff;
|
||||
peer->peer->next = firstserver;
|
||||
firstserver = peer->peer;
|
||||
}
|
||||
peer++;
|
||||
info->numpeers++;
|
||||
}
|
||||
peer++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1619,6 +1619,8 @@ static void SCR_DrawAutoID(vec3_t org, player_info_t *pl, qboolean isteam)
|
|||
|
||||
h = 0;
|
||||
|
||||
barwidth = 32;
|
||||
|
||||
//display health bar
|
||||
if (scr_autoid_health.ival)
|
||||
{
|
||||
|
@ -1631,7 +1633,6 @@ static void SCR_DrawAutoID(vec3_t org, player_info_t *pl, qboolean isteam)
|
|||
r = countof(healthcolours)-2;
|
||||
health = 100;
|
||||
}
|
||||
barwidth = 32;
|
||||
h += 8;
|
||||
y -= 8;
|
||||
R2D_ImageColours(healthcolours[r][0], healthcolours[r][1], healthcolours[r][2], healthcolours[r][3]*alpha);
|
||||
|
|
|
@ -100,6 +100,15 @@ void NET_PrintAddresses(struct ftenet_connections_s *collection);
|
|||
qboolean NET_AddressSmellsFunny(netadr_t *a);
|
||||
qboolean NET_EnsureRoute(struct ftenet_connections_s *collection, char *routename, char *host, qboolean islisten);
|
||||
|
||||
enum addressscope_e
|
||||
{
|
||||
ASCOPE_PROCESS=0,
|
||||
ASCOPE_HOST=1,
|
||||
ASCOPE_LAN=2,
|
||||
ASCOPE_NET=3
|
||||
};
|
||||
enum addressscope_e NET_ClassifyAddress(netadr_t *adr, char **outdesc);
|
||||
|
||||
qboolean NET_CompareAdr (netadr_t *a, netadr_t *b);
|
||||
qboolean NET_CompareBaseAdr (netadr_t *a, netadr_t *b);
|
||||
void NET_AdrToStringResolve (netadr_t *adr, void (*resolved)(void *ctx, void *data, size_t a, size_t b), void *ctx, size_t a, size_t b);
|
||||
|
|
|
@ -5024,6 +5024,53 @@ int NET_EnumerateAddresses(ftenet_connections_t *collection, struct ftenet_gener
|
|||
return found;
|
||||
}
|
||||
|
||||
enum addressscope_e NET_ClassifyAddress(netadr_t *adr, char **outdesc)
|
||||
{
|
||||
int scope = ASCOPE_NET;
|
||||
char *desc = NULL;
|
||||
|
||||
if (adr->type == NA_LOOPBACK)
|
||||
{
|
||||
//we don't list 127.0.0.1 or ::1, so don't bother with this either. its not interesting.
|
||||
scope = ASCOPE_PROCESS, desc = "internal";
|
||||
}
|
||||
else if (adr->type == NA_IPV6 || adr->type == NA_BROADCAST_IP6 || adr->type == NA_TCPV6 || adr->type == NA_TLSV6)
|
||||
{
|
||||
if ((*(int*)adr->address.ip6&BigLong(0xffc00000)) == BigLong(0xfe800000)) //fe80::/10
|
||||
scope = ASCOPE_LAN, desc = "link-local";
|
||||
else if ((*(int*)adr->address.ip6&BigLong(0xfe000000)) == BigLong(0xfc00000)) //fc::/7
|
||||
scope = ASCOPE_LAN, desc = "ULA/private";
|
||||
else if (*(int*)adr->address.ip6 == BigLong(0x20010000)) //2001::/32
|
||||
scope = ASCOPE_NET, desc = "toredo";
|
||||
else if ((*(int*)adr->address.ip6&BigLong(0xffff0000)) == BigLong(0x20020000)) //2002::/16
|
||||
scope = ASCOPE_NET, desc = "6to4";
|
||||
else if (memcmp(adr->address.ip6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 16) == 0) //::1
|
||||
scope = ASCOPE_HOST, desc = "localhost";
|
||||
else if (memcmp(adr->address.ip6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) == 0) //::
|
||||
scope = ASCOPE_NET, desc = "any";
|
||||
}
|
||||
else if (adr->type == NA_IP || adr->type == NA_BROADCAST_IP || adr->type == NA_TCP || adr->type == NA_TLSV4)
|
||||
{
|
||||
if ((*(int*)adr->address.ip&BigLong(0xffff0000)) == BigLong(0xA9FE0000)) //169.254.x.x/16
|
||||
scope = ASCOPE_LAN, desc = "link-local";
|
||||
else if ((*(int*)adr->address.ip&BigLong(0xff000000)) == BigLong(0x0a000000)) //10.x.x.x/8
|
||||
scope = ASCOPE_LAN, desc = "private";
|
||||
else if ((*(int*)adr->address.ip&BigLong(0xff000000)) == BigLong(0x7f000000)) //127.x.x.x/8
|
||||
scope = ASCOPE_HOST, desc = "localhost";
|
||||
else if ((*(int*)adr->address.ip&BigLong(0xfff00000)) == BigLong(0xac100000)) //172.16.x.x/12
|
||||
scope = ASCOPE_LAN, desc = "private";
|
||||
else if ((*(int*)adr->address.ip&BigLong(0xffff0000)) == BigLong(0xc0a80000)) //192.168.x.x/16
|
||||
scope = ASCOPE_LAN, desc = "private";
|
||||
else if ((*(int*)adr->address.ip&BigLong(0xffc00000)) == BigLong(0x64400000)) //10.64.x.x/10
|
||||
scope = ASCOPE_LAN, desc = "CGNAT";
|
||||
else if (*(int*)adr->address.ip == BigLong(0x00000000)) //0.0.0.0/32
|
||||
scope = ASCOPE_LAN, desc = "any";
|
||||
}
|
||||
if (outdesc)
|
||||
*outdesc = desc;
|
||||
return scope;
|
||||
}
|
||||
|
||||
#define MAXADDRESSES 64
|
||||
void NET_PrintAddresses(ftenet_connections_t *collection)
|
||||
{
|
||||
|
@ -5044,45 +5091,10 @@ void NET_PrintAddresses(ftenet_connections_t *collection)
|
|||
{
|
||||
if (addr[i].type != NA_INVALID)
|
||||
{
|
||||
char *scope = "net";
|
||||
char *desc = NULL;
|
||||
if (addr[i].type == NA_LOOPBACK)
|
||||
{
|
||||
//we don't list 127.0.0.1 or ::1, so don't bother with this either. its not interesting.
|
||||
scope = NULL/*"internal"*/, desc = "internal";
|
||||
}
|
||||
else if (addr[i].type == NA_IPV6)
|
||||
{
|
||||
if ((*(int*)addr[i].address.ip6&BigLong(0xffc00000)) == BigLong(0xfe800000)) //fe80::/10
|
||||
scope = "lan", desc = "link-local";
|
||||
else if ((*(int*)addr[i].address.ip6&BigLong(0xfe000000)) == BigLong(0xfc00000)) //fc::/7
|
||||
scope = "lan", desc = "ULA/private";
|
||||
else if (*(int*)addr[i].address.ip6 == BigLong(0x20010000)) //2001::/32
|
||||
scope = "net", desc = "toredo";
|
||||
else if ((*(int*)addr[i].address.ip6&BigLong(0xffff0000)) == BigLong(0x20020000)) //2002::/16
|
||||
scope = "net", desc = "6to4";
|
||||
else if (memcmp(addr[i].address.ip6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 16) == 0) //::1
|
||||
scope = "local", desc = "localhost";
|
||||
else if (memcmp(addr[i].address.ip6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) == 0) //::
|
||||
scope = "net", desc = "any";
|
||||
}
|
||||
else if (addr[i].type == NA_IP)
|
||||
{
|
||||
if ((*(int*)addr[i].address.ip&BigLong(0xffff0000)) == BigLong(0xA9FE0000)) //169.254.x.x/16
|
||||
scope = "lan", desc = "link-local";
|
||||
else if ((*(int*)addr[i].address.ip&BigLong(0xff000000)) == BigLong(0x0a000000)) //10.x.x.x/8
|
||||
scope = "lan", desc = "private";
|
||||
else if ((*(int*)addr[i].address.ip&BigLong(0xff000000)) == BigLong(0x7f000000)) //127.x.x.x/8
|
||||
scope = "local", desc = "localhost";
|
||||
else if ((*(int*)addr[i].address.ip&BigLong(0xfff00000)) == BigLong(0xac100000)) //172.16.x.x/12
|
||||
scope = "lan", desc = "private";
|
||||
else if ((*(int*)addr[i].address.ip&BigLong(0xffff0000)) == BigLong(0xc0a80000)) //192.168.x.x/16
|
||||
scope = "lan", desc = "private";
|
||||
else if ((*(int*)addr[i].address.ip&BigLong(0xffc00000)) == BigLong(0x64400000)) //10.64.x.x/10
|
||||
scope = "lan", desc = "CGNAT";
|
||||
else if (*(int*)addr[i].address.ip == BigLong(0x00000000)) //0.0.0.0/32
|
||||
scope = "lan", desc = "any";
|
||||
}
|
||||
char *scopes[] = {NULL, "local", "lan", "net"};
|
||||
char *scope;
|
||||
char *desc;
|
||||
scope = scopes[NET_ClassifyAddress(&addr[i], &desc)];
|
||||
if (scope)
|
||||
{
|
||||
warn = false;
|
||||
|
|
Loading…
Reference in a new issue