diff options
Diffstat (limited to 'src/modules')
27 files changed, 78 insertions, 97 deletions
diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp index ff6e3c7c2..d2d8f93f8 100644 --- a/src/modules/extra/m_geoip.cpp +++ b/src/modules/extra/m_geoip.cpp @@ -62,23 +62,19 @@ class ModuleGeoIP : public Module } } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { - /* only do lookups on local users */ - if (IS_LOCAL(user)) + const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString()); + if (c) { - const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString()); - if (c) - { - std::map<std::string, std::string>::iterator x = GeoBans.find(c); - if (x != GeoBans.end()) - ServerInstance->Users->QuitUser(user, x->second); - } - else - { - if (banunknown) - ServerInstance->Users->QuitUser(user, "Could not identify your country of origin. Access denied."); - } + std::map<std::string, std::string>::iterator x = GeoBans.find(c); + if (x != GeoBans.end()) + ServerInstance->Users->QuitUser(user, x->second); + } + else + { + if (banunknown) + ServerInstance->Users->QuitUser(user, "Could not identify your country of origin. Access denied."); } return MOD_RES_PASSTHRU; } diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index 50c952704..26e968367 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -111,7 +111,7 @@ public: return true; } - ModResult OnUserRegister(User* user) + ModResult OnUserRegister(LocalUser* user) { if ((!allowpattern.empty()) && (InspIRCd::Match(user->nick,allowpattern))) { @@ -208,7 +208,7 @@ public: } } - ModResult OnCheckReady(User* user) + ModResult OnCheckReady(LocalUser* user) { return ldapAuthed.get(user) ? MOD_RES_PASSTHRU : MOD_RES_DENY; } diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 0267b6595..29e439ed3 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -551,7 +551,7 @@ class ModuleSSLGnuTLS : public Module { // This occurs AFTER OnUserConnect so we can be sure the // protocol module has propagated the NICK message. - if (user->GetIOHook() == this && (IS_LOCAL(user))) + if (user->GetIOHook() == this) { if (sessions[user->GetFd()].sess) { diff --git a/src/modules/m_antibear.cpp b/src/modules/m_antibear.cpp index f4f725ab2..abc4608ff 100644 --- a/src/modules/m_antibear.cpp +++ b/src/modules/m_antibear.cpp @@ -62,7 +62,7 @@ class ModuleAntiBear : public Module return MOD_RES_PASSTHRU; } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { user->WriteNumeric(439, "%s :This server has anti-spambot mechanisms enabled.", user->nick.c_str()); user->WriteNumeric(931, "%s :Malicious bots, spammers, and other automated systems of dubious origin are NOT welcome here.", user->nick.c_str()); diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp index 2c7e58e6a..5c820043c 100644 --- a/src/modules/m_cap.cpp +++ b/src/modules/m_cap.cpp @@ -142,7 +142,7 @@ class ModuleCAP : public Module ServerInstance->Modules->Attach(eventlist, this, 1); } - ModResult OnCheckReady(User* user) + ModResult OnCheckReady(LocalUser* user) { /* Users in CAP state get held until CAP END */ if (cmd.reghold.get(user)) diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 53c761b3e..745dc13d2 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -214,7 +214,7 @@ public: } } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { for(CGIHostlist::iterator iter = cmd.Hosts.begin(); iter != cmd.Hosts.end(); iter++) { @@ -253,7 +253,7 @@ public: return MOD_RES_PASSTHRU; } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { std::string *webirc_hostname = cmd.webirc_hostname.get(user); std::string *webirc_ip = cmd.webirc_ip.get(user); diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index c61868dc3..0ad790de9 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -74,10 +74,10 @@ class CloakUser : public ModeHandler std::string* cloak = ext.get(dest); - if (!cloak) + if (!cloak && IS_LOCAL(dest)) { /* Force creation of missing cloak */ - creator->OnUserConnect(dest); + creator->OnUserConnect(IS_LOCAL(dest)); cloak = ext.get(dest); } if (cloak) @@ -424,7 +424,7 @@ class ModuleCloaking : public Module } } - void OnUserConnect(User* dest) + void OnUserConnect(LocalUser* dest) { std::string* cloak = cu.ext.get(dest); if (cloak) diff --git a/src/modules/m_conn_join.cpp b/src/modules/m_conn_join.cpp index ef834e55a..df575f1b3 100644 --- a/src/modules/m_conn_join.cpp +++ b/src/modules/m_conn_join.cpp @@ -73,11 +73,10 @@ class ModuleConnJoin : public Module return Version("Forces users to join the specified channel(s) on connect", VF_VENDOR); } - virtual void OnPostConnect(User* user) + void OnPostConnect(User* user) { if (!IS_LOCAL(user)) return; - for(std::vector<std::string>::iterator it = Joinchans.begin(); it != Joinchans.end(); it++) if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) Channel::JoinUser(user, it->c_str(), false, "", false, ServerInstance->Time()); diff --git a/src/modules/m_conn_umodes.cpp b/src/modules/m_conn_umodes.cpp index 714114f04..22a4ee0aa 100644 --- a/src/modules/m_conn_umodes.cpp +++ b/src/modules/m_conn_umodes.cpp @@ -35,11 +35,8 @@ class ModuleModesOnConnect : public Module return Version("Sets (and unsets) modes on users when they connect", VF_VENDOR); } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { - if (!IS_LOCAL(user)) - return; - // Backup and zero out the disabled usermodes, so that we can override them here. char save[64]; memcpy(save, ServerInstance->Config->DisabledUModes, diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index 46f4a69eb..362835c6d 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -55,7 +55,7 @@ class ModuleWaitPong : public Module return out; } - ModResult OnUserRegister(User* user) + ModResult OnUserRegister(LocalUser* user) { std::string pingrpl = RandString(); @@ -92,7 +92,7 @@ class ModuleWaitPong : public Module return MOD_RES_PASSTHRU; } - ModResult OnCheckReady(User* user) + ModResult OnCheckReady(LocalUser* user) { return ext.get(user) ? MOD_RES_DENY : MOD_RES_PASSTHRU; } diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index f956cb7db..9506bc2fe 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -66,7 +66,7 @@ class ModuleConnectBan : public Module banduration = ServerInstance->Duration(duration); } - virtual void OnUserConnect(User *u) + virtual void OnUserConnect(LocalUser *u) { int range = 32; clonemap::iterator i; diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index b2aaab45a..d2738fe18 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -57,7 +57,7 @@ public: first = ServerInstance->Time(); } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { time_t next = ServerInstance->Time(); diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index d97ea940a..486a816da 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -46,12 +46,12 @@ class DNSBLConfEntry class DNSBLResolver : public Resolver { int theirfd; - User* them; + LocalUser* them; DNSBLConfEntry *ConfEntry; public: - DNSBLResolver(Module *me, const std::string &hostname, User* u, int userfd, DNSBLConfEntry *conf, bool &cached) + DNSBLResolver(Module *me, const std::string &hostname, LocalUser* u, int userfd, DNSBLConfEntry *conf, bool &cached) : Resolver(hostname, DNS_QUERY_A, cached, me) { theirfd = userfd; @@ -322,42 +322,38 @@ class ModuleDNSBL : public Module ReadConf(); } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { - /* only do lookups on local users */ - if (IS_LOCAL(user)) - { - /* following code taken from bopm, reverses an IP address. */ - struct in_addr in; - unsigned char a, b, c, d; - char reversedipbuf[128]; - std::string reversedip; - bool success; + /* following code taken from bopm, reverses an IP address. */ + struct in_addr in; + unsigned char a, b, c, d; + char reversedipbuf[128]; + std::string reversedip; + bool success; - success = inet_aton(user->GetIPString(), &in); + success = inet_aton(user->GetIPString(), &in); - if (!success) - return MOD_RES_PASSTHRU; + if (!success) + return MOD_RES_PASSTHRU; - d = (unsigned char) (in.s_addr >> 24) & 0xFF; - c = (unsigned char) (in.s_addr >> 16) & 0xFF; - b = (unsigned char) (in.s_addr >> 8) & 0xFF; - a = (unsigned char) in.s_addr & 0xFF; + d = (unsigned char) (in.s_addr >> 24) & 0xFF; + c = (unsigned char) (in.s_addr >> 16) & 0xFF; + b = (unsigned char) (in.s_addr >> 8) & 0xFF; + a = (unsigned char) in.s_addr & 0xFF; - snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a); - reversedip = std::string(reversedipbuf); + snprintf(reversedipbuf, 128, "%d.%d.%d.%d", d, c, b, a); + reversedip = std::string(reversedipbuf); - // For each DNSBL, we will run through this lookup - for (std::vector<DNSBLConfEntry *>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++) - { - // Fill hostname with a dnsbl style host (d.c.b.a.domain.tld) - std::string hostname = reversedip + "." + (*i)->domain; + // For each DNSBL, we will run through this lookup + for (std::vector<DNSBLConfEntry *>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++) + { + // Fill hostname with a dnsbl style host (d.c.b.a.domain.tld) + std::string hostname = reversedip + "." + (*i)->domain; - /* now we'd need to fire off lookups for `hostname'. */ - bool cached; - DNSBLResolver *r = new DNSBLResolver(this, hostname, user, user->GetFd(), *i, cached); - ServerInstance->AddResolver(r, cached); - } + /* now we'd need to fire off lookups for `hostname'. */ + bool cached; + DNSBLResolver *r = new DNSBLResolver(this, hostname, user, user->GetFd(), *i, cached); + ServerInstance->AddResolver(r, cached); } /* don't do anything with this hot potato */ diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 7d998e267..4a067bcac 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -91,9 +91,8 @@ class ModuleHostChange : public Module return Version("Provides masking of user hostnames in a different way to m_cloaking", VF_VENDOR); } - virtual void OnUserConnect(User* iuser) + virtual void OnUserConnect(LocalUser* user) { - LocalUser* user = (LocalUser*)iuser; for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++) { if (((InspIRCd::MatchCIDR(user->MakeHost(), i->first)) || (InspIRCd::MatchCIDR(user->MakeHostIP(), i->first)))) diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 8df849902..fbd7706fe 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -303,7 +303,7 @@ class ModuleIdent : public Module RequestTimeout = 5; } - virtual ModResult OnUserRegister(User *user) + virtual ModResult OnUserRegister(LocalUser *user) { ConfigTag* tag = user->MyClass->config; if (!tag->getBool("useident", true)) @@ -334,7 +334,7 @@ class ModuleIdent : public Module * creating a Timer object and especially better than creating a * Timer per ident lookup! */ - virtual ModResult OnCheckReady(User *user) + virtual ModResult OnCheckReady(LocalUser *user) { /* Does user have an ident socket attached at all? */ IdentRequestSocket *isock = ext.get(user); @@ -389,10 +389,10 @@ class ModuleIdent : public Module { /* Module unloading, tidy up users */ if (target_type == TYPE_USER) - OnUserDisconnect((User*)item); + OnUserDisconnect((LocalUser*)item); } - virtual void OnUserDisconnect(User *user) + virtual void OnUserDisconnect(LocalUser *user) { /* User disconnect (generic socket detatch event) */ IdentRequestSocket *isock = ext.get(user); diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 12e0cfa84..0c7cc4dc7 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -41,10 +41,6 @@ class InvisibleMode : public ModeHandler if (m && adding) m->OnUserQuit(dest, "Connection closed", "Connection closed"); - /* This has to come after setting/unsetting the handler */ - if (m && !adding) - m->OnPostConnect(dest); - /* User appears to vanish or appear from nowhere */ for (UCListIter f = dest->chans.begin(); f != dest->chans.end(); f++) { diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index d46e85bdd..10453818a 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -146,7 +146,7 @@ class ModuleJumpServer : public Module { } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { if (js.port && js.redirect_new_users) { diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp index 100b7864b..58f468c50 100644 --- a/src/modules/m_lockserv.cpp +++ b/src/modules/m_lockserv.cpp @@ -93,7 +93,7 @@ public: ResetLocked(); } - virtual ModResult OnUserRegister(User* user) + virtual ModResult OnUserRegister(LocalUser* user) { if (locked) { @@ -103,7 +103,7 @@ public: return MOD_RES_PASSTHRU; } - virtual ModResult OnCheckReady(User* user) + virtual ModResult OnCheckReady(LocalUser* user) { return locked ? MOD_RES_DENY : MOD_RES_PASSTHRU; } diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp index f6925e974..6c6f060e8 100644 --- a/src/modules/m_randquote.cpp +++ b/src/modules/m_randquote.cpp @@ -97,7 +97,7 @@ class ModuleRandQuote : public Module return Version("Provides random Quotes on Connect.",VF_VENDOR); } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { cmd.Handle(std::vector<std::string>(), user); } diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 63ab0ccbb..87a95a1ff 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -230,7 +230,7 @@ class ModuleRLine : public Module return Version("RLINE: Regexp user banning.", VF_COMMON | VF_VENDOR); } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { // Apply lines on user connect XLine *rl = ServerInstance->XLines->MatchesLine("R", user); diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 8e1a73354..677e930f2 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -237,7 +237,7 @@ class ModuleSASL : public Module ServerInstance->Logs->Log("m_sasl", DEFAULT, "WARNING: m_services_account.so and m_cap.so are not loaded! m_sasl.so will NOT function correctly until these two modules are loaded!"); } - ModResult OnUserRegister(User *user) + ModResult OnUserRegister(LocalUser *user) { SaslAuthenticator *sasl_ = authExt.get(user); if (sasl_) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index d4053fba0..b4adc9300 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -236,7 +236,7 @@ class ModuleShun : public Module affectopers = MyConf.ReadFlag("shun", "affectopers", "no", 0); } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { if (!IS_LOCAL(user)) return; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 3b18874d3..a0acd9b08 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -46,7 +46,7 @@ ModuleSpanningTree::ModuleSpanningTree() { I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostTopicChange, I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, - I_OnChangeLocalUserHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule, + I_OnChangeHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule, I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash, I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnSetAway, I_OnPostCommand, I_OnUserConnect @@ -592,7 +592,7 @@ void ModuleSpanningTree::OnBackgroundTimer(time_t curtime) DoConnectTimeout(curtime); } -void ModuleSpanningTree::OnUserConnect(User* user) +void ModuleSpanningTree::OnUserConnect(LocalUser* user) { if (user->quitting) return; @@ -630,21 +630,19 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created, C } } -ModResult ModuleSpanningTree::OnChangeLocalUserHost(User* user, const std::string &newhost) +void ModuleSpanningTree::OnChangeHost(User* user, const std::string &newhost) { - if (user->registered != REG_ALL) - return MOD_RES_PASSTHRU; + if (user->registered != REG_ALL || !IS_LOCAL(user)) + return; parameterlist params; params.push_back(newhost); Utils->DoOneToMany(user->uuid,"FHOST",params); - return MOD_RES_PASSTHRU; } void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos) { - // only occurs for local clients - if (user->registered != REG_ALL) + if (user->registered != REG_ALL || !IS_LOCAL(user)) return; parameterlist params; diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 692442598..b9d5debb3 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -161,7 +161,7 @@ class ModuleSpanningTree : public Module ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line); void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line); void OnGetServerDescription(const std::string &servername,std::string &description); - void OnUserConnect(User* source); + void OnUserConnect(LocalUser* source); void OnUserInvite(User* source,User* dest,Channel* channel, time_t); void OnPostTopicChange(User* user, Channel* chan, const std::string &topic); void OnWallops(User* user, const std::string &text); @@ -169,7 +169,7 @@ class ModuleSpanningTree : public Module void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list); void OnBackgroundTimer(time_t curtime); void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts); - ModResult OnChangeLocalUserHost(User* user, const std::string &newhost); + void OnChangeHost(User* user, const std::string &newhost); void OnChangeName(User* user, const std::string &gecos); void OnChangeIdent(User* user, const std::string &ident); void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts); diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index 6763e8214..a4c237e4e 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -69,7 +69,7 @@ public: verbose = Conf.ReadFlag("sqlauth", "verbose", 0); /* Set to true if failed connects should be reported to operators */ } - ModResult OnUserRegister(User* user) + ModResult OnUserRegister(LocalUser* user) { if ((!allowpattern.empty()) && (InspIRCd::Match(user->nick,allowpattern))) { @@ -176,7 +176,7 @@ public: } } - ModResult OnCheckReady(User* user) + ModResult OnCheckReady(LocalUser* user) { return sqlAuthed.get(user) ? MOD_RES_PASSTHRU : MOD_RES_DENY; } diff --git a/src/modules/m_sqllog.cpp b/src/modules/m_sqllog.cpp index 6bdcda6cb..8ff12a8d9 100644 --- a/src/modules/m_sqllog.cpp +++ b/src/modules/m_sqllog.cpp @@ -248,7 +248,7 @@ class ModuleSQLLog : public Module return MOD_RES_PASSTHRU; } - virtual void OnUserConnect(User* user) + virtual void OnUserConnect(LocalUser* user) { AddLogEntry(LT_CONNECT,user->nick,user->host,user->server); } diff --git a/src/modules/m_sqlutils.cpp b/src/modules/m_sqlutils.cpp index 28f32ec26..db5a990e1 100644 --- a/src/modules/m_sqlutils.cpp +++ b/src/modules/m_sqlutils.cpp @@ -97,7 +97,7 @@ public: } } - void OnUserDisconnect(User* user) + void OnUserDisconnect(LocalUser* user) { /* A user is disconnecting, first we need to check if they have a list of queries associated with them. * Then, if they do, we need to erase each of them from our IdUserMap (iduser) so when the module that |