summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-07 04:24:17 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-05-07 04:24:17 +0000
commit373db450cc1351e0271054ba620a9485b8896253 (patch)
tree418e4b7ebba90e7528744f9e3630aa8239d4316e
parent955b3ef59b6d69d04d82c07a8f8548654c4d4d98 (diff)
Fix ListenSocketBase::GetPort() returning incorrect value on ports not bound to a specific address
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11367 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/listensocket.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index 31913e8ee..1daca2a39 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -24,12 +24,13 @@ irc::sockets::sockaddrs ListenSocketBase::server;
ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr) : ServerInstance(Instance), desc("plaintext")
{
irc::sockets::sockaddrs bind_to;
- irc::sockets::aptosa(addr.c_str(), port, &bind_to);
- irc::sockets::satoap(&bind_to, bind_addr, bind_port);
-
- // Preserve empty string for wildcard binds, rather than "::" or "0.0.0.0"
- if (addr.empty())
- bind_addr = addr;
+
+ bind_addr = addr;
+ bind_port = port;
+
+ // canonicalize address if it is defined
+ if (!addr.empty() && irc::sockets::aptosa(addr.c_str(), port, &bind_to))
+ irc::sockets::satoap(&bind_to, bind_addr, bind_port);
this->SetFd(irc::sockets::OpenTCPSocket(bind_addr.c_str()));
if (this->GetFd() > -1)
@@ -68,7 +69,7 @@ void ListenSocketBase::AcceptInternal()
ServerInstance->stats->statsRefused++;
return;
}
-
+
socklen_t sz = sizeof(server);
if (getsockname(incomingSockfd, &server.sa, &sz));
ServerInstance->Logs->Log("SOCKET", DEBUG, "Can't get peername: %s", strerror(errno));