ip

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllProviders

func AllProviders() map[string]Provider

AllProviders returns all supported IP providers.

Types

type GoogleIPProvider

type GoogleIPProvider struct {
	Name string
	URL  *url.URL
}

GoogleIPProvider is IP provider.

func NewGoogleIPProvider

func NewGoogleIPProvider() *GoogleIPProvider

NewGoogleIPProvider instantiate an IP provider.

func (GoogleIPProvider) ExtractIP

func (p GoogleIPProvider) ExtractIP(data []byte) (net.IP, error)

ExtractIP extracts IP address from provider data.

func (GoogleIPProvider) GetName

func (p GoogleIPProvider) GetName() string

GetName gets the provider name.

func (GoogleIPProvider) GetURL

func (p GoogleIPProvider) GetURL() *url.URL

GetURL gets the provider url.

type HTTPClient

type HTTPClient interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPClient is an interface for http client.

type IP

type IP struct {
	Client   HTTPClient
	Provider Provider
	Address  net.IP
}

IP is struct for IP address.

func (*IP) Check

func (i *IP) Check() error

Check checks IP address with given provider.

type NotSupported

type NotSupported struct {
	Name string
}

NotSupported errors when a given provider is not supported.

func (*NotSupported) Error

func (e *NotSupported) Error() string

type Provider

type Provider interface {
	ExtractIP(data []byte) (net.IP, error)
	GetName() string
	GetURL() *url.URL
}

Provider is an interface for IP providers.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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