aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_geoban.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-03-24 02:33:59 +0000
committerGravatar Sadie Powell2022-03-25 13:18:45 +0000
commitd9be3ed77fac2601d813b2c85e2d9e1a02d61668 (patch)
treee9de7413e9fa79b724bf0c77bf954b0b272ead1f /src/modules/m_geoban.cpp
parentAllow modules to handle WHO matching. (diff)
Add support for matching against geolocation data with WHO.
Closes #1969.
Diffstat (limited to 'src/modules/m_geoban.cpp')
-rw-r--r--src/modules/m_geoban.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/modules/m_geoban.cpp b/src/modules/m_geoban.cpp
index 7e44ffa1f..1e0e6cd74 100644
--- a/src/modules/m_geoban.cpp
+++ b/src/modules/m_geoban.cpp
@@ -20,10 +20,12 @@
#include "inspircd.h"
#include "modules/geolocation.h"
+#include "modules/who.h"
#include "modules/whois.h"
class ModuleGeoBan
: public Module
+ , public Who::MatchEventListener
, public Whois::EventListener
{
private:
@@ -31,7 +33,8 @@ class ModuleGeoBan
public:
ModuleGeoBan()
- : Whois::EventListener(this)
+ : Who::MatchEventListener(this)
+ , Whois::EventListener(this)
, geoapi(this)
{
}
@@ -60,6 +63,16 @@ class ModuleGeoBan
return MOD_RES_PASSTHRU;
}
+ ModResult OnWhoMatch(const Who::Request& request, LocalUser* source, User* user) CXX11_OVERRIDE
+ {
+ if (!request.flags['G'])
+ return MOD_RES_PASSTHRU;
+
+ Geolocation::Location* location = geoapi ? geoapi->GetLocation(user) : NULL;
+ const std::string code = location ? location->GetCode() : "XX";
+ return InspIRCd::Match(code, request.matchtext, ascii_case_insensitive_map) ? MOD_RES_ALLOW : MOD_RES_DENY;
+ }
+
void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
if (whois.GetTarget()->server->IsULine())