namespace
{
- std::set<FlashPDSocket*> sockets;
+ insp::intrusive_list<FlashPDSocket> sockets;
std::string policy_reply;
const std::string expected_request("<policy-file-request/>\0", 23);
}
-class FlashPDSocket : public BufferedSocket, public Timer
+class FlashPDSocket : public BufferedSocket, public Timer, public insp::intrusive_list_node<FlashPDSocket>
{
/** True if this object is in the cull list
*/
public:
ModResult OnAcceptConnection(int nfd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE
{
- if (from->bind_tag->getString("type") != "flashpolicyd")
+ if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "flashpolicyd"))
return MOD_RES_PASSTHRU;
if (policy_reply.empty())
return MOD_RES_DENY;
- sockets.insert(new FlashPDSocket(nfd, timeout));
+ sockets.push_front(new FlashPDSocket(nfd, timeout));
return MOD_RES_ALLOW;
}
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("flashpolicyd");
- timeout = tag->getInt("timeout", 5, 1);
std::string file = tag->getString("file");
if (!file.empty())
}
catch (CoreException&)
{
- const std::string error_message = "A file was specified for FlashPD, but it could not be loaded.";
- ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, error_message);
- ServerInstance->SNO->WriteGlobalSno('a', error_message);
- policy_reply.clear();
+ throw ModuleException("A file was specified for FlashPD, but it could not be loaded at " + tag->getTagLocation());
}
return;
}
for (std::vector<ListenSocket*>::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i)
{
ListenSocket* ls = *i;
- if (ls->bind_tag->getString("type", "clients") != "clients" || ls->bind_tag->getString("ssl", "plaintext") != "plaintext")
+ if (!stdalgo::string::equalsci(ls->bind_tag->getString("type", "clients"), "clients") || !ls->bind_tag->getString("ssl").empty())
continue;
- to_ports.append(ConvToStr(ls->bind_port)).push_back(',');
+ to_ports.append(ConvToStr(ls->bind_sa.port())).push_back(',');
}
if (to_ports.empty())
<site-control permitted-cross-domain-policies=\"master-only\"/>\
<allow-access-from domain=\"*\" to-ports=\"" + to_ports + "\" />\
</cross-domain-policy>";
+ timeout = tag->getDuration("timeout", 5, 1);
}
- CullResult cull()
+ CullResult cull() CXX11_OVERRIDE
{
- for (std::set<FlashPDSocket*>::const_iterator i = sockets.begin(); i != sockets.end(); ++i)
+ for (insp::intrusive_list<FlashPDSocket>::const_iterator i = sockets.begin(); i != sockets.end(); ++i)
{
FlashPDSocket* sock = *i;
sock->AddToCull();