]> 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 1ec0f4d3eadc7903f1a6490903283213d50b288c..293a9b4e40497cf4a2302ecf3da74bd1e11c500d 100644 (file)
@@ -160,12 +160,15 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
                        continue;
 
                l = strlen(ip);
-               for(j = 0; j < l; ++j)
-                       if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
-                       {
-                               print("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
-                               goto skip;
-                       }
+               if(l != 44) // length 44 is a cryptographic ID
+               {
+                       for(j = 0; j < l; ++j)
+                               if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
+                               {
+                                       print("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
+                                       goto skip;
+                               }
+               }
 
                if(cvar("g_ban_sync_trusted_servers_verify"))
                        if((strstrofs(strcat(";", OnlineBanList_Servers, ";"), strcat(";", serverip, ";"), 0) == -1))
@@ -243,9 +246,7 @@ string ban_ip1;
 string ban_ip2;
 string ban_ip3;
 string ban_ip4;
-#ifdef UID
-string ban_uid;
-#endif
+string ban_idfp;
 
 void Ban_SaveBans()
 {
@@ -335,9 +336,10 @@ float Ban_GetClientIP(entity client)
        float i1, i2, i3, i4;
        string s;
 
-#ifdef UID
-       ban_uid = client.uid;
-#endif
+       if(client.crypto_keyfp)
+               ban_idfp = client.crypto_idfp;
+       else
+               ban_idfp = string_null;
 
        s = client.netaddress;
 
@@ -388,7 +390,7 @@ float Ban_GetClientIP(entity client)
 
 float Ban_IsClientBanned(entity client, float idx)
 {
-       float i, b, e;
+       float i, b, e, ipbanned;
        if(!ban_loaded)
                Ban_LoadBans();
        if(!Ban_GetClientIP(client))
@@ -403,20 +405,22 @@ float Ban_IsClientBanned(entity client, float idx)
                b = idx;
                e = idx + 1;
        }
+       ipbanned = FALSE;
        for(i = b; i < e; ++i)
        {
                string s;
                if(time > ban_expire[i])
                        continue;
                s = ban_ip[i];
-               if(ban_ip1 == s) return TRUE;
-               if(ban_ip2 == s) return TRUE;
-               if(ban_ip3 == s) return TRUE;
-               if(ban_ip4 == s) return TRUE;
-#ifdef UID
-               if(ban_uid == s) return TRUE;
-#endif
+               if(ban_ip1 == s) ipbanned = TRUE;
+               if(ban_ip2 == s) ipbanned = TRUE;
+               if(ban_ip3 == s) ipbanned = TRUE;
+               if(ban_ip4 == s) ipbanned = TRUE;
+               if(ban_idfp == s) return TRUE;
        }
+       if(ipbanned)
+               if(!cvar("g_banned_list_idmode") || !ban_idfp)
+                       return TRUE;
        return FALSE;
 }
 
@@ -560,12 +564,9 @@ void Ban_KickBanClient(entity client, float bantime, float masksize, string reas
                default:
                        Ban_Insert(ban_ip4, bantime, reason, 1);
                        break;
-#ifdef UID
-               case 0:
-                       Ban_Insert(ban_uid, bantime, reason, 1);
-                       break;
-#endif
        }
+       if(ban_idfp)
+               Ban_Insert(ban_idfp, bantime, reason, 1);
        /*
         * not needed, as we enforce the ban in Ban_Insert anyway
        // and kick him