resolve

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIPForURL

func FormatIPForURL(ip string) string

FormatIPForURL basically puts brackets [] around the IP if it is IPv6

Types

type IPResolver

type IPResolver interface {
	Resolve() string
}

IPResolver resolves an IPAddresse

type LocalIPResolver

type LocalIPResolver struct {
}

LocalIPResolver resolves to a local ip addresse. Defaults to 127.0.0.1. Zero value is usable.

func (*LocalIPResolver) Resolve

func (l *LocalIPResolver) Resolve() string

Resolve resolves to the first local non loopback addresse it finds. Defaults to 127.0.0.1

type PublicIPResolver

type PublicIPResolver struct {
	Fallback IPResolver
}

PublicIPResolver resolves the public ip by querying another server. If an error occurs the Fallback resolver is used. Zero value is *not* usable.

func NewPublicIPResolver

func NewPublicIPResolver(fallback IPResolver) *PublicIPResolver

NewPublicIPResolver creaes a new PublicIpResolver. fallback must not be null.

func (*PublicIPResolver) Resolve

func (p *PublicIPResolver) Resolve() string

Resolve gets your public ip from a remote server. Defaults to fallback resolver on errors

Jump to

Keyboard shortcuts

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