add support for a geolocation table

including two converter scripts to use Geolite2 and Webnet77 tables
This commit is contained in:
ac-stef
2017-06-27 15:15:21 +02:00
parent ac5229dfba
commit 63668e0dda
10 changed files with 219 additions and 4 deletions
+6 -1
View File
@@ -466,7 +466,12 @@ const char *atoip(const char *s, enet_uint32 *ip)
{
unsigned int d[4];
int n;
if(!s || sscanf(s, "%u.%u.%u.%u%n", d, d + 1, d + 2, d + 3, &n) != 4) return NULL;
if(!s) return NULL;
if(sscanf(s, "%u.%u.%u.%u%n", d, d + 1, d + 2, d + 3, &n) != 4)
{
*ip = strtoul(s, (char **)&s, 0); // try single-integer IPs
return *ip > 0xffffff ? s : NULL; // require first octet to be non-zero to avoid misinterpreting faulty dotted IPs
}
*ip = 0;
loopi(4)
{