dynamicip

package
v1.7.12-rc.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: BSD-3-Clause Imports: 10 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchExternalIP

func FetchExternalIP(resolver Resolver) (net.IP, error)

Types

type DynamicIP

type DynamicIP struct {
	ips.DynamicIPPort
	// contains filtered or unexported fields
}

DynamicIP is an IP address that gets periodically updated to our public IP

func (*DynamicIP) Stop

func (dynamicIP *DynamicIP) Stop()

func (*DynamicIP) UpdateExternalIP

func (dynamicIP *DynamicIP) UpdateExternalIP()

Update our public IP address in a loop

type IFConfigResolver

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

IFConfigResolves resolves our public IP using ifconfig's format

func (*IFConfigResolver) IsResolver

func (r *IFConfigResolver) IsResolver() bool

func (*IFConfigResolver) Resolve

func (r *IFConfigResolver) Resolve() (net.IP, error)

type IPManager

type IPManager interface {
	Stop()
}

func NewDynamicIPManager

func NewDynamicIPManager(resolver Resolver, updateTimeout time.Duration, log logging.Logger, ip ips.DynamicIPPort) IPManager

Returns a new dynamic IP that resolves and updates [ip] to our public IP every [updateTimeout]. Uses [dynamicResolver] to resolve our public ip. Stops updating when Stop() is called.

type NoDynamicIP

type NoDynamicIP struct{}

func (*NoDynamicIP) Stop

func (noDynamicIP *NoDynamicIP) Stop()

type NoResolver

type NoResolver struct{}

NoResolver doesn't resolve our public IP address

func (*NoResolver) IsResolver

func (r *NoResolver) IsResolver() bool

func (*NoResolver) Resolve

func (r *NoResolver) Resolve() (net.IP, error)

type OpenDNSResolver

type OpenDNSResolver struct {
	*net.Resolver
}

IFConfigResolves resolves our public IP using openDNS

func NewOpenDNSResolver

func NewOpenDNSResolver() *OpenDNSResolver

func (*OpenDNSResolver) IsResolver

func (r *OpenDNSResolver) IsResolver() bool

func (*OpenDNSResolver) Resolve

func (r *OpenDNSResolver) Resolve() (net.IP, error)

type Resolver

type Resolver interface {
	// Resolve our public IP
	Resolve() (net.IP, error)
	// If false, Resolve always returns an error
	IsResolver() bool
}

Resolver resolves our public IP

func NewResolver

func NewResolver(opt string) Resolver

Jump to

Keyboard shortcuts

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