ipfsgeoip

package module
v0.0.0-...-8a8f947 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

README

go-ipfs-geoip

Build Status Go Reference

Geoip lookup over ipfs

This is a Go implementation of ipfs-geoip.

Best suited for use with an ipld.DAGService, as provided by ipfs-lite.

Currently only IPv4 lookups are supported. The author does not maintain the database, which has been made available via IPFS.

For an example, see ipfsgeoip_test.go.

License

Apache 2.0

Documentation

Overview

Package ipfsgeoip provides geoip information lookup using an IPFS-hosted GeoLite2 database. The database is split to allow efficient lookups and it does not need to be fully downloaded for every lookup.

This package is a fork of ipfs-geoip (Javascript).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeoIPInfo

type GeoIPInfo struct {
	CountryName string
	CountryCode string
	RegionCode  string
	City        string
	PostalCode  string
	Latitude    float64
	Longitude   float64
}

GeoIPInfo provides geographical information about an IP address.

func (*GeoIPInfo) UnmarshalJSON

func (gipi *GeoIPInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes geoip-information objects as they are stored in the database.

type IPLocator

type IPLocator struct {
	// contains filtered or unexported fields
}

IPLocator obtains geo information for IP addresses by using a GeoLite2 database hosted on IPFS.

func NewIPLocator

func NewIPLocator(ng format.NodeGetter) *IPLocator

NewIPLocator returns an IPLocator that uses the given NodeGetter.

func (*IPLocator) Lookup

func (l *IPLocator) Lookup(ctx context.Context, addr string) (GeoIPInfo, error)

Lookup provides GeoIP information for a given address in string form. Only IPv4 addresses are supported.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL