Skip to content
This repository has been archived by the owner on Oct 2, 2022. It is now read-only.

Releases: ContainerSSH/geoip

1.0.0: First stable version

01 Apr 13:59
Compare
Choose a tag to compare

This release tags the first stable version for ContainerSSH 0.4.0.

0.9.4: Added Validate

30 Dec 00:18
Compare
Choose a tag to compare
0.9.4: Added Validate Pre-release
Pre-release

This release adds a Validate() method to the configuration structure.

0.9.3: Shorter config name

24 Nov 08:52
Compare
Choose a tag to compare
Pre-release

This change renames the Configuration struct to Config for brevity.

0.9.1: Better usage

17 Nov 22:45
Compare
Choose a tag to compare
0.9.1: Better usage Pre-release
Pre-release

This release moves the New() method to the geoipprovider package and the LookupProvider interface to the geoip package for easier usage.

0.9.0: Initial Release

17 Nov 22:44
Compare
Choose a tag to compare
Pre-release

This is the initial release.

Using this library

This library needs a configuration structure described in config.go. This configuration structure can be passed to the geoip.New() method:

provider, err := geoip.New(geoip.Configuration{
    provider: "maxmind",
    GeoIP2File: "/path/to/maxmind/file.mmdb2",
})
if err != nil {
    // handle error
}

The GeoIP lookup can be performed using the Lookup() method:

countryCode := provider.Lookup("127.0.0.1")

The countryCode field will contain the value of XX if the lookup failed.

Implementing a lookup provider

A custom provider can be written by implementing the following interface:

type LookupProvider interface {
	Lookup(remoteAddr net.IP) (countryCode string)
}

Once implemented you will need to add the necessary configuration options to config.go and add a factory
method to factory.go.