]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/ipban.qc
why does fteqcc fail so much? seems like f *= x now is equivalent to f = x
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / ipban.qc
index 9dd3cb51ad08ad1ba7c79e4aaaab79afed593339..293a9b4e40497cf4a2302ecf3da74bd1e11c500d 100644 (file)
@@ -345,7 +345,7 @@ float Ban_GetClientIP(entity client)
 
        i1 = strstrofs(s, ".", 0);
        if(i1 < 0)
-               return FALSE;
+               goto ipv6;
        i2 = strstrofs(s, ".", i1 + 1);
        if(i2 < 0)
                return FALSE;
@@ -354,12 +354,36 @@ float Ban_GetClientIP(entity client)
                return FALSE;
        i4 = strstrofs(s, ".", i3 + 1);
        if(i4 >= 0)
+               s = substring(s, 0, i4);
+       
+       ban_ip1 = substring(s, 0, i1); // 8
+       ban_ip2 = substring(s, 0, i2); // 16
+       ban_ip3 = substring(s, 0, i3); // 24
+       ban_ip4 = strcat1(s); // 32
+       return TRUE;
+
+:ipv6
+       i1 = strstrofs(s, ":", 0);
+       if(i1 < 0)
+               return FALSE;
+       i1 = strstrofs(s, ":", i1 + 1);
+       if(i1 < 0)
                return FALSE;
+       i2 = strstrofs(s, ":", i1 + 1);
+       if(i2 < 0)
+               return FALSE;
+       i3 = strstrofs(s, ":", i2 + 1);
+       if(i3 < 0)
+               return FALSE;
+
+       ban_ip1 = strcat(substring(s, 0, i1), "::/32"); // 32
+       ban_ip2 = strcat(substring(s, 0, i2), "::/48"); // 48
+       ban_ip4 = strcat(substring(s, 0, i3), "::/64"); // 64
 
-       ban_ip1 = substring(s, 0, i1);
-       ban_ip2 = substring(s, 0, i2);
-       ban_ip3 = substring(s, 0, i3);
-       ban_ip4 = strcat1(s);
+       if(i3 - i2 > 3) // means there is more than 2 digits and a : in the range
+               ban_ip3 = strcat(substring(s, 0, i2), ":", substring(s, i2 + 1, i3 - i2 - 3), "00::/56");
+       else
+               ban_ip3 = strcat(substring(s, 0, i2), ":0::/56");
 
        return TRUE;
 }