Releases: ContainerSSH/geoip
1.0.0: First stable version
This release tags the first stable version for ContainerSSH 0.4.0.
0.9.4: Added Validate
This release adds a Validate()
method to the configuration structure.
0.9.3: Shorter config name
This change renames the Configuration
struct to Config
for brevity.
0.9.1: Better usage
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
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.