]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into divVerent/crypto2
authorRudolf Polzer <divverent@alientrap.org>
Sun, 5 Sep 2010 16:08:46 +0000 (18:08 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 5 Sep 2010 16:08:46 +0000 (18:08 +0200)
12 files changed:
defaultXonotic.cfg
qcsrc/client/Main.qc
qcsrc/menu/mbuiltin.qh
qcsrc/menu/skin-customizables.inc
qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c
qcsrc/menu/xonotic/serverlist.c
qcsrc/server/cl_client.qc
qcsrc/server/clientcommands.qc
qcsrc/server/extensions.qh
qcsrc/server/ipban.qc
qcsrc/server/race.qc
quake.rc

index 2d8046e4a8dfb5701085572a20f44e831b320ea6..1990af6dbad05f68a16d85820032aea0d519e38f 100644 (file)
@@ -1257,6 +1257,7 @@ set cl_gravity 800        "but ignored anyway"
 set g_ban_default_bantime 5400 "90 minutes"
 set g_ban_default_masksize 3   "whole 255.255.255.0 networks (set to 4 for single IPs); when UID support is compiled in, masksize 0 means banning by UID"
 set g_banned_list ""   "format: IP remainingtime IP remainingtime ..."
+set g_banned_list_idmode "1"   "when set, the IP banning system always uses the ID over the IP address (so a user in a banned IP range can connect if they have a valid signed ID)"
 alias bans "sv_cmd bans"
 alias ban "sv_cmd ban $*"         // usage: ban address(maybe incomplete, like 1.2.3) bantime(seconds)
 alias kickban "sv_cmd kickban $*" // usage: kickban # playerno bantime(seconds) masksize(bytes)
index 2fc1ce308bee3c0d7fd49907249f8dbd25dc205b..320ed94727aed077678eda54eade821b53ece437 100644 (file)
@@ -148,23 +148,6 @@ void CSQC_Init(void)
        }
        Tuba_Precache();
 
-#ifdef UID
-       {
-               // find the user ID
-               string uid;
-               registercvar("_cl_userid", "", CVAR_SAVE);
-               uid = cvar_string("_cl_userid");
-               if(strlen(uid) < 16)
-               {
-                       uid = "";
-                       for(i = 0; i < 4; ++i)
-                               uid = strcat(uid, substring(ftos(floor(10000 + random() * 10000)), 1, -1));
-               }
-               cvar_set("_cl_userid", uid);
-               localcmd(strcat("\ncmd uid ", uid, "\n"));
-       }
-#endif
-
        get_mi_min_max_texcoords(1); // try the CLEVER way first
        minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
        shortmapname = mi_shortname;
index 6d9d3345c30e0430ba892190176c3be584cd94b2..e325915c95e3791626f6c548f6b2383bbb9b0fee 100644 (file)
@@ -350,3 +350,12 @@ string(float, float) getgamedirinfo = #626;
 float log(float f) = #532;
 
 string(string format, ...) sprintf = #627;
+
+//DP_CRYPTO
+//idea: divVerent
+//darkplaces implementation: divVerent
+//field definitions: (MENUQC)
+string crypto_getkeyfp(string serveraddress) = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
+string crypto_getidfp(string serveraddress) = #634; // retrieves the cached host key fingerprint of a server given by IP address
+string crypto_getencryptlevel(string serveraddress) = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
+//description:
index c3320e503874d751d0a1688c8fa9c986a851f0c0..b93ecaa7ce84d5f4cc63dd9099c78e1963b0e3f9 100644 (file)
@@ -220,6 +220,8 @@ SKINBEGIN
        SKINFLOAT(ALPHA_SERVERLIST_HIGHPING, 0.4);
        SKINFLOAT(ALPHA_SERVERLIST_FAVORITE, 0.8);
        SKINVECTOR(COLOR_SERVERLIST_FAVORITE, '1 1 1');
