diff options
-rw-r--r-- | include/xline.h | 4 | ||||
-rw-r--r-- | src/InspIRCd.layout | 24 | ||||
-rw-r--r-- | src/commands.cpp | 162 | ||||
-rw-r--r-- | src/inspircd.cpp | 28 | ||||
-rw-r--r-- | src/xline.cpp | 39 |
5 files changed, 244 insertions, 13 deletions
diff --git a/include/xline.h b/include/xline.h index e87c5ff50..bdd9ac2d3 100644 --- a/include/xline.h +++ b/include/xline.h @@ -110,5 +110,9 @@ void stats_g(userrec* user); void stats_q(userrec* user); void stats_z(userrec* user); +void gline_set_creation_time(char* host, time_t create_time); +void qline_set_creation_time(char* nick, time_t create_time); +void zline_set_creation_time(char* ip, time_t create_time); + #endif diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 685da9ec2..26ab5cd17 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -13,9 +13,9 @@ LeftChar=1 [Editor_1] Open=1 Top=0 -CursorCol=42 -CursorRow=2755 -TopLine=2709 +CursorCol=2 +CursorRow=2245 +TopLine=2204 LeftChar=1 [Editor_2] @@ -330,9 +330,9 @@ LeftChar=1 [Editor_43] Open=1 Top=1 -CursorCol=1 -CursorRow=2657 -TopLine=2636 +CursorCol=14 +CursorRow=1776 +TopLine=1743 LeftChar=1 [Editor_44] Open=1 @@ -344,14 +344,14 @@ LeftChar=1 [Editor_45] Open=1 Top=0 -CursorCol=1 -CursorRow=114 -TopLine=17 +CursorCol=60 +CursorRow=115 +TopLine=61 LeftChar=1 [Editor_46] Open=1 Top=0 -CursorCol=1 -CursorRow=543 -TopLine=492 +CursorCol=24 +CursorRow=380 +TopLine=344 LeftChar=1 diff --git a/src/commands.cpp b/src/commands.cpp index f56783b5a..8d3e087bd 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1440,7 +1440,6 @@ void handle_nick(char **parameters, int pcnt, userrec *user) /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */ ConnectUser(user); } - log(DEBUG,"exit nickchange: %s",user->nick); } @@ -1774,6 +1773,7 @@ void handle_H(char token,char* params,serverrec* source,serverrec* reply, char* s.SetState(STATE_DISCONNECTED); s.SetServerName(params); source->connectors.push_back(s); + WriteOpers("Non-Mesh server %s has joined the network",params); } void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) @@ -2031,6 +2031,129 @@ void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char long authcookie; +void handle_hash(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + // # <mask> <who-set-it> <time-set> <duration> :<reason> + log(DEBUG,"Adding G-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + char* create_time = strtok(NULL," "); + char* duration = strtok(NULL," :"); + char* reason = strtok(NULL,"\r\n"); + add_gline(atoi(duration),who,reason,mask); + // we must update the creation time on this gline + // now that we've added it, or it wont expire at the right time. + gline_set_creation_time(mask,atoi(create_time)); + if (!atoi(duration)) + { + WriteOpers("*** %s Added permenant G-Line on %s.",who,mask); + } + else + { + WriteOpers("*** %s Added timed G-Line on %s to expire in %d seconds.",who,mask,atoi(duration)); + } + apply_lines(); +} + +void handle_dot(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + log(DEBUG,"Removing G-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + if (mask) + { + if (del_gline(mask)) + { + if (who) + { + WriteOpers("*** %s Removed G-line on %s.",who,mask); + } + } + } +} + +void handle_add_sqline(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + // { <mask> <who-set-it> <time-set> <duration> :<reason> + log(DEBUG,"Adding Q-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + char* create_time = strtok(NULL," "); + char* duration = strtok(NULL," :"); + char* reason = strtok(NULL,"\r\n"); + add_qline(atoi(duration),who,reason,mask); + // we must update the creation time on this gline + // now that we've added it, or it wont expire at the right time. + qline_set_creation_time(mask,atoi(create_time)); + if (!atoi(duration)) + { + WriteOpers("*** %s Added permenant Q-Line on %s.",who,mask); + } + else + { + WriteOpers("*** %s Added timed Q-Line on %s to expire in %d seconds.",who,mask,atoi(duration)); + } + apply_lines(); +} + +void handle_del_sqline(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + log(DEBUG,"Removing Q-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + if (mask) + { + if (del_qline(mask)) + { + if (who) + { + WriteOpers("*** %s Removed Q-line on %s.",who,mask); + } + } + } +} + +void handle_add_szline(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + // } <mask> <who-set-it> <time-set> <duration> :<reason> + log(DEBUG,"Adding Z-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + char* create_time = strtok(NULL," "); + char* duration = strtok(NULL," :"); + char* reason = strtok(NULL,"\r\n"); + add_zline(atoi(duration),who,reason,mask); + // we must update the creation time on this gline + // now that we've added it, or it wont expire at the right time. + zline_set_creation_time(mask,atoi(create_time)); + if (!atoi(duration)) + { + WriteOpers("*** %s Added permenant Z-Line on %s.",who,mask); + } + else + { + WriteOpers("*** %s Added timed Z-Line on %s to expire in %d seconds.",who,mask,atoi(duration)); + } + apply_lines(); +} + +void handle_del_szline(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) +{ + log(DEBUG,"Removing Z-line"); + char* mask = strtok(params," "); + char* who = strtok(NULL," "); + if (mask) + { + if (del_zline(mask)) + { + if (who) + { + WriteOpers("*** %s Removed Q-line on %s.",who,mask); + } + } + } +} + void process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host,char* ipaddr,int port) { @@ -2181,6 +2304,36 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve case '@': handle_AT(token,params,source,reply,tcp_host); break; + // # <mask> <who-set-it> <time-set> <duration> :<reason> + // add gline + case '#': + handle_hash(token,params,source,reply,tcp_host); + break; + // . <mask> <who> + // remove gline + case '.': + handle_dot(token,params,source,reply,tcp_host); + break; + // # <mask> <who-set-it> <time-set> <duration> :<reason> + // add gline + case '{': + handle_add_sqline(token,params,source,reply,tcp_host); + break; + // . <mask> <who> + // remove gline + case '[': + handle_del_sqline(token,params,source,reply,tcp_host); + break; + // # <mask> <who-set-it> <time-set> <duration> :<reason> + // add gline + case '}': + handle_add_szline(token,params,source,reply,tcp_host); + break; + // . <mask> <who> + // remove gline + case ']': + handle_del_szline(token,params,source,reply,tcp_host); + break; // F <TS> // end netburst case 'F': @@ -2587,6 +2740,7 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) NetSendMyRoutingTable(); sprintf(buffer,"H %s",servername); NetSendToAllExcept(servername,buffer); + WriteOpers("Non-Mesh server %s has joined the network",servername); return; } } @@ -2725,9 +2879,13 @@ void handle_kline(char **parameters, int pcnt, userrec *user) void handle_gline(char **parameters, int pcnt, userrec *user) { + char netdata[MAXBUF]; if (pcnt >= 3) { add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + // # <mask> <who-set-it> <time-set> <duration> :<reason> + snprintf(netdata,MAXBUF,"# %s %s %ld %ld :%s",parameters[0],user->nick,time(NULL),duration(parameters[1]),parameters[2]); + NetSendToAll(netdata); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]); @@ -2741,6 +2899,8 @@ void handle_gline(char **parameters, int pcnt, userrec *user) { if (del_gline(parameters[0])) { + // . <mask> <who-removed-it> + snprintf(netdata,MAXBUF,". %s %s",parameters[0],user->nick); WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]); } else diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 618365c8b..f226f2af5 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2102,6 +2102,14 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip) if (clientlist.size() == MAXCLIENTS) kill_link(clientlist[tempnick],"No more connections allowed in this class"); + + char* r = matches_zline(ip); + if (r) + { + char reason[MAXBUF]; + snprintf(reason,MAXBUF,"Z-Lined: %s",r); + kill_link(clientlist[tempnick],reason); + } } @@ -2225,6 +2233,26 @@ void ConnectUser(userrec *user) return; } + char match_against[MAXBUF]; + snprintf(match_against,MAXBUF,"%s@%s",user->ident,user->host); + char* r = matches_gline(match_against); + if (r) + { + char reason[MAXBUF]; + snprintf(reason,MAXBUF,"G-Lined: %s",r); + kill_link(user,reason); + return; + } + + r = matches_kline(user->host); + if (r) + { + char reason[MAXBUF]; + snprintf(reason,MAXBUF,"K-Lined: %s",r); + kill_link(user,reason); + return; + } + WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Network); WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Network,user->nick,user->ident,user->host); WriteServ(user->fd,"002 %s :Your host is %s, running version %s",user->nick,ServerName,VERSION); diff --git a/src/xline.cpp b/src/xline.cpp index 400fac241..1ef612ff1 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -345,6 +345,45 @@ char* matches_gline(const char* host) return NULL; } +void gline_set_creation_time(char* host, time_t create_time) +{ + for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++) + { + if (!strcasecmp(host,i->hostmask)) + { + i->set_time = create_time; + return; + } + } + return ; +} + +void qline_set_creation_time(char* nick, time_t create_time) +{ + for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++) + { + if (!strcasecmp(nick,i->nick)) + { + i->set_time = create_time; + return; + } + } + return ; +} + +void zline_set_creation_time(char* ip, time_t create_time) +{ + for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++) + { + if (!strcasecmp(ip,i->ipaddr)) + { + i->set_time = create_time; + return; + } + } + return ; +} + // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match char* matches_zline(const char* ipaddr) |