summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4d36019)
This adds the <bind:hook> config option which works together with <bind:ssl>
/** Human-readable bind description */
std::string bind_desc;
/** 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
*/
/** Create a new listening socket
*/
#ifndef _WIN32
#include <netinet/tcp.h>
#ifndef _WIN32
#include <netinet/tcp.h>
ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_to)
: bind_tag(tag)
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();
{
irc::sockets::satoap(bind_to, bind_addr, bind_port);
bind_desc = bind_to.str();
void ListenSocket::ResetIOHookProvider()
{
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/");
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);
{
ServerInstance->Timers.AddTimer(this);
{
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);
capab = new CapabData;
capab->capab_phase = 0;
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);
SendCapabilities(1);
Utils->timeoutlist[this] = std::pair<std::string, int>(linkID, 30);
UserIOHandler* eh = &New->eh;
// If this listener has an IO hook provider set then tell it about the connection
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);
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New user fd: %d", socket);