+       SKINFLOAT(ALPHA_SERVERLIST_IMPOSSIBLE, 0.7);
+       SKINVECTOR(COLOR_SERVERLIST_IMPOSSIBLE, '0.3 0.3 0.3');
 
        // item: server info
        SKINVECTOR(COLOR_SERVERINFO_NAME, '1 1 1');
index 7770230d316d1d39bc1930499e92c8291496fdb8..21eefeae6d72ef0ea83f5878215f6b85c7276321 100644 (file)
@@ -5,7 +5,7 @@ CLASS(XonoticServerInfoDialog) EXTENDS(XonoticDialog)
        ATTRIB(XonoticServerInfoDialog, title, string, "Server Information")
        ATTRIB(XonoticServerInfoDialog, color, vector, SKINCOLOR_DIALOG_SERVERINFO)
        ATTRIB(XonoticServerInfoDialog, intendedWidth, float, 0.68)
-       ATTRIB(XonoticServerInfoDialog, rows, float, 11)
+       ATTRIB(XonoticServerInfoDialog, rows, float, 14)
        ATTRIB(XonoticServerInfoDialog, columns, float, 12)
 
        ATTRIB(XonoticServerInfoDialog, currentServerName, string, string_null)
@@ -18,6 +18,10 @@ CLASS(XonoticServerInfoDialog) EXTENDS(XonoticDialog)
        ATTRIB(XonoticServerInfoDialog, currentServerMod, string, string_null)
        ATTRIB(XonoticServerInfoDialog, currentServerVersion, string, string_null)
        ATTRIB(XonoticServerInfoDialog, currentServerPing, string, string_null)
+       ATTRIB(XonoticServerInfoDialog, currentServerKey, string, string_null)
+       ATTRIB(XonoticServerInfoDialog, currentServerID, string, string_null)
+       ATTRIB(XonoticServerInfoDialog, currentServerEncrypt, string, string_null)
+       ATTRIB(XonoticServerInfoDialog, currentServerCanConnect, string, string_null)
 
        ATTRIB(XonoticServerInfoDialog, nameLabel, entity, NULL)
        ATTRIB(XonoticServerInfoDialog, cnameLabel, entity, NULL)
@@ -29,6 +33,10 @@ CLASS(XonoticServerInfoDialog) EXTENDS(XonoticDialog)
        ATTRIB(XonoticServerInfoDialog, modLabel, entity, NULL)
        ATTRIB(XonoticServerInfoDialog, versionLabel, entity, NULL)
        ATTRIB(XonoticServerInfoDialog, pingLabel, entity, NULL)
+       ATTRIB(XonoticServerInfoDialog, keyLabel, entity, NULL)
+       ATTRIB(XonoticServerInfoDialog, idLabel, entity, NULL)
+       ATTRIB(XonoticServerInfoDialog, encryptLabel, entity, NULL)
+       ATTRIB(XonoticServerInfoDialog, canConnectLabel, entity, NULL)
 ENDCLASS(XonoticServerInfoDialog)
 
 float SLIST_FIELD_NAME;
@@ -74,7 +82,6 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
        me.currentServerType = strzone(typestr);
        me.typeLabel.setText(me.typeLabel, me.currentServerType);
 
-
        SLIST_FIELD_MAP = gethostcacheindexforkey("map");
        me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
        me.mapLabel.setText(me.mapLabel, me.currentServerMap);
@@ -106,6 +113,51 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
        s = ftos(gethostcachenumber(SLIST_FIELD_PING, i));
        me.currentServerPing = strzone(s);
        me.pingLabel.setText(me.pingLabel, me.currentServerPing);
