]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socket.cpp
Fixed broken syncing for glines and elines using idents - thanks to dotslasher for...
[user/henk/code/inspircd.git] / src / socket.cpp
index 50a4050e01f6d0acbaf5a36d3542e33440d00d5c..6d7fc45d6108be4deb84f0b3683d1e6da2df86d4 100644 (file)
@@ -18,7 +18,6 @@
 #include "configreader.h"
 #include "socket.h"
 #include "inspircd.h"
-#include "inspstring.h"
 #include "socketengine.h"
 #include "wildcard.h"
 
@@ -52,7 +51,7 @@ ListenSocket::ListenSocket(InspIRCd* Instance, int sockfd, insp_sockaddr client,
        }
 }
 
-void ListenSocket::HandleEvent(EventType et)
+void ListenSocket::HandleEvent(EventType et, int errornum)
 {
        insp_sockaddr sock_us;  // our port number
        socklen_t uslen;        // length of our port number
@@ -216,6 +215,7 @@ bool irc::sockets::MatchCIDR(const char* address, const char* cidr_mask, bool ma
        else
        {
                /* No 'number of bits' field! */
+               free(mask);
                return false;
        }
 
@@ -389,13 +389,15 @@ bool InspIRCd::HasPort(int port, char* addr)
 }
 
 /* XXX: Probably belongs in class InspIRCd */
-int InspIRCd::BindPorts(bool bail)
+int InspIRCd::BindPorts(bool bail, int &ports_found)
 {
        char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
        insp_sockaddr client, server;
        int clientportcount = 0;
        int BoundPortCount = 0;
 
+       ports_found = 0;
+
        if (!bail)
        {
                int InitialPortCount = stats->BoundPortCount;
@@ -409,6 +411,7 @@ int InspIRCd::BindPorts(bool bail)
 
                        if (((!*Type) || (!strcmp(Type,"clients"))) && (!HasPort(atoi(configToken),Addr)))
                        {
+                               ports_found++;
                                // modules handle server bind types now
                                Config->ports[clientportcount+InitialPortCount] = atoi(configToken);
                                if (*Addr == '*')
@@ -422,6 +425,7 @@ int InspIRCd::BindPorts(bool bail)
                int PortCount = clientportcount;
                if (PortCount)
                {
+                       BoundPortCount = stats->BoundPortCount;
                        for (int count = InitialPortCount; count < InitialPortCount + PortCount; count++)
                        {
                                int fd = OpenTCPSocket();
@@ -431,15 +435,15 @@ int InspIRCd::BindPorts(bool bail)
                                }
                                else
                                {
-                                       Config->openSockfd[count] = new ListenSocket(this,fd,client,server,Config->ports[count],Config->addrs[count]);
-                                       if (Config->openSockfd[count]->GetFd() > -1)
+                                       Config->openSockfd[BoundPortCount] = new ListenSocket(this,fd,client,server,Config->ports[count],Config->addrs[count]);
+                                       if (Config->openSockfd[BoundPortCount]->GetFd() > -1)
                                        {
-                                               if (!SE->AddFd(Config->openSockfd[count]))
+                                               if (!SE->AddFd(Config->openSockfd[BoundPortCount]))
                                                {
                                                        this->Log(DEFAULT,"ERK! Failed to add listening port to socket engine!");
-                                                       shutdown(Config->openSockfd[count]->GetFd(),2);
-                                                       close(Config->openSockfd[count]->GetFd());
-                                                       delete Config->openSockfd[count];
+                                                       shutdown(Config->openSockfd[BoundPortCount]->GetFd(),2);
+                                                       close(Config->openSockfd[BoundPortCount]->GetFd());
+                                                       delete Config->openSockfd[BoundPortCount];
                                                }
                                                else
                                                        BoundPortCount++;
@@ -467,6 +471,7 @@ int InspIRCd::BindPorts(bool bail)
 
                if ((!*Type) || (!strcmp(Type,"clients")))
                {
+                       ports_found++;
                        // modules handle server bind types now
                        Config->ports[clientportcount] = atoi(configToken);
 
@@ -494,8 +499,8 @@ int InspIRCd::BindPorts(bool bail)
                }
                else
                {
-                       Config->openSockfd[count] = new ListenSocket(this,fd,client,server,Config->ports[count],Config->addrs[count]);
-                       if (Config->openSockfd[count]->GetFd() > -1)
+                       Config->openSockfd[BoundPortCount] = new ListenSocket(this,fd,client,server,Config->ports[count],Config->addrs[count]);
+                       if (Config->openSockfd[BoundPortCount]->GetFd() > -1)
                        {
                                BoundPortCount++;
                        }