diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-03-24 16:03:39 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-03-24 16:03:39 +0000 |
commit | 43d1577839df81d3746092f11ebd1280ca2f85c1 (patch) | |
tree | 6014c07ec588186e6e64949542ce88387131abd6 /src/socket.cpp | |
parent | 343f12b9b2d4e519b09877f76a00f6a0714509f2 (diff) |
Port bindings for gnutls now bind via ip:port, rather than on all ports for that ip, fixes feature request for roadmap. NOTE, this still needs doing for the openssl module!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9188 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socket.cpp')
-rw-r--r-- | src/socket.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/socket.cpp b/src/socket.cpp index 2089fffbd..16cdebae6 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -101,23 +101,42 @@ void ListenSocket::HandleEvent(EventType, int) if ((incomingSockfd > -1) && (!ServerInstance->SE->GetSockName(this, sock_us, &uslen))) { char buf[MAXBUF]; + char target[MAXBUF]; + + *target = *buf = '\0'; + + sockaddr* raddr = new sockaddr[2]; + #ifdef IPV6 if (this->family == AF_INET6) { - inet_ntop(AF_INET6, &((const sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf)); in_port = ntohs(((sockaddr_in6*)sock_us)->sin6_port); + inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, buf, sizeof(buf)); + socklen_t raddrsz = sizeof(sockaddr_in6); + if (getpeername(incomingSockfd, (sockaddr*) raddr, &raddrsz) == 0) + inet_ntop(AF_INET6, &((const sockaddr_in6*)raddr)->sin6_addr, target, sizeof(target)); + else + ServerInstance->Logs->Log("SOCKET", DEBUG, "Can't get peername: %s", strerror(errno)); } else #endif { inet_ntop(AF_INET, &((const sockaddr_in*)client)->sin_addr, buf, sizeof(buf)); in_port = ntohs(((sockaddr_in*)sock_us)->sin_port); + socklen_t raddrsz = sizeof(sockaddr_in); + if (getpeername(incomingSockfd, (sockaddr*) raddr, &raddrsz) == 0) + inet_ntop(AF_INET, &((const sockaddr_in*)raddr)->sin_addr, target, sizeof(target)); + else + ServerInstance->Logs->Log("SOCKET", DEBUG, "Can't get peername: %s", strerror(errno)); + } + delete[] raddr; + ServerInstance->SE->NonBlocking(incomingSockfd); ServerInstance->stats->statsAccept++; - ServerInstance->Users->AddClient(ServerInstance, incomingSockfd, in_port, false, this->family, client); + ServerInstance->Users->AddClient(ServerInstance, incomingSockfd, in_port, false, this->family, client, target); } else { |