Durand Fabrice bcc73e2a61 Protocol as param
2020-12-22 16:24:13 -05:00
2020-09-14 09:51:52 -04:00
2014-11-08 20:30:26 -06:00
2014-11-08 20:30:26 -06:00
2014-11-08 20:30:26 -06:00
2014-11-08 20:30:26 -06:00
2020-12-22 16:24:13 -05:00
2020-12-22 16:21:02 -05:00
2014-06-26 19:57:22 +08:00
2020-11-12 07:43:37 -05:00
2020-12-22 16:24:13 -05:00

upnp protocol

====

A simple implementation of the UPnP protocol as a Golang library. Add port mappings for NAT devices.

Look for a gateway device, check if it supports UPnP, and if so, add port mappings.

====

example:

1. add a port mapping

mapping := new(upnp.Upnp)
if err := mapping.AddPortMapping(55789, 55789, "TCP"); err == nil {
	fmt.Println("success !")
	// remove port mapping in gatway
	mapping.Reclaim()
} else {
	fmt.Println("fail !")
}

2. search gateway device.

upnpMan := new(upnp.Upnp)
err := upnpMan.SearchGateway()
if err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println("local ip address: ", upnpMan.LocalHost)
	fmt.Println("gateway ip address: ", upnpMan.Gateway.Host)
}

3. get an internet ip address in gatway.

upnpMan := new(upnp.Upnp)
err := upnpMan.ExternalIPAddr()
if err != nil {
	fmt.Println(err.Error())
} else {
	fmt.Println("internet ip address: ", upnpMan.GatewayOutsideIP)
}
Description
A simple implements UPnP protocol for Go(Golang) library. Add port mapping for NAT devices. Look for a gateway device, check if it supports UPnP, and if so, add port mappings.
Readme 1.9 MiB
Languages
Go 100%