]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix problem where in certain cases a \0 would be sent out. Thx to network Hak5IRC...
[user/henk/code/inspircd.git] / src / users.cpp
index 906a2e9c3dccda8936052850b3ccae66d11cc3ba..7e0851f59abf0c6e3c50c9dfb6121d18c913aae0 100644 (file)
@@ -183,14 +183,10 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
                                        bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (!strncmp(ip, "0::ffff:", 8) ? DNS_QUERY_A : DNS_QUERY_AAAA), cached);
                                }
                                else
-                               {
                                        /* IPV4 lookup (mixed protocol mode) */
-                                       bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached);
-                               }
-#else
+#endif
                                /* IPV4 lookup (ipv4 only mode) */
                                bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached);
-#endif
                                this->ServerInstance->AddResolver(bound_user->res_forward, cached);
                        }
                }
@@ -334,9 +330,9 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
        ChannelCount = timeout = flood = bytes_in = bytes_out = cmds_in = cmds_out = 0;
        muted = exempt = haspassed = dns_done = false;
        fd = -1;
-       recvq = "";
-       sendq = "";
-       WriteError = "";
+       recvq.clear();
+       sendq.clear();
+       WriteError.clear();
        res_forward = res_reverse = NULL;
        Visibility = NULL;
        ip = NULL;
@@ -636,7 +632,7 @@ bool userrec::BufferIsReady()
 
 void userrec::ClearBuffer()
 {
-       recvq = "";
+       recvq.clear();
 }
 
 std::string userrec::GetBuffer()
@@ -717,7 +713,7 @@ void userrec::FlushWriteBuf()
        {
                if ((this->fd == FD_MAGIC_NUMBER) || (*this->GetWriteError()))
                {
-                       sendq = "";
+                       sendq.clear();
                }
                if ((sendq.length()) && (this->fd != FD_MAGIC_NUMBER))
                {
@@ -864,10 +860,8 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
        if (socketfamily == AF_INET6)
                inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, ipaddr, sizeof(ipaddr));
        else
-               inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
-#else
-       inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
 #endif
+       inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr));
        userrec* New;
        int j = 0;
 
@@ -968,6 +962,8 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
                if (r)
                {
                        char reason[MAXBUF];
+                       if (*Instance->Config->MoronBanner)
+                               New->WriteServ("NOTICE %s :*** %s", New->nick, Instance->Config->MoronBanner);
                        snprintf(reason,MAXBUF,"Z-Lined: %s",r->reason);
                        userrec::QuitUser(Instance, New, reason);
                        return;
@@ -1019,20 +1015,12 @@ void userrec::CheckClass()
                userrec::QuitUser(ServerInstance, this, "Unauthorised connection");
                return;
        }
-
-       if ((!a->GetPass().empty()) && (!this->haspassed))
+       else if ((!a->GetPass().empty()) && (!this->haspassed))
        {
                userrec::QuitUser(ServerInstance, this, "Invalid password");
                return;
        }
-
-       if ((!a) || (a->GetType() == CC_DENY))
-       {
-               userrec::QuitUser(ServerInstance, this,"Unauthorised connection");
-               return;
-       }
-
-       if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
+       else if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
        {
                userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
                ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
@@ -1067,6 +1055,8 @@ void userrec::FullConnect()
                {
                        this->muted = true;
                        char reason[MAXBUF];
+                       if (*ServerInstance->Config->MoronBanner)
+                               this->WriteServ("NOTICE %s :*** %s", this->nick, ServerInstance->Config->MoronBanner);
                        snprintf(reason,MAXBUF,"G-Lined: %s",r->reason);
                        ServerInstance->GlobalCulls.AddItem(this, reason);
                        return;
@@ -1078,11 +1068,12 @@ void userrec::FullConnect()
                {
                        this->muted = true;
                        char reason[MAXBUF];
+                       if (*ServerInstance->Config->MoronBanner)
+                               this->WriteServ("NOTICE %s :*** %s", this, ServerInstance->Config->MoronBanner);
                        snprintf(reason,MAXBUF,"K-Lined: %s",n->reason);
                        ServerInstance->GlobalCulls.AddItem(this, reason);
                        return;
                }
-
        }
 
        this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
@@ -1630,7 +1621,7 @@ void userrec::WriteWallOps(const std::string &text)
        for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
        {
                userrec* t = *i;
-               if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS]))
+               if (t->modes[UM_WALLOPS])
                        this->WriteTo(t,wallop);
        }
 }