X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Flistensocket.cpp;h=4ec6c2b0642453b7dfc31b9a563d7bec46e817d4;hb=bb7b2fc9e76f7a0894afd9bb88c9c326cf20fe6f;hp=dc588386de7893e2b27b78ddd1f6341f9695931e;hpb=e7c829af5941c6a8a303ca75ed9ac47570347e41;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/listensocket.cpp b/src/listensocket.cpp index dc588386d..4ec6c2b06 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -27,10 +27,8 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to) : bind_tag(tag) + , bind_sa(bind_to) { - irc::sockets::satoap(bind_to, bind_addr, bind_port); - bind_desc = bind_to.str(); - fd = socket(bind_to.sa.sa_family, SOCK_STREAM, 0); if (this->fd == -1) @@ -118,12 +116,12 @@ ListenSocket::~ListenSocket() void ListenSocket::OnEventHandlerRead() { irc::sockets::sockaddrs client; - irc::sockets::sockaddrs server; + irc::sockets::sockaddrs server(bind_sa); socklen_t length = sizeof(client); int incomingSockfd = SocketEngine::Accept(this, &client.sa, &length); - ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Accepting connection on socket %s fd %d", bind_desc.c_str(), incomingSockfd); + ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Accepting connection on socket %s fd %d", bind_sa.str().c_str(), incomingSockfd); if (incomingSockfd < 0) { ServerInstance->stats.Refused++; @@ -134,7 +132,6 @@ void ListenSocket::OnEventHandlerRead() if (getsockname(incomingSockfd, &server.sa, &sz)) { ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "Can't get peername: %s", strerror(errno)); - irc::sockets::aptosa(bind_addr, bind_port, server); } if (client.sa.sa_family == AF_INET6) @@ -188,7 +185,7 @@ void ListenSocket::OnEventHandlerRead() { ServerInstance->stats.Refused++; ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Refusing connection on %s - %s", - bind_desc.c_str(), res == MOD_RES_DENY ? "Connection refused by module" : "Module for this port not found"); + bind_sa.str().c_str(), res == MOD_RES_DENY ? "Connection refused by module" : "Module for this port not found"); SocketEngine::Close(incomingSockfd); } }