diff options
-rw-r--r-- | include/modules.h | 9 | ||||
-rw-r--r-- | src/InspIRCd.layout | 28 | ||||
-rw-r--r-- | src/commands.cpp | 22 | ||||
-rw-r--r-- | src/inspircd.cpp | 8 | ||||
-rw-r--r-- | src/modules.cpp | 1 |
5 files changed, 54 insertions, 14 deletions
diff --git a/include/modules.h b/include/modules.h index 20fb5f04d..cf5d87f6f 100644 --- a/include/modules.h +++ b/include/modules.h @@ -230,6 +230,15 @@ class Module : public classbase * of where the message is destined to be sent. */ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text); + + /** Called before any nickchange, local or remote. This can be used to implement Q-lines etc. + * 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. + * check user->server before taking any action (including returning nonzero from the method). + * If your method returns nonzero, the nickchange is silently forbidden, and it is down to your + * module to generate some meaninful output. + */ + virtual int OnUserPreNick(userrec* user, std::string newnick); }; diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 40f21b210..d72cb0f4e 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -13,9 +13,9 @@ LeftChar=1 [Editor_1] Open=1 Top=0 -CursorCol=1 -CursorRow=1 -TopLine=1 +CursorCol=2 +CursorRow=1821 +TopLine=1767 LeftChar=1 [Editor_2] @@ -37,9 +37,9 @@ LeftChar=1 [Editor_4] Open=1 Top=0 -CursorCol=1 -CursorRow=364 -TopLine=333 +CursorCol=62 +CursorRow=128 +TopLine=77 LeftChar=1 [Editor_5] @@ -163,11 +163,11 @@ TopLine=1 LeftChar=1 [Editor_20] -Open=0 +Open=1 Top=0 -CursorCol=32 -CursorRow=30 -TopLine=573 +CursorCol=5 +CursorRow=240 +TopLine=197 LeftChar=1 [Editor_21] @@ -314,7 +314,7 @@ CursorRow=10 TopLine=1 LeftChar=1 [Editor_41] -Open=0 +Open=1 Top=0 CursorCol=22 CursorRow=13 @@ -330,9 +330,9 @@ LeftChar=1 [Editor_43] Open=1 Top=1 -CursorCol=45 -CursorRow=2189 -TopLine=2153 +CursorCol=12 +CursorRow=1678 +TopLine=1651 LeftChar=1 [Editor_44] Open=1 diff --git a/src/commands.cpp b/src/commands.cpp index f8a410dc8..3adf3fc33 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1374,6 +1374,13 @@ void handle_nick(char **parameters, int pcnt, userrec *user) if (user->registered == 7) { + int MOD_RESULT = 0; + FOREACH_RESULT(OnUserPreNick(user,parameters[0])); + if (MOD_RESULT) { + // if a module returns true, the nick change is silently forbidden. + return; + } + WriteCommon(user,"NICK %s",parameters[0]); // Q token must go to ALL servers!!! @@ -1664,6 +1671,14 @@ void handle_n(char token,char* params,serverrec* source,serverrec* reply, char* WriteCommon(user,"NICK %s",newnick); if (is_uline(tcp_host)) { + int MOD_RESULT = 0; + FOREACH_RESULT(OnUserPreNick(user,newnick)); + if (MOD_RESULT) { + // if a module returns true, the nick change couldnt be allowed + kill_link(user,"Nickname collision"); + return; + } + // broadcast this because its a services thingy char buffer[MAXBUF]; snprintf(buffer,MAXBUF,"n %s %s",user->nick,newnick); @@ -2148,6 +2163,13 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) { + if ((!strncmp(udp_msg,"USER ",5)) || (!strncmp(udp_msg,"NICK ",5))) + { + // a user on a server port, just close their connection. + RemoveServer(tcp_host); + return; + } + char response[10240]; char token = udp_msg[0]; char* old = udp_msg; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index f55a6f1b6..80909b312 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2356,7 +2356,15 @@ long map_count(const char* s) void force_nickchange(userrec* user,const char* newnick) { char nick[MAXBUF]; + int MOD_RESULT = 0; + strcpy(nick,""); + + FOREACH_RESULT(OnUserPreNick(user,newnick)); + if (MOD_RESULT) { + kill_link(user,"Nickname collision"); + return; + } if (user) { diff --git a/src/modules.cpp b/src/modules.cpp index 59833b6bd..1c37dd0cb 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -125,6 +125,7 @@ void Module::OnInfo(userrec* user) { }; void Module::OnWhois(userrec* source, userrec* dest) { }; int Module::OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text) { return 0; }; int Module::OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text) { return 0; }; +int Module::OnUserPreNick(userrec* user, std::string newnick) { return 0; }; // server is a wrapper class that provides methods to all of the C-style // exports in the core |