diff options
author | Peter Powell <petpow@saberuk.com> | 2019-03-11 00:21:16 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-04-15 19:08:22 +0100 |
commit | 14e1d1f844c89e14cac24799c80af47ed6767cf2 (patch) | |
tree | fd47fc94ecfc1da318c209afb3c3743fc1f76e45 /include/modules | |
parent | 7c8e2990a1cc990f73822e037e1f0866f8aba97e (diff) |
Replace the geoip module with geo_maxmind, geoban, and geoclass.
MaxMind have EOL'd the library that the geoip module uses and have
replaced it with libmaxminddb.
The geoip module has been split into geo_maxmind which provides
geolocation data, geoban which provides location-based channel
bans, and geoclass which is used to filter a user into a connect
class based on location.
Diffstat (limited to 'include/modules')
-rw-r--r-- | include/modules/geolocation.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/include/modules/geolocation.h b/include/modules/geolocation.h new file mode 100644 index 000000000..911a9634d --- /dev/null +++ b/include/modules/geolocation.h @@ -0,0 +1,80 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2019 Peter Powell <petpow@saberuk.com> + * + * 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 + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#pragma once + +namespace Geolocation +{ + class APIBase; + class API; + class Location; +} + +class Geolocation::APIBase : public DataProvider +{ + public: + APIBase(Module* parent) + : DataProvider(parent, "geolocationapi") + { + } + + /** Looks up the location of the specified user. + * @param user The user to look up the location of. + * @return Either an instance of the Location class or NULL if no location could be found. + */ + virtual Location* GetLocation(User* user) = 0; + + /** Looks up the location of the specified IP address. + * @param sa The IP address to look up the location of. + * @return Either an instance of the Location class or NULL if no location could be found. + */ + virtual Location* GetLocation(irc::sockets::sockaddrs& sa) = 0; +}; + +class Geolocation::API : public dynamic_reference<Geolocation::APIBase> +{ + public: + API(Module* parent) + : dynamic_reference<Geolocation::APIBase>(parent, "geolocationapi") + { + } +}; + +class Geolocation::Location : public usecountbase +{ +private: + /** The two character country code for this location. */ + std::string code; + + /** The country name for this location. */ + std::string name; + + public: + Location(const std::string& Code, const std::string& Name) + : code(Code) + , name(Name) + { + } + + /** Retrieves the two character country code for this location. */ + std::string GetCode() const { return code; } + + /** Retrieves the country name for this location. */ + std::string GetName() const { return name; } +}; |