]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Stuff to make dns work protocol-independent
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index f408de6ddaf6fe9fb94ab4418e48ecd3e0763524..08b8f4cd698c2fa907b9d0f41494fd059c9210ff 100644 (file)
@@ -56,7 +56,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool
        this->IsIOHooked = false;
        if (listening)
        {
-               if ((this->fd = OpenTCPSocket()) == ERROR)
+               if ((this->fd = OpenTCPSocket(host)) == ERROR)
                {
                        this->fd = -1;
                        this->state = I_ERROR;
@@ -65,7 +65,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool
                }
                else
                {
-                       if (!SI->BindSocket(this->fd,this->client,this->server,aport,(char*)ipaddr.c_str()))
+                       if (!SI->BindSocket(this->fd,aport,(char*)ipaddr.c_str()))
                        {
                                this->Close();
                                this->fd = -1;
@@ -88,7 +88,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool
                                }
                                return;
                        }
-               }                       
+               }
        }
        else
        {
@@ -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)