nat

package
v1.3.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MPL-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(provider DiscoverFunc)

Types

type Address

type Address struct {
	IP   net.IP
	Port int
}

Address is essentially net.TCPAddr yet is more general, and has a few helper methods which reduce boilerplate code.

func (Address) Equal

func (a Address) Equal(b Address) bool

func (Address) GoString

func (a Address) GoString() string

func (Address) String

func (a Address) String() string

type Device

type Device interface {
	ID() string
	GetLocalIPAddress() net.IP
	AddPortMapping(protocol Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
	GetExternalIPAddress() (net.IP, error)
}

type DiscoverFunc

type DiscoverFunc func(renewal, timeout time.Duration) []Device

type Mapping

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

func (*Mapping) Address

func (m *Mapping) Address() Address

func (*Mapping) ExternalAddresses

func (m *Mapping) ExternalAddresses() []Address

func (*Mapping) GoString

func (m *Mapping) GoString() string

func (*Mapping) OnChanged

func (m *Mapping) OnChanged(subscribed MappingChangeSubscriber)

func (*Mapping) Protocol

func (m *Mapping) Protocol() Protocol

func (*Mapping) String

func (m *Mapping) String() string

type MappingChangeSubscriber

type MappingChangeSubscriber func(*Mapping, []Address, []Address)

type Protocol

type Protocol string
const (
	TCP Protocol = "TCP"
	UDP Protocol = "UDP"
)

type Service

type Service struct {
	suture.Service
	// contains filtered or unexported fields
}

Service runs a loop for discovery of IGDs (Internet Gateway Devices) and setup/renewal of a port mapping.

func NewService

func NewService(id protocol.DeviceID, cfg config.Wrapper) *Service

func (*Service) NewMapping

func (s *Service) NewMapping(protocol Protocol, ip net.IP, port int) *Mapping

func (*Service) RemoveMapping

func (s *Service) RemoveMapping(mapping *Mapping)

RemoveMapping does not actually remove the mapping from the IGD, it just internally removes it which stops renewing the mapping. Also, it clears any existing mapped addresses from the mapping, which as a result should cause discovery to reannounce the new addresses.

Jump to

Keyboard shortcuts

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