+
+       print(me.currentServerCName, "\n");
+
+       s = crypto_getidfp(me.currentServerCName);
+       if not(s)
+               s = "N/A";
+       me.currentServerID = strzone(s);
+       me.idLabel.setText(me.idLabel, me.currentServerID);
+
+       s = crypto_getkeyfp(me.currentServerCName);
+       if not(s)
+               s = "N/A";
+       me.currentServerKey = strzone(s);
+       me.keyLabel.setText(me.keyLabel, me.currentServerKey);
+
+       s = crypto_getencryptlevel(me.currentServerCName);
+       if(s == "")
+       {
+               if(cvar("crypto_aeslevel") >= 3)
+                       me.currentServerEncrypt = "N/A (can't connect)";
+               else
+                       me.currentServerEncrypt = "N/A";
+       }
+       else switch(stof(substring(s, 0, 1)))
+       {
+               case 0:
+                       if(cvar("crypto_aeslevel") >= 3)
+                               me.currentServerEncrypt = "not supported (can't connect)";
+                       else
+                               me.currentServerEncrypt = "not supported";
+                       break;
+               case 1:
+                       me.currentServerEncrypt = "supported";
+                       break;
+               case 2:
+                       me.currentServerEncrypt = "requested";
+                       break;
+               case 3:
+                       if(cvar("crypto_aeslevel") <= 0)
+                               me.currentServerEncrypt = "required (can't connect)";
+                       else
+                               me.currentServerEncrypt = "required";
+                       break;
+       }
+       me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
 }
 
 void XonoticServerInfoDialog_fill(entity me)
@@ -166,6 +218,24 @@ void XonoticServerInfoDialog_fill(entity me)
                        e.allowCut = 1;
                        me.pingLabel = e;
 
+       me.TR(me);
+               me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "CA:"));
+               me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
+                       e.allowCut = 1;
+                       me.keyLabel = e;
+
+       me.TR(me);
+               me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Key:"));
+               me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
+                       e.allowCut = 1;
+                       me.idLabel = e;
+
+       me.TR(me);
+               me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Encryption:"));
+               me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
+                       e.allowCut = 1;
+                       me.encryptLabel = e;
+
        me.gotoRC(me, me.rows - 1, 0);
 
                me.TD(me, 1, me.columns - 6, e = makeXonoticButton("Close", '0 0 0'));
index d721c2555e2dbae45621da79f75b5d4601c88978..9de685ef4fbe0528e945d728aba70dc6ba1bc160 100644 (file)
@@ -95,41 +95,76 @@ void ServerList_UpdateFieldIDs()
 
 float IsFavorite(string srv)
 {
+       string p;
        float i, n;
+       if(srv == "")
+               return FALSE;
        srv = netaddress_resolve(srv, 26000);
+       p = crypto_getidfp(srv);
        n = tokenize_console(cvar_string("net_slist_favorites"));
        for(i = 0; i < n; ++i)
-               if(srv == netaddress_resolve(argv(i), 26000))
-                       return TRUE;
+       {
+               if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
+               {
+                       if(p)
+                               if(argv(i) == p)
+                                       return TRUE;
+               }
+               else
+               {
+                       if(srv == netaddress_resolve(argv(i), 26000))
+                               return TRUE;
+               }
+       }
        return FALSE;
 }
 
 void ToggleFavorite(string srv)
 {
-       string s, s0, s1, s2, srv_resolved;
-       float i, n;
+       string s, s0, s1, s2, srv_resolved, p;
+       float i, n, f;
        srv_resolved = netaddress_resolve(srv, 26000);
+       p = crypto_getidfp(srv_resolved);
        s = cvar_string("net_slist_favorites");
        n = tokenize_console(s);
+       f = 0;
        for(i = 0; i < n; ++i)
-               if(srv_resolved == netaddress_resolve(argv(i), 26000))
+       {
+               if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
                {
-                       s0 = s1 = s2 = "";
-                       if(i > 0)
-                               s0 = substring(s, 0, argv_end_index(i - 1));
-                       if(i < n-1)
-                               s2 = substring(s, argv_start_index(i + 1), -1);
-                       if(s0 != "" && s2 != "")
-                               s1 = " ";
-                       print("s0 = >>", s0, "<<\ns1 = >>", s1, "<<\ns2 = >>", s2, "<<\n");
-                       cvar_set("net_slist_favorites", strcat(s0, s1, s2));
-                       return;
+                       if(p)
+                               if(argv(i) != p)
+                                       continue;
                }
+               else
+               {
+                       if(srv_resolved != netaddress_resolve(argv(i), 26000))
+                               continue;
+               }
+               s0 = s1 = s2 = "";
+               if(i > 0)
+                       s0 = substring(s, 0, argv_end_index(i - 1));
+               if(i < n-1)
+                       s2 = substring(s, argv_start_index(i + 1), -1);
+               if(s0 != "" && s2 != "")
+                       s1 = " ";
+               cvar_set("net_slist_favorites", strcat(s0, s1, s2));
+               s = cvar_string("net_slist_favorites");
+               n = tokenize_console(s);
+               f = 1;
+               --i;
+       }
        
-       s1 = "";
-       if(s != "")
-               s1 = " ";
-       cvar_set("net_slist_favorites", strcat(s, " ", srv));
+       if(!f)
+       {
+               s1 = "";
+               if(s != "")
+                       s1 = " ";
+               if(p)
+                       cvar_set("net_slist_favorites", strcat(s, s1, p));
+               else
+                       cvar_set("net_slist_favorites", strcat(s, s1, srv));
+       }
 
        resorthostcache();
 }
