]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Fix this not working.
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index 18fd346b7259130fcb14ece569413d711fa2764e..6fd7785e4e789abfe25062d94778b6c61c24b8a9 100644 (file)
@@ -146,14 +146,14 @@ bool InspSocket::BindAddr()
                std::string IP = Conf.ReadValue("bind","address",j);
                if (Type == "servers")
                {
-                       if ((IP != "*") && (IP != "127.0.0.1") && (IP != ""))
+                       if ((IP != "*") && (IP != "127.0.0.1") && (IP != "") && (IP != "::1"))
                        {
                                insp_sockaddr s;
 
                                if (insp_aton(IP.c_str(),&n) > 0)
                                {
 #ifdef IPV6
-                                       s.sin6_addr = n;
+                                       memcpy(&s.sin6_addr, &n, sizeof(n));
                                        s.sin6_family = AF_FAMILY;
 #else
                                        s.sin_addr = n;
@@ -192,7 +192,7 @@ bool InspSocket::DoConnect()
        insp_aton(this->IP,&addy);
 #ifdef IPV6
        addr.sin6_family = AF_FAMILY;
-       memcpy(&addr.sin6_addr, &addy, sizeof(insp_inaddr));
+       memcpy(&addr.sin6_addr, &addy, sizeof(addy));
        addr.sin6_port = htons(this->port);
 #else
        addr.sin_family = AF_FAMILY;
@@ -200,8 +200,7 @@ bool InspSocket::DoConnect()
        addr.sin_port = htons(this->port);
 #endif
 
-       int flags;
-       flags = fcntl(this->fd, F_GETFL, 0);
+       int flags = fcntl(this->fd, F_GETFL, 0);
        fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
 
        if (connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
@@ -235,6 +234,11 @@ bool InspSocket::DoConnect()
 
 void InspSocket::Close()
 {
+       /* Save this, so we dont lose it,
+        * otherise on failure, error messages
+        * might be inaccurate.
+        */
+       int save = errno;
        if (this->fd > -1)
        {
                 if (this->IsIOHooked && Instance->Config->GetIOHook(this))
@@ -252,6 +256,7 @@ void InspSocket::Close()
                shutdown(this->fd,2);
                close(this->fd);
        }
+       errno = save;
 }
 
 std::string InspSocket::GetIP()