nat/upnp.go
func (n *upnp) AddMapping(protocol string, extPort, intPort int,
	desc string, lifetime time.Duration) error {
	ip, err := n.internalAddress()
	if err != nil {
		return nil
	}
	protocol = strings.ToUpper(protocol)
	lifetimeS := uint32(lifetime / time.Second)
	n.DeleteMapping(protocol, extPort, intPort)
	return n.client.AddPortMapping("", uint16(extPort),
		protocol, uint16(intPort), ip.String(), true, desc, lifetimeS)
}
func (n *upnp) AddMapping(protocol string, extPort, intPort int,
	desc string, lifetime time.Duration) error {
	ip, err := n.internalAddress()
	if err != nil {
		return nil
	}
	protocol = strings.ToUpper(protocol)
	lifetimeS := uint32(lifetime / time.Second)
	n.DeleteMapping(protocol, extPort, intPort)
	return n.client.AddPortMapping("", uint16(extPort),
		protocol, uint16(intPort), ip.String(), true, desc, lifetimeS)
}
func ( n * upnp ) AddMapping ( protocol string , extPort , intPort int , desc string , lifetime time . Duration ) error { ip , err := n . internalAddress ( ) if err != nil { return nil } protocol = strings . ToUpper ( protocol ) lifetimeS := uint32 ( lifetime / time . Second ) n . DeleteMapping ( protocol , extPort , intPort ) return n . client . AddPortMapping ( " " , uint16 ( extPort ) , protocol , uint16 ( intPort ) , ip . String ( ) , true , desc , lifetimeS ) }
// AddMapping maps an external port to a local port for a specific
// service to UPnP interface.
AddMapping maps an external port to a local port for a specific service to UPnP interface .