go.mod
Initialize Go module with Go 1.21LICENSE
Fix LICENSE detection, add maintenance banner + SECURITY.md, drop dead Travis badgenatpmp_test.go
Add bounds validation and AddPortMappingWithDuration helper (addresses #12)natpmp.go
Add bounds validation and AddPortMappingWithDuration helper (addresses #12)network_test.go
Add loopback mock UDP server test suite in network_test.gonetwork.go
Support specifying local IP address (addresses #13)README.md
Fix LICENSE detection, add maintenance banner + SECURITY.md, drop dead Travis badgerecorder.go
Add support for custom timeoutsSECURITY.md
Fix LICENSE detection, add maintenance banner + SECURITY.md, drop dead Travis badgego-nat-pmp
A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external IP address of a firewall.
NAT-PMP is supported by Apple brand routers and open source routers like Tomato and DD-WRT.
See https://tools.ietf.org/rfc/rfc6886.txt
Maintenance status: ✅ Maintained (stable). This library is feature-complete — I accept bug fixes and security patches, but am not adding new features. See SECURITY.md for how to report vulnerabilities.
Get the package
# Get the go-nat-pmp package.
go get -u github.com/jackpal/go-nat-pmpUsage
Get one more package, used by the example code:
go get -u github.com/jackpal/gatewayCreate a directory:
cd ~/go
mkdir -p src/hello
cd src/helloCreate a file hello.go with these contents:
package main
import (
"fmt"
"github.com/jackpal/gateway"
natpmp "github.com/jackpal/go-nat-pmp"
)
func main() {
gatewayIP, err := gateway.DiscoverGateway()
if err != nil {
return
}
client := natpmp.NewClient(gatewayIP)
response, err := client.GetExternalAddress()
if err != nil {
return
}
fmt.Printf("External IP address: %v\n", response.ExternalIPAddress)
}Build the example
go build
./hello
External IP address: [www xxx yyy zzz]Clients
This library is used in the Taipei Torrent BitTorrent client http://github.com/jackpal/Taipei-Torrent
Complete documentation
http://godoc.org/github.com/jackpal/go-nat-pmpLicense
This project is licensed under the Apache License 2.0.