nat

package
v0.14.43-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2017 License: MPL-2.0 Imports: 12 Imported by: 0

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          = "UDP"
)

type Service

type Service struct {
	// 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.

func (*Service) Serve

func (s *Service) Serve()

func (*Service) Stop

func (s *Service) Stop()

Jump to

Keyboard shortcuts

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