]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/listensocket.cpp
Merge commit 'danieldg/out-12'
[user/henk/code/inspircd.git] / src / listensocket.cpp
index 3ecfbb432d54dcd2db18924e058b72fceb18433e..313396ed7829b52a448b61069eaada1df711d274 100644 (file)
@@ -24,15 +24,15 @@ sockaddr* ListenSocketBase::sock_us = NULL;
 sockaddr* ListenSocketBase::client = NULL;
 sockaddr* ListenSocketBase::raddr = NULL;
 
-ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, char* addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
+ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
 {
-       this->SetFd(irc::sockets::OpenTCPSocket(addr));
+       this->SetFd(irc::sockets::OpenTCPSocket(addr.c_str()));
        if (this->GetFd() > -1)
        {
-               if (!Instance->BindSocket(this->fd,port,addr))
+               if (!Instance->BindSocket(this->fd,port,addr.c_str()))
                        this->fd = -1;
 #ifdef IPV6
-               if ((!*addr) || (strchr(addr,':')))
+               if ((!*addr.c_str()) || (strchr(addr.c_str(),':')))
                        this->family = AF_INET6;
                else
 #endif
@@ -128,6 +128,10 @@ void ListenSocketBase::AcceptInternal()
        if (this->family == AF_INET6)
        {
                inet_ntop(AF_INET6, &((const sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf));
+               if (!strncmp(buf, "::ffff:", 7))
+               {
+                       memmove(buf, buf+7, sizeof(buf)-7);
+               }
                socklen_t raddrsz = sizeof(sockaddr_in6);
                if (getsockname(incomingSockfd, (sockaddr*) raddr, &raddrsz) == 0)
                        inet_ntop(AF_INET6, &((const sockaddr_in6*)raddr)->sin6_addr, target, sizeof(target));