]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Fixed quit-bouncing issue when a user is g-lined
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 618365c8b84e33633c2d45d75ae35cab4400fef1..8f095889090c5a7e28d7c669319eca7092b32338 100644 (file)
@@ -1840,6 +1840,56 @@ void kill_link(userrec *user,const char* r)
        }
 }
 
+void kill_link_silent(userrec *user,const char* r)
+{
+       user_hash::iterator iter = clientlist.find(user->nick);
+       
+       char reason[MAXBUF];
+       
+       strncpy(reason,r,MAXBUF);
+
+       if (strlen(reason)>MAXQUIT)
+       {
+               reason[MAXQUIT-1] = '\0';
+       }
+
+       log(DEBUG,"kill_link: %s '%s'",user->nick,reason);
+       Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason);
+       log(DEBUG,"closing fd %d",user->fd);
+
+       /* bugfix, cant close() a nonblocking socket (sux!) */
+       if (user->registered == 7) {
+               FOREACH_MOD OnUserQuit(user);
+               WriteCommonExcept(user,"QUIT :%s",reason);
+
+               // Q token must go to ALL servers!!!
+               char buffer[MAXBUF];
+               snprintf(buffer,MAXBUF,"Q %s :%s",user->nick,reason);
+               NetSendToAll(buffer);
+       }
+
+       /* push the socket on a stack of sockets due to be closed at the next opportunity
+        * 'Client exited' is an exception to this as it means the client side has already
+        * closed the socket, we don't need to do it.
+        */
+       fd_reap.push_back(user->fd);
+       
+       bool do_purge = false;
+       
+       if (iter != clientlist.end())
+       {
+               log(DEBUG,"deleting user hash value %d",iter->second);
+               if ((iter->second) && (user->registered == 7)) {
+                       delete iter->second;
+               }
+               clientlist.erase(iter);
+       }
+
+       if (user->registered == 7) {
+               purge_empty_chans();
+       }
+}
+
 
 
 // looks up a users password for their connection class (<ALLOW>/<DENY> tags)
@@ -2102,6 +2152,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 +2283,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_silent(user,reason);
+               return;
+       }
+
+       r = matches_kline(user->host);
+       if (r)
+       {
+               char reason[MAXBUF];
+               snprintf(reason,MAXBUF,"K-Lined: %s",r);
+               kill_link_silent(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);