void OnReload(Configuration::Conf *config) override { Configuration::Block *conf = config->GetModule(this); for (std::map<Anope::string, LDAPService *>::iterator it = this->LDAPServices.begin(); it != this->LDAPServices.end();) { const Anope::string &cname = it->first; LDAPService *s = it->second; int i; ++it; for (i = 0; i < conf->CountBlock("ldap"); ++i) if (conf->GetBlock("ldap", i)->Get<Anope::string>("name", "ldap/main") == cname) break; if (i == conf->CountBlock("ldap")) { logger.Log("Removing server connection {0}", cname); s->SetExitState(); s->Wakeup(); s->Join(); delete s; this->LDAPServices.erase(cname); } } for (int i = 0; i < conf->CountBlock("ldap"); ++i) { Configuration::Block *ldap = conf->GetBlock("ldap", i); const Anope::string &connname = ldap->Get<Anope::string>("name", "ldap/main"); if (this->LDAPServices.find(connname) == this->LDAPServices.end()) { const Anope::string &server = ldap->Get<Anope::string>("server", "127.0.0.1"); const Anope::string &admin_binddn = ldap->Get<Anope::string>("admin_binddn"); const Anope::string &admin_password = ldap->Get<Anope::string>("admin_password"); try { LDAPService *ss = new LDAPService(this, connname, server, admin_binddn, admin_password); ss->Start(); this->LDAPServices.insert(std::make_pair(connname, ss)); logger.Log("Successfully initialized server {0} ({1})", connname, server); } catch (const LDAPException &ex) { logger.Log(ex.GetReason()); } } } }
void OnReload(Configuration::Conf *conf) override { Configuration::Block *config = conf->GetModule(this); for (std::map<Anope::string, MySQLService *>::iterator it = this->MySQLServices.begin(); it != this->MySQLServices.end();) { const Anope::string &cname = it->first; MySQLService *s = it->second; int i; ++it; for (i = 0; i < config->CountBlock("mysql"); ++i) if (config->GetBlock("mysql", i)->Get<Anope::string>("name", "mysql/main") == cname) break; if (i == config->CountBlock("mysql")) { Log(LOG_NORMAL, "mysql") << "MySQL: Removing server connection " << cname; delete s; this->MySQLServices.erase(cname); } } for (int i = 0; i < config->CountBlock("mysql"); ++i) { Configuration::Block *block = config->GetBlock("mysql", i); const Anope::string &connname = block->Get<Anope::string>("name", "mysql/main"); if (this->MySQLServices.find(connname) == this->MySQLServices.end()) { const Anope::string &database = block->Get<Anope::string>("database", "anope"); const Anope::string &server = block->Get<Anope::string>("server", "127.0.0.1"); const Anope::string &user = block->Get<Anope::string>("username", "anope"); const Anope::string &password = block->Get<Anope::string>("password"); int port = block->Get<int>("port", "3306"); try { MySQLService *ss = new MySQLService(this, connname, database, server, user, password, port); this->MySQLServices.insert(std::make_pair(connname, ss)); Log(LOG_NORMAL, "mysql") << "MySQL: Successfully connected to server " << connname << " (" << server << ")"; } catch (const SQL::Exception &ex) { Log(LOG_NORMAL, "mysql") << "MySQL: " << ex.GetReason(); } } } }
void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); std::vector<Anope::string> new_services; for (int i = 0; i < block->CountBlock("redis"); ++i) { Configuration::Block *redis = block->GetBlock("redis", i); const Anope::string &n = redis->Get<Anope::string>("name"), &ip = redis->Get<Anope::string>("ip"); int port = redis->Get<int>("port"); unsigned db = redis->Get<unsigned>("db"); delete services[n]; services[n] = new MyRedisService(this, n, ip, port, db); new_services.push_back(n); } for (std::map<Anope::string, MyRedisService *>::iterator it = services.begin(); it != services.end();) { Provider *p = it->second; ++it; if (std::find(new_services.begin(), new_services.end(), p->name) == new_services.end()) delete it->second; } }
void OnReload(Configuration::Conf *conf) override { Configuration::Block *config = conf->GetModule(this); for (std::map<Anope::string, SQLiteService *>::iterator it = this->SQLiteServices.begin(); it != this->SQLiteServices.end();) { const Anope::string &cname = it->first; SQLiteService *s = it->second; int i, num; ++it; for (i = 0, num = config->CountBlock("sqlite"); i < num; ++i) if (config->GetBlock("sqlite", i)->Get<Anope::string>("name", "sqlite/main") == cname) break; if (i == num) { Log(LOG_NORMAL, "sqlite") << "SQLite: Removing server connection " << cname; delete s; this->SQLiteServices.erase(cname); } } for (int i = 0; i < config->CountBlock("sqlite"); ++i) { Configuration::Block *block = config->GetBlock("sqlite", i); Anope::string connname = block->Get<Anope::string>("name", "sqlite/main"); if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) { Anope::string database = Anope::DataDir + "/" + block->Get<Anope::string>("database", "anope"); try { SQLiteService *ss = new SQLiteService(this, connname, database); this->SQLiteServices[connname] = ss; Log(LOG_NORMAL, "sqlite") << "SQLite: Successfully added database " << database; } catch (const SQL::Exception &ex) { Log(LOG_NORMAL, "sqlite") << "SQLite: " << ex.GetReason(); } } } }
void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); defaults.clear(); for (int i = 0; i < block->CountBlock("default"); ++i) { Configuration::Block *def = block->GetBlock("default", i); LogDefault ld; ld.service = def->Get<Anope::string>("service"); ld.command = def->Get<Anope::string>("command"); ld.method = def->Get<Anope::string>("method"); defaults.push_back(ld); } }