Documentation
¶
Overview ¶
Package nat performs network address translation and provides helpers for routing ports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mapper ¶
type Mapper interface {
MapPort(newInternalPort, newExternalPort uint16) error
UnmapAllPorts() error
}
Mapper maps port
func NewDefaultMapper ¶
func NewDefaultMapper( log logging.Logger, router Router, networkProtocol NetworkProtocol, mappingNames string, ) Mapper
NewDefaultMapper returns a new mapper that can map ports on a router with default settings
type NetworkProtocol ¶
type NetworkProtocol string
NetworkProtocol is a protocol that will be used through a port
const ( TCP NetworkProtocol = "TCP" UDP NetworkProtocol = "UDP" )
Available protocol
type Router ¶
type Router interface {
// mapPort creates a mapping between a port on the local computer to an
// external port on the router.
//
// The mappingName is something displayed on the router, so it is included
// for completeness.
MapPort(
networkProtocol NetworkProtocol,
newInternalPort uint16,
newExternalPort uint16,
mappingName string,
mappingDuration time.Duration) error
// UnmapPort clears a mapping that was previous made by a call to MapPort
UnmapPort(
networkProtocol NetworkProtocol,
internalPort uint16,
externalPort uint16) error
// Returns the routers IP address on the network the router considers
// external
IP() (net.IP, error)
}
Router provides a standard NAT router functions. Specifically, allowing the fetching of public IPs and port forwarding to this computer.
Click to show internal directories.
Click to hide internal directories.