From fdeccd7dd366ebac516ed66841fbf7f0952d8ed2 Mon Sep 17 00:00:00 2001 From: genius3000 Date: Fri, 30 Mar 2018 10:08:22 -0600 Subject: Update the GeoIP ExtItem when CGI:IRC sets the real IP (#1471) Since CGI:IRC calls it's 'ChangeIP()' either from 'OnCheckReady()' or 'OnUserRegister()', both of which are called after the user has sent NICK/USER, we can safely skip re-setting the ExtItem prior to this point. This skips the first 'OnSetUserIP()' from 'User::AddUser()' as the 'OnSetConnectClass()' catch handles the initial setting. --- src/modules/extra/m_geoip.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/modules/extra') diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp index a36c39bc8..03b7a55f7 100644 --- a/src/modules/extra/m_geoip.cpp +++ b/src/modules/extra/m_geoip.cpp @@ -58,7 +58,7 @@ class ModuleGeoIP : public Module throw ModuleException("Unable to initialize geoip, are you missing GeoIP.dat?"); ServerInstance->Modules->AddService(ext); - Implementation eventlist[] = { I_OnSetConnectClass, I_OnStats }; + Implementation eventlist[] = { I_OnSetConnectClass, I_OnSetUserIP, I_OnStats }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i) @@ -99,6 +99,13 @@ class ModuleGeoIP : public Module return MOD_RES_DENY; } + void OnSetUserIP(LocalUser* user) + { + // If user has sent NICK/USER, re-set the ExtItem as this is likely CGI:IRC changing the IP + if (user->registered == REG_NICKUSER) + SetExt(user); + } + ModResult OnStats(char symbol, User* user, string_list &out) { if (symbol != 'G') -- cgit v1.2.3