]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/listensocket.cpp
Convert IsNick to std::function.
[user/henk/code/inspircd.git] / src / listensocket.cpp
index d09f5e62436ea60ca1a70c33c2ea699b13c255f8..4ec6c2b0642453b7dfc31b9a563d7bec46e817d4 100644 (file)
 
 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)
@@ -74,7 +72,7 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
                rv = SocketEngine::Listen(this->fd, ServerInstance->Config->MaxConn);
 
        // Default defer to on for TLS listeners because in TLS the client always speaks first
-       int timeout = tag->getInt("defer", (tag->getString("ssl").empty() ? 0 : 3));
+       int timeout = tag->getDuration("defer", (tag->getString("ssl").empty() ? 0 : 3));
        if (timeout && !rv)
        {
 #if defined TCP_DEFER_ACCEPT
@@ -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);
        }
 }