diff options
-rw-r--r-- | include/socket.h | 17 | ||||
-rw-r--r-- | src/listensocket.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_httpd.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 9 | ||||
-rw-r--r-- | src/usermanager.cpp | 8 |
5 files changed, 43 insertions, 12 deletions
diff --git a/include/socket.h b/include/socket.h index 52294fe71..427ee9fe7 100644 --- a/include/socket.h +++ b/include/socket.h @@ -141,10 +141,21 @@ class CoreExport ListenSocket : public EventHandler /** Human-readable bind description */ std::string bind_desc; - /** The IOHook provider which handles connections on this socket, - * NULL if there is none. + class IOHookProvRef : public dynamic_reference_nocheck<IOHookProvider> + { + public: + IOHookProvRef() + : dynamic_reference_nocheck<IOHookProvider>(NULL, std::string()) + { + } + }; + + typedef TR1NS::array<IOHookProvRef, 2> IOHookProvList; + + /** IOHook providers for handling connections on this socket, + * may be empty. */ - dynamic_reference_nocheck<IOHookProvider> iohookprov; + IOHookProvList iohookprovs; /** Create a new listening socket */ diff --git a/src/listensocket.cpp b/src/listensocket.cpp index f560ad277..fb9f2a0ef 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -19,6 +19,7 @@ #include "inspircd.h" +#include "iohook.h" #ifndef _WIN32 #include <netinet/tcp.h> @@ -26,7 +27,6 @@ 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 = bind_to.str(); @@ -180,10 +180,21 @@ void ListenSocket::OnEventHandlerRead() void ListenSocket::ResetIOHookProvider() { + iohookprovs[0].SetProvider(bind_tag->getString("hook")); + + // Check that all non-last hooks support being in the middle + for (IOHookProvList::iterator i = iohookprovs.begin(); i != iohookprovs.end()-1; ++i) + { + IOHookProvRef& curr = *i; + // Ignore if cannot be in the middle + if ((curr) && (!curr->IsMiddle())) + curr.SetProvider(std::string()); + } + 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); + // SSL should be the last + iohookprovs.back().SetProvider(provname); } diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 0b6b2e32b..64bef70d1 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -78,8 +78,8 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru { ServerInstance->Timers.AddTimer(this); - if (via->iohookprov) - via->iohookprov->OnAccept(this, client, server); + if ((!via->iohookprovs.empty()) && (via->iohookprovs.back())) + via->iohookprovs.back()->OnAccept(this, client, server); } ~HttpServerSocket() diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 2198d6208..e1642a086 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -60,8 +60,13 @@ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* cl capab = new CapabData; capab->capab_phase = 0; - if (via->iohookprov) - via->iohookprov->OnAccept(this, client, server); + for (ListenSocket::IOHookProvList::iterator i = via->iohookprovs.begin(); i != via->iohookprovs.end(); ++i) + { + ListenSocket::IOHookProvRef& iohookprovref = *i; + if (iohookprovref) + iohookprovref->OnAccept(this, client, server); + } + SendCapabilities(1); Utils->timeoutlist[this] = std::pair<std::string, int>(linkID, 30); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index fe052fcfc..95deca00a 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -72,8 +72,12 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs UserIOHandler* eh = &New->eh; // If this listener has an IO hook provider set then tell it about the connection - if (via->iohookprov) - via->iohookprov->OnAccept(eh, client, server); + for (ListenSocket::IOHookProvList::iterator i = via->iohookprovs.begin(); i != via->iohookprovs.end(); ++i) + { + ListenSocket::IOHookProvRef& iohookprovref = *i; + if (iohookprovref) + iohookprovref->OnAccept(eh, client, server); + } ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New user fd: %d", socket); |