]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/listensocket.cpp
Omit the server name internally when building a /STATS reply and prepend it later
[user/henk/code/inspircd.git] / src / listensocket.cpp
index 20cbe51ac8d21098182e4b0d8ec85cee990f3433..01bc36cc5ea6c08d6c7874b6a140c9493ebe6033 100644 (file)
 #include "socket.h"
 #include "socketengine.h"
 
-#ifdef USE_TCP_DEFER_ACCEPT
+#ifndef _WIN32
 #include <netinet/tcp.h>
 #endif
 
 ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to)
        : bind_tag(tag)
+       , iohookprov(NULL, std::string())
 {
        irc::sockets::satoap(bind_to, bind_addr, bind_port);
-       bind_desc = irc::sockets::satouser(bind_to);
+       bind_desc = bind_to.str();
 
        fd = socket(bind_to.sa.sa_family, SOCK_STREAM, 0);
 
@@ -63,9 +64,9 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
        int timeout = tag->getInt("defer", 0);
        if (timeout && !rv)
        {
-#ifdef USE_TCP_DEFER_ACCEPT
+#if defined TCP_DEFER_ACCEPT
                setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, sizeof(timeout));
-#elif defined USE_SO_ACCEPTFILTER
+#elif defined SO_ACCEPTFILTER
                struct accept_filter_arg afa;
                memset(&afa, 0, sizeof(afa));
                strcpy(afa.af_name, "dataready");
@@ -85,6 +86,8 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
        {
                ServerInstance->SE->NonBlocking(this->fd);
                ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE);
+
+               this->ResetIOHookProvider();
        }
 }
 
@@ -214,3 +217,16 @@ void ListenSocket::HandleEvent(EventType e, int err)
                        break;
        }
 }
+
+bool ListenSocket::ResetIOHookProvider()
+{
+       std::string provname = bind_tag->getString("ssl");
+       if (!provname.empty())
+               provname.insert(0, "ssl/");
+
+       // Set the new provider name, dynref handles the rest
+       iohookprov.SetProvider(provname);
+
+       // Return true if no provider was set, or one was set and it was also found
+       return (provname.empty() || iohookprov);
+}