diff options
| author | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
| commit | 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch) | |
| tree | 4486f0784bdf050fd7eb225c0cb9df352ce1f45a /modules/extra/m_proxyscan.cpp | |
| parent | 781defb7076ddfddf723ca08cd0a518b6657b64f (diff) | |
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'modules/extra/m_proxyscan.cpp')
| -rw-r--r-- | modules/extra/m_proxyscan.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index 9dd3f8884..c77f0f9cd 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -86,7 +86,7 @@ class ProxyConnect : public ConnectionSocket reason = reason.replace_all_cs("%p", stringify(this->conaddr.port())); Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")"; - XLine *x = new XLine("*@" + this->conaddr.addr(), Config->OperServ, Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); + XLine *x = new XLine("*@" + this->conaddr.addr(), OperServ ? OperServ->nick : "", Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); if (add_to_akill && akills) { akills->AddXLine(x); @@ -253,34 +253,36 @@ class ModuleProxyScan : public Module delete this->listener; } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - Anope::string s_target_ip = reader.ReadValue("m_proxyscan", "target_ip", "", 0); + Configuration::Block *config = Config->GetModule(this); + + Anope::string s_target_ip = config->Get<const Anope::string &>("target_ip"); if (s_target_ip.empty()) - throw ConfigException("m_proxyscan:target_ip may not be empty"); + throw ConfigException(this->name + " target_ip may not be empty"); - int s_target_port = reader.ReadInteger("m_proxyscan", "target_port", "-1", 0, true); + int s_target_port = config->Get<int>("target_port", "-1"); if (s_target_port <= 0) - throw ConfigException("m_proxyscan:target_port may not be empty and must be a positive number"); + throw ConfigException(this->name + " target_port may not be empty and must be a positive number"); - Anope::string s_listen_ip = reader.ReadValue("m_proxyscan", "listen_ip", "", 0); + Anope::string s_listen_ip = config->Get<const Anope::string &>("listen_ip"); if (s_listen_ip.empty()) - throw ConfigException("m_proxyscan:listen_ip may not be empty"); + throw ConfigException(this->name + " listen_ip may not be empty"); - int s_listen_port = reader.ReadInteger("m_proxyscan", "listen_port", "-1", 0, true); + int s_listen_port = config->Get<int>("listen_port", "-1"); if (s_listen_port <= 0) - throw ConfigException("m_proxyscan:listen_port may not be empty and must be a positive number"); + throw ConfigException(this->name + " listen_port may not be empty and must be a positive number"); target_ip = s_target_ip; target_port = s_target_port; this->listen_ip = s_listen_ip; this->listen_port = s_listen_port; - this->con_notice = reader.ReadValue("m_proxyscan", "connect_notice", "", 0); - this->con_source = reader.ReadValue("m_proxyscan", "connect_source", "", 0); - add_to_akill = reader.ReadFlag("m_proxyscan", "add_to_akill", "true", 0); - this->connectionTimeout.SetSecs(reader.ReadInteger("m_proxyscan", "timeout", "5", 0, true)); + this->con_notice = config->Get<const Anope::string &>("connect_notice"); + this->con_source = config->Get<const Anope::string &>("connect_source"); + add_to_akill = config->Get<bool>("add_to_akill", "true"); + this->connectionTimeout.SetSecs(config->Get<time_t>("timeout", "5s")); - ProxyCheckString = Config->NetworkName + " proxy check"; + ProxyCheckString = Config->GetBlock("networkinfo")->Get<const Anope::string &>("networkname") + " proxy check"; delete this->listener; this->listener = NULL; try @@ -293,12 +295,13 @@ class ModuleProxyScan : public Module } this->proxyscans.clear(); - for (int i = 0; i < reader.Enumerate("proxyscan"); ++i) + for (int i = 0; i < conf->CountBlock("proxyscan"); ++i) { + Configuration::Block *block = conf->GetBlock("proxyscan", i); ProxyCheck p; Anope::string token; - commasepstream sep(reader.ReadValue("proxyscan", "type", "", i)); + commasepstream sep(block->Get<const Anope::string &>("type")); while (sep.GetToken(token)) { if (!token.equals_ci("HTTP") && !token.equals_ci("SOCKS5")) @@ -308,7 +311,7 @@ class ModuleProxyScan : public Module if (p.types.empty()) continue; - commasepstream sep2(reader.ReadValue("proxyscan", "port", "", i)); + commasepstream sep2(block->Get<const Anope::string &>("port")); while (sep2.GetToken(token)) { try @@ -321,8 +324,8 @@ class ModuleProxyScan : public Module if (p.ports.empty()) continue; - p.duration = Anope::DoTime(reader.ReadValue("proxyscan", "time", "4h", i)); - p.reason = reader.ReadValue("proxyscan", "reason", "", i); + p.duration = block->Get<time_t>("time", "4h"); + p.reason = block->Get<const Anope::string &>("reason"); if (p.reason.empty()) continue; |
