]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_geo_maxmind.cpp
Fix an oversight in mkversions that caused it to not update extras.
[user/henk/code/inspircd.git] / src / modules / extra / m_geo_maxmind.cpp
index f249ecf9154c642daf68cba679e1faa4eec26da2..0d164baa05e0688f7914ca2c052d95a738a8dca5 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ *   Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -19,6 +20,7 @@
 /// $CompilerFlags: find_compiler_flags("libmaxminddb" "")
 /// $LinkerFlags: find_linker_flags("libmaxminddb" "-lmaxminddb")
 
+/// $PackageInfo: require_system("arch") libmaxminddb pkgconf
 /// $PackageInfo: require_system("darwin") libmaxminddb pkg-config
 /// $PackageInfo: require_system("debian" "9.0") libmaxminddb-dev pkg-config
 /// $PackageInfo: require_system("ubuntu" "16.04") libmaxminddb-dev pkg-config
 # pragma comment(lib, "libmaxminddb.lib")
 #endif
 
-#include <maxminddb.h>
 #include "inspircd.h"
 #include "modules/geolocation.h"
+#include <maxminddb.h>
 
-class GeolocationExtItem : public LocalExtItem
+class GeolocationExtItem : public ExtensionItem
 {
  public:
        GeolocationExtItem(Module* parent)
-               : LocalExtItem("geolocation", ExtensionItem::EXT_USER, parent)
+               : ExtensionItem("geolocation", ExtensionItem::EXT_USER, parent)
        {
        }
 
@@ -97,6 +99,10 @@ class GeolocationAPIImpl : public Geolocation::APIBase
 
        Geolocation::Location* GetLocation(irc::sockets::sockaddrs& sa) CXX11_OVERRIDE
        {
+               // Skip trying to look up a UNIX socket.
+               if (sa.family() != AF_INET && sa.family() != AF_INET6)
+                       return NULL;
+
                // Attempt to look up the socket address.
                int result;
                MMDB_lookup_result_s lookup = MMDB_lookup_sockaddr(&mmdb, &sa.sa, &result);
@@ -148,13 +154,13 @@ class ModuleGeoMaxMind : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides Geolocation lookups using the libMaxMindDB library", VF_VENDOR);
+               return Version("Allows the server to perform geolocation lookups on both IP addresses and users.", VF_VENDOR);
        }
 
        void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("maxmind");
-               const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb"));
+               const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb", 1));
 
                // Try to read the new database.
                MMDB_s mmdb;
@@ -173,7 +179,7 @@ class ModuleGeoMaxMind : public Module
        void OnGarbageCollect() CXX11_OVERRIDE
        {
                for (LocationMap::iterator iter = geoapi.locations.begin(); iter != geoapi.locations.end(); )
-               {       
+               {
                        Geolocation::Location* location = iter->second;
                        if (location->GetUseCount())
                        {