diff options
-rw-r--r-- | include/modules.h | 22 | ||||
-rw-r--r-- | src/commands.cpp | 19 | ||||
-rw-r--r-- | src/modules.cpp | 18 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 63 |
4 files changed, 115 insertions, 7 deletions
diff --git a/include/modules.h b/include/modules.h index 21418ba8a..2b6fec02d 100644 --- a/include/modules.h +++ b/include/modules.h @@ -440,7 +440,27 @@ class Module : public classbase virtual void OnChangeHost(userrec* user, std::string newhost); virtual void OnChangeName(userrec* user, std::string gecos); - + + virtual void OnAddGLine(long duration, userrec* source, std::string reason, std::string hostmask); + + virtual void OnAddZLine(long duration, userrec* source, std::string reason, std::string ipmask); + + virtual void OnAddKLine(long duration, userrec* source, std::string reason, std::string hostmask); + + virtual void OnAddQLine(long duration, userrec* source, std::string reason, std::string nickmask); + + virtual void OnAddELine(long duration, userrec* source, std::string reason, std::string hostmask); + + virtual void OnDelGLine(userrec* source, std::string hostmask); + + virtual void OnDelZLine(userrec* source, std::string ipmask); + + virtual void OnDelKLine(userrec* source, std::string hostmask); + + virtual void OnDelQLine(userrec* source, std::string nickmask); + + virtual void OnDelELine(userrec* source, std::string hostmask); + /** Called after any nickchange, local or remote. This can be used to track users after nickchanges * have been applied. Please note that although you can see remote nickchanges through this function, you should * NOT make any changes to the userrec if the user is a remote user as this may cause a desnyc. diff --git a/src/commands.cpp b/src/commands.cpp index 17f2c632e..1fa29bf8d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1805,6 +1805,13 @@ long duration(const char* str) long total = 0; const char* str_end = str + strlen(str); n_field[0] = 0; + + if ((!strchr(str,'s')) && (!strchr(str,'m')) && (!strchr(str,'h')) && (!strchr(str,'d')) && (!strchr(str,'w')) && (!strchr(str,'y'))) + { + std::string n = str; + n = n + "s"; + return duration(n.c_str()); + } for (char* i = (char*)str; i < str_end; i++) { @@ -1858,6 +1865,7 @@ void handle_kline(char **parameters, int pcnt, userrec *user) if (pcnt >= 3) { add_kline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + FOREACH_MOD OnAddKLine(duration(parameters[1]), user, parameters[2], parameters[0]); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant K-line for %s.",user->nick,parameters[0]); @@ -1871,6 +1879,7 @@ void handle_kline(char **parameters, int pcnt, userrec *user) { if (del_kline(parameters[0])) { + FOREACH_MOD OnDelKLine(user, parameters[0]); WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]); } else @@ -1886,6 +1895,7 @@ void handle_eline(char **parameters, int pcnt, userrec *user) if (pcnt >= 3) { add_eline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + FOREACH_MOD OnAddELine(duration(parameters[1]), user, parameters[2], parameters[0]); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant E-line for %s.",user->nick,parameters[0]); @@ -1899,6 +1909,7 @@ void handle_eline(char **parameters, int pcnt, userrec *user) { if (del_eline(parameters[0])) { + FOREACH_MOD OnDelELine(user, parameters[0]); WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]); } else @@ -1915,6 +1926,7 @@ void handle_gline(char **parameters, int pcnt, userrec *user) if (pcnt >= 3) { add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + FOREACH_MOD OnAddGLine(duration(parameters[1]), user, parameters[2], parameters[0]); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]); @@ -1928,8 +1940,7 @@ 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); + FOREACH_MOD OnDelGLine(user, parameters[0]); WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]); } else @@ -1945,6 +1956,7 @@ void handle_zline(char **parameters, int pcnt, userrec *user) if (pcnt >= 3) { add_zline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + FOREACH_MOD OnAddZLine(duration(parameters[1]), user, parameters[2], parameters[0]); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant Z-line for %s.",user->nick,parameters[0]); @@ -1958,6 +1970,7 @@ void handle_zline(char **parameters, int pcnt, userrec *user) { if (del_zline(parameters[0])) { + FOREACH_MOD OnDelZLine(user, parameters[0]); WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]); } else @@ -1973,6 +1986,7 @@ void handle_qline(char **parameters, int pcnt, userrec *user) if (pcnt >= 3) { add_qline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); + FOREACH_MOD OnAddQLine(duration(parameters[1]), user, parameters[2], parameters[0]); if (!duration(parameters[1])) { WriteOpers("*** %s added permenant Q-line for %s.",user->nick,parameters[0]); @@ -1986,6 +2000,7 @@ void handle_qline(char **parameters, int pcnt, userrec *user) { if (del_qline(parameters[0])) { + FOREACH_MOD OnDelQLine(user, parameters[0]); WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]); } else diff --git a/src/modules.cpp b/src/modules.cpp index 23091fc63..eed3adb1e 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -370,10 +370,20 @@ void Module::ProtoSendMode(void* opaque, int target_type, void* target, std::st void Module::OnWallops(userrec* user, std::string text) { }; void Module::OnChangeHost(userrec* user, std::string newhost) { }; void Module::OnChangeName(userrec* user, std::string gecos) { }; - -// server is a wrapper class that provides methods to all of the C-style -// exports in the core -// +void Module::OnAddGLine(long duration, userrec* source, std::string reason, std::string hostmask) { }; +void Module::OnAddZLine(long duration, userrec* source, std::string reason, std::string ipmask) { }; +void Module::OnAddKLine(long duration, userrec* source, std::string reason, std::string hostmask) { }; +void Module::OnAddQLine(long duration, userrec* source, std::string reason, std::string nickmask) { }; +void Module::OnAddELine(long duration, userrec* source, std::string reason, std::string hostmask) { }; +void Module::OnDelGLine(userrec* source, std::string hostmask) { }; +void Module::OnDelZLine(userrec* source, std::string ipmask) { }; +void Module::OnDelKLine(userrec* source, std::string hostmask) { }; +void Module::OnDelQLine(userrec* source, std::string nickmask) { }; +void Module::OnDelELine(userrec* source, std::string hostmask) { }; + +/* server is a wrapper class that provides methods to all of the C-style + * exports in the core + */ Server::Server() { diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 313a5d93c..c2526c2b0 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -2211,6 +2211,69 @@ class ModuleSpanningTree : public Module } } + void OnLine(userrec* source, std::string host, bool adding, char linetype, long duration, std::string reason) + { + if (std::string(source->server) == Srv->GetServerName()) + { + if (adding) + { + char sduration[MAXBUF]; + snprintf(sduration,MAXBUF,"%ld",duration); + std::deque<std::string> params; + params.push_back(host); + params.push_back(sduration); + params.push_back(":"+reason); + DoOneToMany(source->nick,linetype+"LINE",params); + } + else + { + std::deque<std::string> params; + params.push_back(host); + DoOneToMany(source->nick,linetype+"LINE",params); + } + } + } + + virtual void OnAddGLine(long duration, userrec* source, std::string reason, std::string hostmask) + { + OnLine(source,hostmask,true,'G',duration,reason); + } + + virtual void OnAddZLine(long duration, userrec* source, std::string reason, std::string ipmask) + { + OnLine(source,ipmask,true,'Z',duration,reason); + } + + virtual void OnAddQLine(long duration, userrec* source, std::string reason, std::string nickmask) + { + OnLine(source,nickmask,true,'Q',duration,reason); + } + + virtual void OnAddELine(long duration, userrec* source, std::string reason, std::string hostmask) + { + OnLine(source,hostmask,true,'E',duration,reason); + } + + virtual void OnDelGLine(userrec* source, std::string hostmask) + { + OnLine(source,hostmask,false,'G',"",""); + } + + virtual void OnDelZLine(userrec* source, std::string ipmask) + { + OnLine(source,ipmask,false,'Z',"",""); + } + + virtual void OnDelQLine(userrec* source, std::string nickmask) + { + OnLine(source,nickmask,false,'Q',"",""); + } + + virtual void OnDelELine(userrec* source, std::string hostmask) + { + OnLine(source,hostmask,false,'E',"",""); + } + virtual void OnMode(userrec* user, void* dest, int target_type, std::string text) { if (std::string(user->server) == Srv->GetServerName()) |