@@ -556,6 +591,15 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float
                theAlpha = theAlpha * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINALPHA_SERVERLIST_FAVORITE;
        }
 
+       s = gethostcachestring(SLIST_FIELD_CNAME, i);
+       p = stof(substring(crypto_getencryptlevel(s), 0, 1));
+       if((p <= 0 && cvar("crypto_aeslevel") >= 3) || (p >= 3 && cvar("crypto_aeslevel") <= 0))
+       {
+               theColor = SKINCOLOR_SERVERLIST_IMPOSSIBLE;
+               theAlpha = SKINALPHA_SERVERLIST_IMPOSSIBLE;
+       }
+       // TODO show an icon for encryption status
+
        s = ftos(p);
        draw_Text(me.realUpperMargin * eY + (me.columnPingSize - draw_TextWidth(s, 0, me.realFontSize)) * eX, s, me.realFontSize, theColor, theAlpha, 0);
        s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_NAME, i), me.columnNameSize, 0, me.realFontSize);
index f08ef5f5385b7b9dad3eb90bd06a86efbbff21db..21ab80f2fef733a6c6a6f0221bb8ae0521022cc8 100644 (file)
@@ -1386,10 +1386,6 @@ Called when a client connects to the server
 string ColoredTeamName(float t);
 void DecodeLevelParms (void);
 //void dom_player_join_team(entity pl);
