GeoIp.Plugin

Assembly: GeoIp.Plugin

Description

The GeoIp plugin module provides access to GeoIp data from a number of sources by implementing the IGeoIpDataService interface. Currently it supports the following GeoIp providers:

IpStack

IpStack offers a free web based API to obtain GeoIp data for a given Ip Address. Please see IpStackSettings for details on providing

WebNet77

WebNet77 offers a free Web Service maintained by Webnet77 and updated daily. It represents over 4 billion IPV4 numbers as well as the virtually inexhaustible IPV6 range.

Settings

Settings to select the provider and individual provider settings are available using the GeoIpPluginSettings class.

How to use

The GeoIp plugin will be loaded by the plugin manager if it is used, otherwise you can manually add the GeoIp service as follows:

services.UseGeoIpService();

Useage

if (LoadGeoIpService() && 
    _geoIpInstance.GetIPAddressDetails(e.IPAddress, out string countryCodeout string region, 
        out string cityNameout decimal latitudeout decimal longitudeout long ipUniqueId))
{
    e.IPUniqueID = ipUniqueId;
    e.Latitude = latitude;
    e.Longitude = longitude;
    e.CityName = cityName;
    e.CountryCode = countryCode;
    e.Region = region;
}
else
{
    e.CountryCode = "ZZ";
    e.CityName = "Unknown";
    e.Region = String.Empty;
    e.Latitude = 0;
    e.Longitude = 0;
}