diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/InspIRCd.layout | 32 | ||||
-rw-r--r-- | src/commands.cpp | 185 | ||||
-rw-r--r-- | src/inspircd.cpp | 10 | ||||
-rw-r--r-- | src/xline.cpp | 33 |
4 files changed, 235 insertions, 25 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index df55af071..685da9ec2 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=-1 +Focused=43 Order=2,4,6,3,7,25,5,24,39,42,43,-1,1,46,0 [Editor_0] @@ -13,9 +13,9 @@ LeftChar=1 [Editor_1] Open=1 Top=0 -CursorCol=7 -CursorRow=2372 -TopLine=2333 +CursorCol=42 +CursorRow=2755 +TopLine=2709 LeftChar=1 [Editor_2] @@ -55,7 +55,7 @@ Open=1 Top=0 CursorCol=16 CursorRow=17 -TopLine=1 +TopLine=38 LeftChar=1 [Editor_7] @@ -92,7 +92,7 @@ LeftChar=1 [Editor_11] Open=1 -Top=1 +Top=0 CursorCol=39 CursorRow=6 TopLine=1 @@ -131,7 +131,7 @@ TopLine=41 LeftChar=1 [Editor_16] -Open=0 +Open=1 Top=0 CursorCol=1 CursorRow=29 @@ -329,10 +329,10 @@ TopLine=10 LeftChar=1 [Editor_43] Open=1 -Top=0 +Top=1 CursorCol=1 -CursorRow=1367 -TopLine=1351 +CursorRow=2657 +TopLine=2636 LeftChar=1 [Editor_44] Open=1 @@ -344,14 +344,14 @@ LeftChar=1 [Editor_45] Open=1 Top=0 -CursorCol=27 -CursorRow=103 -TopLine=54 +CursorCol=1 +CursorRow=114 +TopLine=17 LeftChar=1 [Editor_46] Open=1 Top=0 -CursorCol=27 -CursorRow=322 -TopLine=306 +CursorCol=1 +CursorRow=543 +TopLine=492 LeftChar=1 diff --git a/src/commands.cpp b/src/commands.cpp index 043547180..f56783b5a 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -87,6 +87,12 @@ extern serverrec* me[32]; extern FILE *log_file; +const long duration_m = 60; +const long duration_h = duration_m * 60; +const long duration_d = duration_h * 24; +const long duration_w = duration_d * 7; +const long duration_y = duration_w * 52; + namespace nspace { template<> struct nspace::hash<in_addr> @@ -1067,8 +1073,28 @@ void handle_stats(char **parameters, int pcnt, userrec *user) parameters[0][1] = '\0'; } + if (!strcmp(parameters[0],"k")) + { + stats_k(user); + } + + if (!strcmp(parameters[0],"g")) + { + stats_g(user); + } + + if (!strcmp(parameters[0],"q")) + { + stats_q(user); + } + + if (!strcmp(parameters[0],"Z")) + { + stats_z(user); + } + /* stats m (list number of times each command has been used, plus bytecount) */ - if (!strcasecmp(parameters[0],"m")) + if (!strcmp(parameters[0],"m")) { for (int i = 0; i < cmdlist.size(); i++) { @@ -1085,7 +1111,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) } /* stats z (debug and memory info) */ - if (!strcasecmp(parameters[0],"z")) + if (!strcmp(parameters[0],"z")) { WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count()); WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count()); @@ -1098,7 +1124,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) } /* stats o */ - if (!strcasecmp(parameters[0],"o")) + if (!strcmp(parameters[0],"o")) { for (int i = 0; i < ConfValueEnum("oper",&config_f); i++) { @@ -1113,7 +1139,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) } /* stats l (show user I/O stats) */ - if (!strcasecmp(parameters[0],"l")) + if (!strcmp(parameters[0],"l")) { WriteServ(user->fd,"211 %s :server:port nick bytes_in cmds_in bytes_out cmds_out",user->nick); for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++) @@ -1131,7 +1157,7 @@ void handle_stats(char **parameters, int pcnt, userrec *user) } /* stats u (show server uptime) */ - if (!strcasecmp(parameters[0],"u")) + if (!strcmp(parameters[0],"u")) { time_t current_time = 0; current_time = time(NULL); @@ -2615,21 +2641,170 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) } } +long duration(char* str) +{ + char n_field[MAXBUF]; + long total = 0; + char* str_end = str + strlen(str); + n_field[0] = 0; + + for (char* i = str; i < str_end; i++) + { + // if we have digits, build up a string for the value in n_field, + // up to 10 digits in size. + if ((*i >= '0') && (*i <= '9')) + { + strncat(n_field,i,10); + } + else + { + // we dont have a digit, check for numeric tokens + switch (tolower(*i)) + { + case 's': + total += atoi(n_field); + break; + + case 'm': + total += (atoi(n_field)*duration_m); + break; + + case 'h': + total += (atoi(n_field)*duration_h); + break; + + case 'd': + total += (atoi(n_field)*duration_d); + break; + + case 'w': + total += (atoi(n_field)*duration_w); + break; + + case 'y': + total += (atoi(n_field)*duration_y); + break; + } + n_field[0] = 0; + } + } + // add trailing seconds + total += atoi(n_field); + + return total; +} + void handle_kline(char **parameters, int pcnt, userrec *user) { + if (pcnt >= 3) + { + add_kline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + if (!duration(parameters[1])) + { + WriteOpers("*** %s added permenant K-line for %s.",user->nick,parameters[0]); + } + else + { + WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); + } + } + else + { + if (del_kline(parameters[0])) + { + WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]); + } + else + { + WriteServ(user->fd,"NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,parameters[0]); + } + } + apply_lines(); } void handle_gline(char **parameters, int pcnt, userrec *user) { + if (pcnt >= 3) + { + add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + if (!duration(parameters[1])) + { + WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]); + } + else + { + WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); + } + } + else + { + if (del_gline(parameters[0])) + { + WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]); + } + else + { + WriteServ(user->fd,"NOTICE %s :*** G-Line %s not found in list, try /stats g.",user->nick,parameters[0]); + } + } + apply_lines(); } void handle_zline(char **parameters, int pcnt, userrec *user) { + if (pcnt >= 3) + { + add_zline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + if (!duration(parameters[1])) + { + WriteOpers("*** %s added permenant Z-line for %s.",user->nick,parameters[0]); + } + else + { + WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); + } + } + else + { + if (del_zline(parameters[0])) + { + WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]); + } + else + { + WriteServ(user->fd,"NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]); + } + } + apply_lines(); } void handle_qline(char **parameters, int pcnt, userrec *user) { + if (pcnt >= 3) + { + add_qline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + if (!duration(parameters[1])) + { + WriteOpers("*** %s added permenant Q-line for %s.",user->nick,parameters[0]); + } + else + { + WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1])); + } + } + else + { + if (del_qline(parameters[0])) + { + WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]); + } + else + { + WriteServ(user->fd,"NOTICE %s :*** Q-Line %s not found in list, try /stats k.",user->nick,parameters[0]); + } + } + apply_lines(); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a3177e949..618365c8b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2749,10 +2749,10 @@ void SetupCommandTable(void) createcommand("MODULES",handle_modules,'o',0); createcommand("LINKS",handle_links,0,0); createcommand("MAP",handle_map,0,0); - createcommand("KLINE",handle_kline,'o',3); - createcommand("GLINE",handle_gline,'o',3); - createcommand("ZLINE",handle_zline,'o',3); - createcommand("QLINE",handle_qline,'o',3); + createcommand("KLINE",handle_kline,'o',1); + createcommand("GLINE",handle_gline,'o',1); + createcommand("ZLINE",handle_zline,'o',1); + createcommand("QLINE",handle_qline,'o',1); } void process_buffer(const char* cmdbuf,userrec *user) @@ -3142,6 +3142,8 @@ int InspIRCd(void) #ifdef _POSIX_PRIORITY_SCHEDULING sched_yield(); #endif + // update the status of klines, etc + expire_lines(); fd_set sfd; timeval tval; diff --git a/src/xline.cpp b/src/xline.cpp index 6ca005bad..400fac241 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -512,4 +512,37 @@ void apply_lines() } } +void stats_k(userrec* user) +{ + for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++) + { + WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason); + } +} + +void stats_g(userrec* user) +{ + for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++) + { + WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason); + } +} + +void stats_q(userrec* user) +{ + for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++) + { + WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason); + } +} + +void stats_z(userrec* user) +{ + for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++) + { + WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason); + } +} + + |