-#ifdef UID
-.float uid_kicktime;
-.string uid;
-#endif
 void ClientConnect (void)
 {
        float t;
@@ -1567,12 +1563,6 @@ void ClientConnect (void)
        else
                self.hitplotfh = -1;
 
-#ifdef UID
-       if(clienttype(self) == CLIENTTYPE_REAL)
-       if not(self.uid)
-               self.uid_kicktime = time + 60;
-#endif
-
        if(g_race || g_cts) {
                string rr;
                if(g_cts)
@@ -2903,16 +2893,6 @@ void PlayerPostThink (void)
                self.stat_count -= 1;
        }
 
-#ifdef UID
-       if(self.uid_kicktime)
-       if(time > self.uid_kicktime)
-       {
-               bprint("^3", self.netname, "^3 was kicked for missing UID.\n");
-               dropclient(self);
-               return;
-       }
-#endif
-
        if(sv_maxidle && frametime)
        {
                // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
index 171906428a39b2a29f146d811f3d97927a516196..a9fd886bfe9c331e34b7651faf4c4bca063703c5 100644 (file)
@@ -182,16 +182,6 @@ void SV_ParseClientCommand(string s) {
                        tokens = tokenize_console(s);
                }
                GetCvars(1);
-#ifdef UID
-       } else if(cmd == "uid") {
-               if not(self.uid)
-               {
-                       self.uid = strzone(argv(1));
-                       self.uid_kicktime = 0;
-                       print("Client ", etos(self), " has UID ", self.uid, "\n");
-                       Ban_MaybeEnforceBan(self);
-               }
-#endif
        } else if(cmd == "sentcvar") { // new system
                if(tokens == 2) // undefined cvar: use the default value on the server then
                {
index 18119546c63d1b82d5bd6a188961647d98f39968..ac774837299c5ce528f61e5ba84e86a44d474608 100644 (file)
@@ -1,60 +1,60 @@
 
-//DarkPlaces supported extension list, draft version 1.04
-
-//things that don't have extensions yet:
-.float disableclientprediction;
-
-//definitions that id Software left out:
-//these are passed as the 'nomonsters' parameter to traceline/tracebox (yes really this was supported in all quake engines, nomonsters is misnamed)
-float MOVE_NORMAL = 0; // same as FALSE
-float MOVE_NOMONSTERS = 1; // same as TRUE
-float MOVE_MISSILE = 2; // save as movement with .movetype == MOVETYPE_FLYMISSILE
-
-//checkextension function
-//idea: expected by almost everyone
-//darkplaces implementation: LordHavoc
-float(string s) checkextension = #99;
-//description:
-//check if (cvar("pr_checkextension")) before calling this, this is the only
-//guaranteed extension to be present in the extension system, it allows you
-//to check if an extension is available, by name, to check for an extension
-//use code like this:
-//// (it is recommended this code be placed in worldspawn or a worldspawn called function somewhere)
-//if (cvar("pr_checkextension"))
-//if (checkextension("DP_SV_SETCOLOR"))
-//     ext_setcolor = TRUE;
-//from then on you can check ext_setcolor to know if that extension is available
-
-//BX_WAL_SUPPORT
-//idea: id Software
-//darkplaces implementation: LordHavoc
-//description:
-//indicates the engine supports .wal textures for filenames in the textures/ directory
-//(note: DarkPlaces has supported this since 2001 or 2002, but did not advertise it as an extension, then I noticed Betwix was advertising it and added the extension accordingly)
-
-//DP_BUTTONCHAT
-//idea: Vermeulen
-//darkplaces implementation: LordHavoc
-//field definitions:
-.float buttonchat;
-//description:
-//true if the player is currently chatting (in messagemode, menus or console)
-
-//DP_BUTTONUSE
-//idea: id Software
-//darkplaces implementation: LordHavoc
-//field definitions:
-.float buttonuse;
-//client console commands:
-//+use
-//-use
-//description:
-//made +use and -use commands work, they now control the .buttonuse field (.button1 was used by many mods for other purposes).
-
-//DP_CL_LOADSKY
-//idea: Nehahra, LordHavoc
-//darkplaces implementation: LordHavoc
-//client console commands:
+       //DarkPlaces supported extension list, draft version 1.04
+
+       //things that don't have extensions yet:
+       .float disableclientprediction;
+
+       //definitions that id Software left out:
+       //these are passed as the 'nomonsters' parameter to traceline/tracebox (yes really this was supported in all quake engines, nomonsters is misnamed)
+       float MOVE_NORMAL = 0; // same as FALSE
+       float MOVE_NOMONSTERS = 1; // same as TRUE
+       float MOVE_MISSILE = 2; // save as movement with .movetype == MOVETYPE_FLYMISSILE
+
+       //checkextension function
+       //idea: expected by almost everyone
+       //darkplaces implementation: LordHavoc
+       float(string s) checkextension = #99;
+       //description:
+       //check if (cvar("pr_checkextension")) before calling this, this is the only
+       //guaranteed extension to be present in the extension system, it allows you
+       //to check if an extension is available, by name, to check for an extension
+       //use code like this:
+       //// (it is recommended this code be placed in worldspawn or a worldspawn called function somewhere)
+       //if (cvar("pr_checkextension"))
+       //if (checkextension("DP_SV_SETCOLOR"))
+       //      ext_setcolor = TRUE;
+       //from then on you can check ext_setcolor to know if that extension is available
+
+       //BX_WAL_SUPPORT
+       //idea: id Software
+       //darkplaces implementation: LordHavoc
+       //description:
+       //indicates the engine supports .wal textures for filenames in the textures/ directory
+       //(note: DarkPlaces has supported this since 2001 or 2002, but did not advertise it as an extension, then I noticed Betwix was advertising it and added the extension accordingly)
+
+       //DP_BUTTONCHAT
+       //idea: Vermeulen
+       //darkplaces implementation: LordHavoc
+       //field definitions:
+       .float buttonchat;
+       //description:
+       //true if the player is currently chatting (in messagemode, menus or console)
+
+       //DP_BUTTONUSE
+       //idea: id Software
+       //darkplaces implementation: LordHavoc
+       //field definitions:
+       .float buttonuse;
+       //client console commands:
+       //+use
+       //-use
+       //description:
+       //made +use and -use commands work, they now control the .buttonuse field (.button1 was used by many mods for other purposes).
+
+       //DP_CL_LOADSKY
+       //idea: Nehahra, LordHavoc
+       //darkplaces implementation: LordHavoc
+       //client console commands:
 //"loadsky" (parameters: "basename", example: "mtnsun_" would load "mtnsun_up.tga" and "mtnsun_rt.tga" and similar names, use "" to revert to quake sky, note: this is the same as Quake2 skybox naming)
 //description:
 //sets global skybox for the map for this client (can be stuffed to a client by QC), does not hurt much to repeatedly execute this command, please don't use this in mods if it can be avoided (only if changing skybox is REALLY needed, otherwise please use DP_GFX_SKYBOX).
@@ -2309,3 +2309,15 @@ float JOINTTYPE_HINGE2 = 5; // hinge2; uses origin (anchor), angles (axis1), vel
 //description:
 //various physics properties can be defined in an entity and are executed via
 //ODE
+
+//DP_CRYPTO
+//idea: divVerent
+//darkplaces implementation: divVerent
+//field definitions: (SVQC)
+.string crypto_keyfp; // fingerprint of CA key the player used to authenticate, or string_null if not verified
+.string crypto_mykeyfp; // fingerprint of CA key the server used to authenticate to the player, or string_null if not verified
+.string crypto_idfp; // fingerprint of ID used by the player entity, or string_null if not identified
+.string crypto_encryptmethod; // the string "AES128" if encrypting, and string_null if plaintext
+.string crypto_signmethod; // the string "HMAC-SHA256" if signing, and string_null if plaintext
+// there is no field crypto_myidfp, as that info contains no additional information the QC may have a use for
+//description:
index ebc58cea7e2847982efb41ace84d6089f001ca1c..9dd3cb51ad08ad1ba7c79e4aaaab79afed593339 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,8 +336,13 @@ float Ban_GetClientIP(entity client)
        float i1, i2, i3, i4;
        string s;
 
+       if(client.crypto_keyfp)
+               ban_idfp = client.crypto_idfp;
+       else
+               ban_idfp = string_null;
+
        s = client.netaddress;
-       
+
        i1 = strstrofs(s, ".", 0);
        if(i1 < 0)
                return FALSE;
@@ -349,21 +355,18 @@ float Ban_GetClientIP(entity client)
        i4 = strstrofs(s, ".", i3 + 1);
        if(i4 >= 0)
                return FALSE;
-       
+
        ban_ip1 = substring(s, 0, i1);
        ban_ip2 = substring(s, 0, i2);
        ban_ip3 = substring(s, 0, i3);
        ban_ip4 = strcat1(s);
-#ifdef UID
-       ban_uid = client.uid;
-#endif
 
        return TRUE;
 }
 
 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))
