diff options
-rw-r--r-- | data/example.conf | 28 | ||||
-rw-r--r-- | data/nickserv.example.conf | 35 | ||||
-rw-r--r-- | modules/commands/ns_group.cpp | 4 | ||||
-rw-r--r-- | modules/commands/ns_recover.cpp | 2 | ||||
-rw-r--r-- | modules/commands/ns_register.cpp | 6 | ||||
-rw-r--r-- | modules/commands/ns_set.cpp | 8 | ||||
-rw-r--r-- | modules/database/db_sql_live.cpp | 2 | ||||
-rw-r--r-- | modules/pseudoclients/nickserv.cpp | 24 | ||||
-rw-r--r-- | src/config.cpp | 9 | ||||
-rw-r--r-- | src/main.cpp | 4 |
10 files changed, 60 insertions, 62 deletions
diff --git a/data/example.conf b/data/example.conf index c038d22f6..68a3a6583 100644 --- a/data/example.conf +++ b/data/example.conf @@ -393,11 +393,6 @@ options casemap = "ascii" /* - * The maximum length of passwords - */ - passlen = 32 - - /* * This key is used to initiate the random number generator. This number * MUST be random as you want your passcodes to be random. Don't give this * key to anyone! Keep it private! @@ -531,11 +526,6 @@ options */ hideprivilegedcommands = yes - /* - * If set, Services do not allow ownership of nick names, only ownership of accounts. - */ - nonicknameownership = no - /* The regex engine to use, as provided by the regex modules. * Leave commented to disable regex matching. * @@ -557,24 +547,6 @@ options * Leave empty to default to English. */ #defaultlanguage = "es_ES.UTF-8" - - /* - * The username, and possibly hostname, used for fake users created when Services needs to - * hold a nickname. - */ - enforceruser = "enforcer" - enforcerhost = "localhost.net" - - /* - * The length of time Services hold nicknames. - */ - releasetimeout = 1m - - /* - * When a user's nick is forcibly changed to enforce a "nick kill", their new nick will start - * with this value. The rest will be made up of 6 or 7 digits. - */ - guestnickprefix = "Guest" } /* diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index e3afd1607..3e5e6b4d8 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -174,6 +174,41 @@ module * This directive is optional. */ #restrictopernicks = yes + + /* + * The username, and possibly hostname, used for fake users created when Services needs to + * hold a nickname. + */ + enforceruser = "enforcer" + enforcerhost = "services.host" + + /* + * The length of time Services hold nicknames. + * + * This directive is optional, but recommended. If not set it defaults to 1 minute. + */ + releasetimeout = 1m + + /* + * When a user's nick is forcibly changed to enforce a "nick kill", their new nick will start + * with this value. The rest will be made up of 6 or 7 digits. + * Make sure this is a valid nick and Nicklen+7 is not longer than the allowed Nicklen on your ircd. + * + * This directive is optional. If not set it defaults to "Guest" + */ + guestnickprefix = "Guest" + + /* + * If set, Services do not allow ownership of nick names, only ownership of accounts. + */ + nonicknameownership = no + + /* + * The maximum length of passwords + * + * This directive is optional. If not set it defaults to 32. + */ + passlen = 32 } /* diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 81daddf84..c40b5bf89 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -111,7 +111,7 @@ class CommandNSGroup : public Command } NickAlias *target, *na = NickAlias::Find(u->nick); - const Anope::string &guestnick = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix"); + const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest"); time_t reg_delay = Config->GetModule("nickserv")->Get<time_t>("regdelay"); unsigned maxaliases = Config->GetModule(this->owner)->Get<unsigned>("maxaliases"); if (!(target = NickAlias::Find(nick))) @@ -349,7 +349,7 @@ class NSGroup : public Module NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsgroup(this), commandnsungroup(this), commandnsglist(this) { - if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index b6cbe2621..5d66b1ad5 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -208,7 +208,7 @@ class NSRecover : public Module commandnsrecover(this), recover(this, "recover") { - if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 7fd19b9d9..c7e50311d 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -56,7 +56,7 @@ class CommandNSConfirm : public Command { IRCD->SendLogin(source.GetUser()); const NickAlias *na = NickAlias::Find(source.GetNick()); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na != NULL && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED")) + if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && na != NULL && na->nc == source.GetAccount() && !na->nc->HasExt("UNCONFIRMED")) source.GetUser()->SetMode(source.service, "REGISTERED"); } } @@ -147,7 +147,7 @@ class CommandNSRegister : public Command /* Guest nick can now have a series of between 1 and 7 digits. * --lara */ - const Anope::string &guestnick = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix"); + const Anope::string &guestnick = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest"); if (nicklen <= guestnick.length() + 7 && nicklen >= guestnick.length() + 1 && !u_nick.find_ci(guestnick) && u_nick.substr(guestnick.length()).find_first_not_of("1234567890") == Anope::string::npos) { source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); @@ -180,7 +180,7 @@ class CommandNSRegister : public Command source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str()); else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5)) source.Reply(MORE_OBSCURE_PASSWORD); - else if (pass.length() > Config->GetBlock("options")->Get<unsigned>("passlen")) + else if (pass.length() > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32")) source.Reply(PASSWORD_TOO_LONG); else if (!email.empty() && !Mail::Validate(email)) source.Reply(MAIL_X_INVALID, email.c_str()); diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 770951b8e..a1e37e15e 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -133,7 +133,7 @@ class CommandNSSetPassword : public Command source.Reply(MORE_OBSCURE_PASSWORD); return; } - else if (len > Config->GetBlock("options")->Get<unsigned>("passlen")) + else if (len > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32")) { source.Reply(PASSWORD_TOO_LONG); return; @@ -196,7 +196,7 @@ class CommandNSSASetPassword : public Command source.Reply(MORE_OBSCURE_PASSWORD); return; } - else if (len > Config->GetBlock("options")->Get<unsigned>("passlen")) + else if (len > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32")) { source.Reply(PASSWORD_TOO_LONG); return; @@ -332,7 +332,7 @@ class CommandNSSetDisplay : public Command const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); - if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; @@ -635,7 +635,7 @@ class CommandNSSetKill : public Command return; } - if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) { source.Reply(_("This command may not be used on this network because nickname ownership is disabled.")); return; diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index f74933b98..b9b8ef57c 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -27,7 +27,7 @@ class DBMySQL : public Module, public Pipe } else { - if (Anope::CurTime - Config->GetBlock("options")->Get<time_t>("updatetimeout") > lastwarn) + if (Anope::CurTime - Config->GetBlock("options")->Get<time_t>("updatetimeout", "5m") > lastwarn) { Log() << "Unable to locate SQL reference, going to readonly..."; Anope::ReadOnly = this->ro = true; diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index b83ae8157..652f91a88 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -64,8 +64,8 @@ class NickServRelease : public User, public Timer Anope::string nick; public: - NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetBlock("options")->Get<const Anope::string>("enforceruser"), - Config->GetBlock("options")->Get<const Anope::string>("enforcerhost"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve(), NULL), Timer(delay), nick(na->nick) + NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetModule("nickserv")->Get<const Anope::string>("enforceruser"), + Config->GetModule("nickserv")->Get<const Anope::string>("enforcerhost"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve(), NULL), Timer(delay), nick(na->nick) { /* Erase the current release timer and use the new one */ std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick); @@ -104,12 +104,12 @@ class NickServCore : public Module, public NickServService { collided.Unset(na); - new NickServHeld(na, Config->GetBlock("options")->Get<time_t>("releasetimeout")); + new NickServHeld(na, Config->GetModule("nickserv")->Get<time_t>("releasetimeout", "1m")); if (IRCD->CanSVSHold) - IRCD->SendSVSHold(na->nick, Config->GetBlock("options")->Get<time_t>("releasetimeout")); + IRCD->SendSVSHold(na->nick, Config->GetModule("nickserv")->Get<time_t>("releasetimeout", "1m")); else - new NickServRelease(na, Config->GetBlock("options")->Get<time_t>("releasetimeout")); + new NickServRelease(na, Config->GetModule("nickserv")->Get<time_t>("releasetimeout", "1m")); } } @@ -160,7 +160,7 @@ class NickServCore : public Module, public NickServService return; } - if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) return; bool on_access = u->IsRecognized(false); @@ -198,7 +198,7 @@ class NickServCore : public Module, public NickServService void OnUserLogin(User *u) anope_override { NickAlias *na = NickAlias::Find(u->nick); - if (na && *na->nc == u->Account() && !Config->GetBlock("options")->Get<bool>("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) + if (na && *na->nc == u->Account() && !Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); } @@ -209,8 +209,8 @@ class NickServCore : public Module, public NickServService if (IRCD->CanSVSNick) { - const Anope::string &guestprefix = Config->GetBlock("options")->Get<const Anope::string>("guestnickprefix"); - + const Anope::string &guestprefix = Config->GetModule("nickserv")->Get<const Anope::string>("guestnickprefix", "Guest"); + Anope::string guestnick; int i = 0; @@ -360,7 +360,7 @@ class NickServCore : public Module, public NickServService const NickAlias *na = NickAlias::Find(u->nick); const Anope::string &unregistered_notice = Config->GetModule(this)->Get<const Anope::string>("unregistered_notice"); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na) + if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na) u->SendMessage(NickServ, unregistered_notice); else if (na && !u->IsIdentified(true)) this->Validate(u); @@ -404,7 +404,7 @@ class NickServCore : public Module, public NickServService { /* Reset +r and re-send account (even though it really should be set at this point) */ IRCD->SendLogin(u); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && !na->nc->HasExt("UNCONFIRMED")) + if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && na->nc == u->Account() && !na->nc->HasExt("UNCONFIRMED")) u->SetMode(NickServ, "REGISTERED"); Log(NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->display; } @@ -423,7 +423,7 @@ class NickServCore : public Module, public NickServService { if (!params.empty() || source.c || source.service != *NickServ) return EVENT_CONTINUE; - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership")) + if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) source.Reply(_("\002%s\002 allows you to register a nickname and\n" "prevent others from using it. The following\n" "commands allow for registration and maintenance of\n" diff --git a/src/config.cpp b/src/config.cpp index 40bfc0613..f3931571f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -155,7 +155,6 @@ Conf::Conf() : Block("") {"networkinfo", "userlen"}, {"networkinfo", "hostlen"}, {"networkinfo", "chanlen"}, - {"options", "passlen"}, }; for (unsigned i = 0; i < sizeof(noreload) / sizeof(noreload[0]); ++i) @@ -171,16 +170,8 @@ Conf::Conf() : Block("") ValidateNotEmpty("serverinfo", "pid", serverinfo->Get<const Anope::string>("pid")); ValidateNotEmpty("serverinfo", "motd", serverinfo->Get<const Anope::string>("motd")); - ValidateNotZero("options", "releasetimeout", options->Get<time_t>("releasetimeout")); - ValidateNotZero("options", "updatetimeout", options->Get<time_t>("updatetimeout")); - ValidateNotZero("options", "expiretimeout", options->Get<time_t>("expiretimeout")); ValidateNotZero("options", "readtimeout", options->Get<time_t>("readtimeout")); ValidateNotZero("options", "warningtimeout", options->Get<time_t>("warningtimeout")); - ValidateNotZero("options", "passlen", options->Get<time_t>("passlen")); - - ValidateNotEmpty("options", "enforceruser", options->Get<const Anope::string>("enforceruser")); - ValidateNotEmpty("options", "enforcerhost", options->Get<const Anope::string>("enforcerhost")); - ValidateNotEmpty("options", "guestnickprefix", options->Get<const Anope::string>("guestnickprefix")); ValidateNotZero("networkinfo", "nicklen", networkinfo->Get<unsigned>("nicklen")); ValidateNotZero("networkinfo", "userlen", networkinfo->Get<unsigned>("userlen")); diff --git a/src/main.cpp b/src/main.cpp index d799d9a21..beeacdc05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,8 +157,8 @@ int main(int ac, char **av, char **envp) /* Set up timers */ time_t last_check = Anope::CurTime; - UpdateTimer updateTimer(Config->GetBlock("options")->Get<time_t>("updatetimeout")); - ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout")); + UpdateTimer updateTimer(Config->GetBlock("options")->Get<time_t>("updatetimeout", "5m")); + ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout", "30m")); /*** Main loop. ***/ while (!Anope::Quitting) |