X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd.cpp;h=d69aa6a1e1e332818a396e9e3a7acb7a45a29f9e;hb=3d7312f8af1becdbe458392e14ea64c904ee7b92;hp=c0cebd522f86cabc7a4b95575c50e8bccd8ddbb3;hpb=034c2c65df4fad4efe08f2a3f332b5772d59c607;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c0cebd522..d69aa6a1e 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -89,6 +89,8 @@ extern int MaxWhoResults; time_t nb_start = 0; int dns_timeout = 5; +char DisabledCommands[MAXBUF]; + bool AllowHalfop = true; bool AllowProtect = true; bool AllowFounder = true; @@ -191,6 +193,7 @@ char MyExecutable[1024]; int boundPortCount = 0; int portCount = 0, UDPportCount = 0, ports[MAXSOCKS]; int defaultRoute = 0; +char ModPath[MAXBUF]; connection C; @@ -317,7 +320,7 @@ void readfile(file_cache &F, const char* fname) void ReadConfig(bool bail, userrec* user) { char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF]; - char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF]; + char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF],DNT[MAXBUF],pfreq[MAXBUF]; ConnectClass c; std::stringstream errstr; @@ -375,6 +378,9 @@ void ReadConfig(bool bail, userrec* user) ConfValue("options","allowfounder",0,AF,&config_f); ConfValue("dns","server",0,DNSServer,&config_f); ConfValue("dns","timeout",0,DNT,&config_f); + ConfValue("options","moduledir",0,ModPath,&config_f); + ConfValue("disabled","commands",0,DisabledCommands,&config_f); + NetBufferSize = atoi(NB); MaxWhoResults = atoi(MW); dns_timeout = atoi(DNT); @@ -382,6 +388,8 @@ void ReadConfig(bool bail, userrec* user) dns_timeout = 5; if (!strcmp(DNSServer,"")) strlcpy(DNSServer,"127.0.0.1",MAXBUF); + if (!strcmp(ModPath,"")) + strlcpy(ModPath,MOD_PATH,MAXBUF); AllowHalfop = ((!strcasecmp(AH,"true")) || (!strcasecmp(AH,"1")) || (!strcasecmp(AH,"yes"))); AllowProtect = ((!strcasecmp(AP,"true")) || (!strcasecmp(AP,"1")) || (!strcasecmp(AP,"yes"))); AllowFounder = ((!strcasecmp(AF,"true")) || (!strcasecmp(AF,"1")) || (!strcasecmp(AF,"yes"))); @@ -416,6 +424,7 @@ void ReadConfig(bool bail, userrec* user) ConfValue("connect","allow",i,Value,&config_f); ConfValue("connect","timeout",i,timeout,&config_f); ConfValue("connect","flood",i,flood,&config_f); + ConfValue("connect","pingfreq",i,pfreq,&config_f); if (strcmp(Value,"")) { strlcpy(c.host,Value,MAXBUF); @@ -424,11 +433,16 @@ void ReadConfig(bool bail, userrec* user) ConfValue("connect","password",i,Value,&config_f); strlcpy(c.pass,Value,MAXBUF); c.registration_timeout = 90; // default is 2 minutes + c.pingtime = 120; c.flood = atoi(flood); if (atoi(timeout)>0) { c.registration_timeout = atoi(timeout); } + if (atoi(pfreq)>0) + { + c.pingtime = atoi(pfreq); + } Classes.push_back(c); log(DEBUG,"Read connect class type ALLOW, host=%s password=%s timeout=%d flood=%d",c.host,c.pass,c.registration_timeout,c.flood); } @@ -901,6 +915,10 @@ void NetSendToCommon(userrec* u, char* s) log(DEBUG,"NetSendToCommon: '%s' '%s'",u->nick,s); + std::string msg = buffer; + FOREACH_MOD OnPacketTransmit(msg,s); + strlcpy(buffer,msg.c_str(),MAXBUF); + for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -924,6 +942,10 @@ void NetSendToAll(char* s) log(DEBUG,"NetSendToAll: '%s'",s); + std::string msg = buffer; + FOREACH_MOD OnPacketTransmit(msg,s); + strlcpy(buffer,msg.c_str(),MAXBUF); + for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -943,6 +965,10 @@ void NetSendToAllAlive(char* s) log(DEBUG,"NetSendToAllAlive: '%s'",s); + std::string msg = buffer; + FOREACH_MOD OnPacketTransmit(msg,s); + strlcpy(buffer,msg.c_str(),MAXBUF); + for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -970,6 +996,10 @@ void NetSendToOne(char* target,char* s) log(DEBUG,"NetSendToOne: '%s' '%s'",target,s); + std::string msg = buffer; + FOREACH_MOD OnPacketTransmit(msg,s); + strlcpy(buffer,msg.c_str(),MAXBUF); + for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -992,6 +1022,10 @@ void NetSendToAllExcept(const char* target,char* s) log(DEBUG,"NetSendToAllExcept: '%s' '%s'",target,s); + std::string msg = buffer; + FOREACH_MOD OnPacketTransmit(msg,s); + strlcpy(buffer,msg.c_str(),MAXBUF); + for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -2283,7 +2317,6 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) strncpy(clientlist[tempnick]->ident, "unknown",9); clientlist[tempnick]->registered = 0; clientlist[tempnick]->signon = TIME+dns_timeout; - clientlist[tempnick]->nping = TIME+240+dns_timeout; clientlist[tempnick]->lastping = 1; clientlist[tempnick]->port = port; strncpy(clientlist[tempnick]->ip,ip,32); @@ -2298,10 +2331,12 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) { class_regtimeout = (unsigned long)i->registration_timeout; class_flood = i->flood; + clientlist[tempnick]->pingmax = i->pingtime; break; } } + clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax+dns_timeout; clientlist[tempnick]->timeout = TIME+class_regtimeout; clientlist[tempnick]->flood = class_flood; @@ -2918,7 +2953,7 @@ void process_command(userrec *user, char* cmd) log(DEBUG,"Processing command"); /* activity resets the ping pending timer */ - user->nping = TIME + 120; + user->nping = TIME + user->pingmax; if ((items) < cmdlist[i].min_params) { log(DEBUG,"process_command: not enough parameters: %s %s",user->nick,command); @@ -2949,6 +2984,24 @@ void process_command(userrec *user, char* cmd) WriteServ(user->fd,"451 %s :You have not registered",command); return; } + } + if ((user->registered == 7) && (!strchr(user->modes,'o'))) + { + char* mycmd; + char* savept2; + mycmd = strtok_r(DisabledCommands," ",&savept2); + while (mycmd) + { + if (!strcasecmp(mycmd,command)) + { + // command is disabled! + WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command); + return; + } + mycmd = strtok_r(NULL," ",&savept2); + } + + } if ((user->registered == 7) || (!strcmp(command,"USER")) || (!strcmp(command,"NICK")) || (!strcmp(command,"PASS"))) { @@ -3047,7 +3100,7 @@ void SetupCommandTable(void) createcommand("WALLOPS",handle_wallops,'o',1,""); createcommand("NOTICE",handle_notice,0,2,""); createcommand("JOIN",handle_join,0,1,""); - createcommand("NAMES",handle_names,0,1,""); + createcommand("NAMES",handle_names,0,0,""); createcommand("PART",handle_part,0,1,""); createcommand("KICK",handle_kick,0,2,""); createcommand("MODE",handle_mode,0,1,""); @@ -3445,7 +3498,7 @@ bool DirValid(char* dirandfile) bool LoadModule(const char* filename) { char modfile[MAXBUF]; - snprintf(modfile,MAXBUF,"%s/%s",MOD_PATH,filename); + snprintf(modfile,MAXBUF,"%s/%s",ModPath,filename); if (!DirValid(modfile)) { log(DEFAULT,"Module %s is not within the modules directory.",modfile); @@ -3773,8 +3826,9 @@ int InspIRCd(void) else NetSendToAllExcept(tcp_host,udp_msg); } - FOREACH_MOD OnPacketReceive(udp_msg); - handle_link_packet(udp_msg, tcp_host, me[x]); + std::string msg = udp_msg; + FOREACH_MOD OnPacketReceive(msg,tcp_host); + strlcpy(udp_msg,msg.c_str(),MAXBUF); } goto label; } @@ -3838,7 +3892,7 @@ int InspIRCd(void) Write(count2->second->fd,"PING :%s",ServerName); log(DEBUG,"InspIRCd: pinging: %s",count2->second->nick); count2->second->lastping = 0; - count2->second->nping = TIME+120; + count2->second->nping = TIME+count2->second->pingmax; // was hard coded to 120 } } count2++;