@@ -378,20 +381,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;
 }
 
@@ -535,12 +540,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
index 4dff570d317798035ea13f029c507ba6eb9f25ee..1c79c575f903818e5ed78d95cf379d9c4d6c4ea9 100644 (file)
@@ -101,9 +101,7 @@ void race_InitSpectator()
 string rr;
 float grecordtime[RANKINGS_CNT];
 string grecordholder[RANKINGS_CNT];
-#ifdef UID
 string grecorduid[RANKINGS_CNT];
-#endif
 float worst_time; // last ranked time
 float have_recs; // have we already read the records from the database before?
 float race_GetTime(float pos) {
@@ -117,15 +115,11 @@ float race_GetTime(float pos) {
                for(i=0;i<RANKINGS_CNT;++i) {
                        grecordtime[i] = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(i))));
                        grecordholder[i] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(i))));
-#ifdef UID
-                       grecorduid[i] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(i))));
-#endif
+                       grecorduid[i] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(i))));
                }
                grecordtime[0] = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, "time")));
                grecordholder[0] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "netname")));
-#ifdef UID
-               grecorduid[0] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "uid")));
-#endif
+               grecorduid[0] = strzone(db_get(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp")));
                worst_time = stof(db_get(ServerProgsDB, strcat(GetMapname(), rr, strcat("time", ftos(RANKINGS_CNT-1)))));
                have_recs = 1;
        }
@@ -137,12 +131,14 @@ string race_GetName(float pos) { // these other functions assume that race_GetTi
        return grecordholder[pos-1];
 }
 
-#ifdef UID
 float race_CheckUID(string myuid, string net_name) { // return existing UID or player name ranking pos, else 0
        float i;
-       for (i=RANKINGS_CNT-1;i>=0;--i)
-               if(grecorduid[i] == myuid)
-                       return i+1;
+       if(myuid)
+       {
+               for (i=RANKINGS_CNT-1;i>=0;--i)
+                       if(grecorduid[i] == myuid)
+                               return i+1;
+       }
        for (i=RANKINGS_CNT-1;i>=0;--i)
                if(grecordholder[i] == net_name)
                        return i+1;
@@ -224,11 +220,7 @@ string race_PlaceName(float pos) {
 void race_SetTime(entity e, float t, float match_rec) {
        float pos, prevpos;
        pos = race_GetPos(t);
-#ifdef UID
-       prevpos = race_CheckUID(e.uid, e.netname);
-#else
-       prevpos = race_CheckName(e.netname);
-#endif
+       prevpos = race_CheckUID(e.crypto_idfp, e.netname);
 
        float oldrec;
        string recorddifference;
@@ -254,37 +246,29 @@ void race_SetTime(entity e, float t, float match_rec) {
                for (i=prevpos-1;i>pos-1;--i) {
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(i)), ftos(grecordtime[i-1]));
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(i)), grecordholder[i-1]);
-#ifdef UID
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(i)), grecorduid[i-1]);
-#endif
+                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(i)), grecorduid[i-1]);
                        grecordtime[i] = grecordtime[i-1];
 
                        if (grecordholder[i])
                                strunzone(grecordholder[i]);
                        grecordholder[i] = strzone(grecordholder[i-1]);
