Categorygithub.com/containerssh/geoip
modulepackage
1.0.0
Repository: https://github.com/containerssh/geoip.git
Documentation: pkg.go.dev

# README

ContainerSSH - Launch Containers on Demand

ContainerSSH IP to Country Code Library

Go Report Card LGTM Alerts

This library provides IP to Country Code lookup services for ContainerSSH.

⚠⚠⚠ Warning: This is a developer documentation. ⚠⚠⚠
The user documentation for ContainerSSH is located at containerssh.io.

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.Config{
    // Can be "dummy" or "maxmind".
    Provider: "maxmind",
    // MMDB2 file for the MaxMind provider.
    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.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

New creates a new lookup provider based on the configuration.

# Constants

DummyProvider always returns the XX country code.
MaxMindProvider looks up IP addresses via the MaxMind GeoIP database.

# Structs

Config is the structure configuring the GeoIP lookup process.

# Type aliases

Provider is a configuration option to select the GeoIP lookup provider.