http

package
v0.0.0-...-89564b7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoIPFound  = errors.New("no IP address found")
	ErrTooManyIPs = errors.New("too many IP addresses")
	ErrBanned     = errors.New("we got banned")
)
View Source
var (
	ErrUnknownProvider   = errors.New("unknown public IP echo HTTP provider")
	ErrProviderIPVersion = errors.New("provider does not support IP version")
)

Functions

func ValidateProvider

func ValidateProvider(provider Provider, version ipversion.IPVersion) error

Types

type Fetcher

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

func New

func New(client *http.Client, options ...Option) (f *Fetcher, err error)

func (*Fetcher) IP

func (f *Fetcher) IP(ctx context.Context) (publicIP netip.Addr, err error)

func (*Fetcher) IP4

func (f *Fetcher) IP4(ctx context.Context) (publicIP netip.Addr, err error)

func (*Fetcher) IP6

func (f *Fetcher) IP6(ctx context.Context) (publicIP netip.Addr, err error)

type Option

type Option func(s *settings) error

func SetProvidersIP

func SetProvidersIP(first Provider, providers ...Provider) Option

func SetProvidersIP4

func SetProvidersIP4(first Provider, providers ...Provider) Option

func SetProvidersIP6

func SetProvidersIP6(first Provider, providers ...Provider) Option

func SetTimeout

func SetTimeout(timeout time.Duration) Option

type Provider

type Provider string
const (
	Ifconfig  Provider = "ifconfig"
	Ipify     Provider = "ipify"
	Ipinfo    Provider = "ipinfo"
	Spdyn     Provider = "spdyn"
	Ipleak    Provider = "ipleak"
	Icanhazip Provider = "icanhazip"
	Ident     Provider = "ident"
	Nnev      Provider = "nnev"
	Wtfismyip Provider = "wtfismyip"
	Seeip     Provider = "seeip"
	Changeip  Provider = "changeip"
)

func CustomProvider

func CustomProvider(httpsURL *url.URL) Provider

CustomProvider creates a provider with a custom HTTP(s) URL. It is the responsibility of the caller to make sure it is a valid URL and that it supports the desired IP version(s) as no further check is done on it.

func ListProviders

func ListProviders() []Provider

func ListProvidersForVersion

func ListProvidersForVersion(version ipversion.IPVersion) (providers []Provider)

func (Provider) SupportsVersion

func (provider Provider) SupportsVersion(version ipversion.IPVersion) bool

Jump to

Keyboard shortcuts

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