-#ifdef UID
                        if (grecorduid[i])
                                strunzone(grecorduid[i]);
                        grecorduid[i] = strzone(grecorduid[i-1]);
-#endif
                }
        } else { // player has no ranked record yet
                for (i=RANKINGS_CNT-1;i>pos-1;--i) {
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(i)), ftos(grecordtime[i-1]));
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(i)), grecordholder[i-1]);
-#ifdef UID
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(i)), grecorduid[i-1]);
-#endif
+                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(i)), grecorduid[i-1]);
                        grecordtime[i] = grecordtime[i-1];
 
                        if (grecordholder[i])
                                strunzone(grecordholder[i]);
                        grecordholder[i] = strzone(grecordholder[i-1]);
-#ifdef UID
                        if (grecorduid[i])
                                strunzone(grecorduid[i]);
                        grecorduid[i] = strzone(grecorduid[i-1]);
-#endif
                }
        }
        
@@ -292,39 +276,31 @@ void race_SetTime(entity e, float t, float match_rec) {
        if (pos == 1) {
                db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(t));
                db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), e.netname);
-#ifdef UID
-               db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid"), e.uid);
-#endif
+               db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp"), e.crypto_idfp);
 
                grecordtime[0] = t;
 
                if (grecordholder[0])
                        strunzone(grecordholder[0]);
                grecordholder[0] = strzone(e.netname);
