diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-08-08 15:10:43 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-08-08 15:10:43 +0200 |
commit | 8dbd80610aee01b8064ca813e1dd7ca44ab3f7b6 (patch) | |
tree | e9b8c765a412d957680acabdec7f04ff01082930 /src | |
parent | 4d3601938593685b3f45439227838f16ee773cdc (diff) |
Keep multiple IOHookProvider references in class ListenSocket
This adds the <bind:hook> config option which works together with <bind:ssl>
Diffstat (limited to 'src')
-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 |
4 files changed, 29 insertions, 9 deletions
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); |