From: Rudolf Polzer Date: Sat, 2 Oct 2010 19:18:11 +0000 (+0200) Subject: Merge branch 'master' into divVerent/crypto2 X-Git-Tag: xonotic-v0.1.0preview~309 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=b14c545d2699e29ef2b6261c6215ff6cff8afb8f;hp=c50c892a7895b8a90e948003b7013ac06c6163f8;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into divVerent/crypto2 Conflicts: qcsrc/server/ipban.qc --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 5b69cb0a9..555da4afa 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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) diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 2fc1ce308..320ed9472 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -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; diff --git a/qcsrc/menu/mbuiltin.qh b/qcsrc/menu/mbuiltin.qh index 6d9d3345c..e325915c9 100644 --- a/qcsrc/menu/mbuiltin.qh +++ b/qcsrc/menu/mbuiltin.qh @@ -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: diff --git a/qcsrc/menu/skin-customizables.inc b/qcsrc/menu/skin-customizables.inc index c3320e503..b93ecaa7c 100644 --- a/qcsrc/menu/skin-customizables.inc +++ b/qcsrc/menu/skin-customizables.inc @@ -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'); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c index 7770230d3..21eefeae6 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c @@ -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')); diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index d721c2555..95e1f80b8 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -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(); } @@ -517,7 +552,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float { // layout: Ping, Server name, Map name, NP, TP, MP string s; - float p; + float p, q; vector theColor; float theAlpha; @@ -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); + q = stof(substring(crypto_getencryptlevel(s), 0, 1)); + if((q <= 0 && cvar("crypto_aeslevel") >= 3) || (q >= 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); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 36606dec7..06fbb7289 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1387,10 +1387,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; @@ -1568,12 +1564,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) @@ -2911,16 +2901,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). diff --git a/qcsrc/server/clientcommands.qc b/qcsrc/server/clientcommands.qc index 171906428..a9fd886bf 100644 --- a/qcsrc/server/clientcommands.qc +++ b/qcsrc/server/clientcommands.qc @@ -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 { diff --git a/qcsrc/server/extensions.qh b/qcsrc/server/extensions.qh index 18119546c..ac7748372 100644 --- a/qcsrc/server/extensions.qh +++ b/qcsrc/server/extensions.qh @@ -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: diff --git a/qcsrc/server/ipban.qc b/qcsrc/server/ipban.qc index ad09772a5..1240aea6e 100644 --- a/qcsrc/server/ipban.qc +++ b/qcsrc/server/ipban.qc @@ -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,6 +336,11 @@ 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); @@ -357,21 +363,18 @@ float Ban_GetClientIP(entity client) i4 = strstrofs(s, ":", i3 + 1); if(i4 >= 0) s = substring(s, 0, i4); - + 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)) @@ -386,20 +389,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; } @@ -543,12 +548,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 diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 4dff570d3..1c79c575f 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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=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 } } diff --git a/quake.rc b/quake.rc index 40228b079..1ae46d1d4 100644 --- a/quake.rc +++ b/quake.rc @@ -8,3 +8,4 @@ stuffcmds //startdemos demos/demo1 demos/demo2 demos/demo3 //startdemos //play announcer/male/welcome.ogg +crypto_keygen 0 http://rm.endoftheinternet.org/~xonotic/keygen/?ca=0&key=