-#ifdef UID
                if (grecorduid[0])
                        strunzone(grecorduid[0]);
-               grecorduid[0] = strzone(e.uid);
-#endif
+               grecorduid[0] = strzone(e.crypto_idfp);
                write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));
                race_send_recordtime(MSG_ALL);
        } else {
                db_put(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(pos-1)), ftos(t));
                db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(pos-1)), e.netname);
-#ifdef UID
-               db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(pos-1)), e.uid);
-#endif
+               db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(pos-1)), e.crypto_idfp);
 
                grecordtime[pos-1] = t;
 
                if (grecordholder[pos-1])
                        strunzone(grecordholder[pos-1]);
                grecordholder[pos-1] = strzone(e.netname);
-#ifdef UID
                if (grecorduid[pos-1])
                        strunzone(grecorduid[pos-1]);
-               grecorduid[pos-1] = strzone(e.uid);
-#endif
+               grecorduid[pos-1] = strzone(e.crypto_idfp);
        }
 
        if (pos == RANKINGS_CNT)
@@ -368,53 +344,41 @@ void race_DeleteTime(float pos) {
                if (i == 0) {
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "time"), ftos(grecordtime[1]));
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname"), grecordholder[1]);
-#ifdef UID
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid"), grecorduid[1]);
-#endif
+                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp"), grecorduid[1]);
                        grecordtime[0] = grecordtime[1];
                        if (grecordholder[i])
                                strunzone(grecordholder[0]);
                        grecordholder[0] = strzone(grecordholder[1]);
 
-#ifdef UID
                        if (grecorduid[i])
                                strunzone(grecorduid[0]);
                        grecorduid[0] = strzone(grecorduid[1]);
-#endif
                }
                else if (i == RANKINGS_CNT-1) {
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(i)), string_null);
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(i)), string_null);
-#ifdef UID
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(i)), string_null);
-#endif
+                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(i)), string_null);
                        grecordtime[i] = 0;
                        if (grecordholder[i])
                                strunzone(grecordholder[i]);
                        grecordholder[i] = string_null;
 
-#ifdef UID
                        if (grecorduid[i])
                                strunzone(grecorduid[i]);
                        grecorduid[i] = string_null;
-#endif
                }
                else {
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "time", ftos(i)), ftos(grecordtime[i+1]));
                        db_put(ServerProgsDB, strcat(GetMapname(), rr, "netname", ftos(i)), grecordholder[i+1]);
-#ifdef UID
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "uid", ftos(i)), grecorduid[i+1]);
-#endif
+                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "crypto_idfp", ftos(i)), grecorduid[i+1]);
                        grecordtime[i] = grecordtime[i+1];
                        if (grecordholder[i])
                                strunzone(grecordholder[i]);
                        grecordholder[i] = strzone(grecordholder[i+1]);
 
-#ifdef UID
                        if (grecorduid[i])
                                strunzone(grecorduid[i]);
                        grecorduid[i] = strzone(grecorduid[i+1]);
-#endif
                }
        }
 
index b595010c73ab57ffbff743b66feadbb054507346..bb2ab366a176cf954a01f5cd36c7ac67dde720a8 100644 (file)
--- a/quake.rc
+++ b/quake.rc
@@ -9,3 +9,4 @@ stuffcmds
 //play announcer/male/welcome.ogg
 
 exec font-nimbussansl.cfg
+crypto_keygen 0 http://rm.endoftheinternet.org/~xonotic/keygen/?ca=0&key=