Documentation ¶
Overview ¶
Package upnp implements UPnP InternetGatewayDevice discovery, querying, and port mapping.
Index ¶
- func Discover(renewal, timeout time.Duration) []nat.Device
- type IGD
- func (n *IGD) AddPortMapping(protocol nat.Protocol, internalPort, externalPort int, description string, ...) (int, error)
- func (n *IGD) DeletePortMapping(protocol nat.Protocol, externalPort int) error
- func (n *IGD) FriendlyIdentifier() string
- func (n *IGD) FriendlyName() string
- func (n *IGD) GetExternalIPAddress() (ip net.IP, err error)
- func (n *IGD) GetLocalIPAddress() net.IP
- func (n *IGD) ID() string
- func (n *IGD) URL() *url.URL
- type IGDService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IGD ¶
type IGD struct {
// contains filtered or unexported fields
}
An IGD is a UPnP InternetGatewayDevice.
func (*IGD) AddPortMapping ¶
func (n *IGD) AddPortMapping(protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
AddPortMapping adds a port mapping to all relevant services on the specified InternetGatewayDevice. Port mapping will fail and return an error if action is fails for _any_ of the relevant services. For this reason, it is generally better to configure port mapping for each individual service instead.
func (*IGD) DeletePortMapping ¶
DeletePortMapping deletes a port mapping from all relevant services on the specified InternetGatewayDevice. Port mapping will fail and return an error if action is fails for _any_ of the relevant services. For this reason, it is generally better to configure port mapping for each individual service instead.
func (*IGD) FriendlyIdentifier ¶
FriendlyIdentifier returns a friendly identifier (friendly name + IP address) for the IGD.
func (*IGD) FriendlyName ¶
func (*IGD) GetExternalIPAddress ¶ added in v0.13.0
GetExternalIPAddress returns the external IP address of the IGD, or an error if no service providing this feature exists.
func (*IGD) GetLocalIPAddress ¶ added in v0.13.0
GetLocalIPAddress returns the IP address of the local network interface which is facing the IGD.
type IGDService ¶
An IGDService is a specific service provided by an IGD.
func (*IGDService) AddPortMapping ¶
func (s *IGDService) AddPortMapping(localIPAddress net.IP, protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) error
AddPortMapping adds a port mapping to the specified IGD service.
func (*IGDService) DeletePortMapping ¶
func (s *IGDService) DeletePortMapping(protocol nat.Protocol, externalPort int) error
DeletePortMapping deletes a port mapping from the specified IGD service.
func (*IGDService) GetExternalIPAddress ¶
func (s *IGDService) GetExternalIPAddress() (net.IP, error)
GetExternalIPAddress queries the IGD service for its external IP address. Returns nil if the external IP address is invalid or undefined, along with any relevant errors