diff --git a/source/src/protos.h b/source/src/protos.h index 4d749fd2..8b5b0bf0 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -800,7 +800,7 @@ struct serverconfigfile struct servercommandline { - int uprate, serverport, syslogfacility, filethres, syslogthres, maxdemos, maxclients, kickthreshold, banthreshold, verbose, incoming_limit, afk_limit; + int uprate, serverport, syslogfacility, filethres, syslogthres, maxdemos, maxclients, kickthreshold, banthreshold, verbose, incoming_limit, afk_limit, ban_time; const char *ip, *master, *logident, *serverpassword, *adminpasswd, *demopath, *maprot, *pwdfile, *blfile, *nbfile, *infopath, *motdpath, *forbidden; bool logtimestamp; string motd, servdesc_full, servdesc_pre, servdesc_suf, voteperm, mapperm; @@ -808,7 +808,7 @@ struct servercommandline vector adminonlymaps; servercommandline() : uprate(0), serverport(CUBE_DEFAULT_SERVER_PORT), syslogfacility(6), filethres(-1), syslogthres(-1), maxdemos(5), - maxclients(DEFAULTCLIENTS), kickthreshold(-5), banthreshold(-6), verbose(0), incoming_limit(10), afk_limit(45000), + maxclients(DEFAULTCLIENTS), kickthreshold(-5), banthreshold(-6), verbose(0), incoming_limit(10), afk_limit(45000), ban_time(20*60*1000), ip(""), master(NULL), logident(""), serverpassword(""), adminpasswd(""), demopath(""), maprot("config/maprot.cfg"), pwdfile("config/serverpwd.cfg"), blfile("config/serverblacklist.cfg"), nbfile("config/nicknameblacklist.cfg"), infopath("config/serverinfo"), motdpath("config/motd"), forbidden("config/forbidden.cfg"), @@ -849,6 +849,11 @@ struct servercommandline if ((ai = atoi(&arg[3])) >= 30) afk_limit = ai * 1000; else afk_limit = 0; } + else if(arg[2]=='B' && arg[3]!='\0') + { + if ((ai = atoi(&arg[3])) >= 0) ban_time = ai * 60 * 1000; + else ban_time = 0; + } else if(ai < 0) kickthreshold = ai; break; } diff --git a/source/src/server.cpp b/source/src/server.cpp index 3cc07e5c..c17b0c87 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1901,12 +1901,12 @@ void sendserveropinfo(int receiver) struct voteinfo { - bool boot; + int boot; int owner, callmillis, result, num, type; char text[MAXTRANS]; serveraction *action; - voteinfo() : boot(false), owner(0), callmillis(0), result(VOTE_NEUTRAL), action(NULL) {} + voteinfo() : boot(0), owner(0), callmillis(0), result(VOTE_NEUTRAL), action(NULL) {} ~voteinfo() { delete action; } void end(int result) @@ -2010,7 +2010,9 @@ bool scallvote(voteinfo *v, ENetPacket *msg) // true if a regular vote was calle else if( v->type == SA_MAP && v->num >= GMODE_NUM && map_queued ) error = VOTEE_NEXT; else if( c->role == CR_DEFAULT && v->action->isdisabled() ) error = VOTEE_DISABLED; else if( (c->lastvotecall && servmillis - c->lastvotecall < 60*1000 && c->role != CR_ADMIN && numclients()>1) || c->nvotes > 3 ) error = VOTEE_MAX; - else if( v->boot && c->role < roleconf('W') && !is_lagging(b) && !b->mute && b->spamcount < 2 ) { + else if( ( ( v->boot == 1 && c->role < roleconf('w') ) || ( v->boot == 2 && c->role < roleconf('X') ) ) + && !is_lagging(b) && !b->mute && b->spamcount < 2 ) + { /** not same team, with low ratio, not lagging, and not spamming... so, why to kick? */ if ( !isteam(c->team, b->team) && b->state.frags < ( b->state.deaths > 0 ? b->state.deaths : 1 ) * 3 ) error = VOTEE_WEAK; /** same team, with low tk, not lagging, and not spamming... so, why to kick? */ @@ -2409,7 +2411,7 @@ void process(ENetPacket *packet, int sender, int chan) logline(ACLOG_INFO, "[%s] '%s' matches nickname blacklist line %d%s", cl->hostname, cl->name, bl, tags); disconnect_client(sender, DISC_BADNICK); } - else if(passwords.check(cl->name, text, cl->salt, &pd) && (!pd.denyadmin || (banned && !srvfull && !srvprivate))) // pass admins always through + else if(passwords.check(cl->name, cl->pwd, cl->salt, &pd, cl->peer->address.host) && (!pd.denyadmin || (banned && !srvfull && !srvprivate))) // pass admins always through { // admin (or deban) password match cl->isauthed = true; if(!pd.denyadmin && wantrole == CR_ADMIN) clientrole = CR_ADMIN; @@ -3051,7 +3053,7 @@ void process(ENetPacket *packet, int sender, int chan) case SV_CALLVOTE: { voteinfo *vi = new voteinfo; - vi->boot = false; + vi->boot = 0; vi->type = getint(p); switch(vi->type) { @@ -3074,7 +3076,7 @@ void process(ENetPacket *packet, int sender, int chan) strncpy(vi->text,text,MAXTRANS-1); filtertext(text, text); vi->action = new kickaction(cn2boot, newstring(text)); - vi->boot = true; + vi->boot = 1; break; } case SA_BAN: @@ -3084,7 +3086,7 @@ void process(ENetPacket *packet, int sender, int chan) strncpy(vi->text,text,MAXTRANS-1); filtertext(text, text); vi->action = new banaction(cn2boot, newstring(text)); - vi->boot = true; + vi->boot = 2; break; } case SA_REMBANS: diff --git a/source/src/serveractions.h b/source/src/serveractions.h index ef5941f3..7e06948c 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -3,7 +3,7 @@ enum { EE_LOCAL_SERV = 1, EE_DED_SERV = 1<<1 }; // execution environment int roleconf(int key) -{ // current defaults: "fGkBMasRCDEW" +{ // current defaults: "fGkBMasRCDEwX" if(strchr(scl.voteperm, tolower(key))) return CR_DEFAULT; if(strchr(scl.voteperm, toupper(key))) return CR_ADMIN; return (key) == tolower(key) ? CR_DEFAULT : CR_ADMIN; diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index 3324573c..7be8cd71 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -629,6 +629,9 @@ struct pwddetail bool denyadmin; // true: connect only }; +int passtime = 0, passtries = 0; +enet_uint32 passguy = 0; + struct serverpasswords : serverconfigfile { vector adminpwds; @@ -688,9 +691,21 @@ struct serverpasswords : serverconfigfile logline(ACLOG_INFO,"read %d admin passwords from '%s'", adminpwds.length() - staticpasses, filename); } - bool check(const char *name, const char *pwd, int salt, pwddetail *detail = NULL) + bool check(const char *name, const char *pwd, int salt, pwddetail *detail = NULL, enet_uint32 address = 0) { bool found = false; + if (address && passguy == address) + { + if (passtime + 1000 > servmillis || ( passtries > 10 && passtime + 10000 > servmillis )) + { + passtime = servmillis; + return false; + } + passtries++; + } + passtries = 0; + passtime = servmillis; + passguy = address; loopv(adminpwds) { if(!strcmp(genpwdhash(name, adminpwds[i].pwd, salt), pwd))