jackpal / go-nat-pmp Goto Github PK
View Code? Open in Web Editor NEWA Go language client for the NAT-PMP internet protocol for port mapping and discovering the external IP address of a firewall.
License: Other
A Go language client for the NAT-PMP internet protocol for port mapping and discovering the external IP address of a firewall.
License: Other
The current test only works if the test machine has networking executables installed, so that the gateway library can find the default gateway, and only if there is a NAT-PMP server on the default gateway.
Can we test some portion of this code without either of those things?
Getting this error from AddPortMapping
. Curious if anyone has seen it before or knows what it means.
Non-zero result code 3
It would be nice to have support for PCP, which is the successor of NAT-PMP (basically NAT-PMP v1).
PCP basically extends NAT-PMP to be able to control stateful firewalls (IPv4 or IPv6), without necessarily involving NAT. Stateful firewalls are the real issue when applications need incoming connectivity (especially in an IPv6 world), NAT is just an artifact of the limited IPv4 address space.
From RFC 6886:
In 2013, NAT-PMP was superseded by the IETF Standards Track Port
Control Protocol [RFC6887]. PCP builds on NAT-PMP and uses a
compatible packet format, and adds a number of significant
enhancements, including IPv6 support, management of outbound
mappings, management of firewall rules, full compatibility with
large-scale NATs with a pool of external addresses, error lifetimes,
and an extension mechanism to enable future enhancements.
The on-wire format and UDP ports are the same, and there is support to facilitate the interoperability between the two protocols, see: https://tools.ietf.org/html/rfc6887#page-87
Hello,
I am using your library and the function GetExternalAddress()
is not returning an error but it isn't returning a proper result either, it just gets stuck at that part of my program.
gatewayIP, err := gateway.DiscoverGateway()
if err != nil {
log.Fatalln("Can't discover gateway: " + err.Error())
} else {
client := natpmp.NewClient(gatewayIP)
fmt.Println("Created a new client!")
address, err := client.GetExternalAddress()
if err != nil {
log.Fatalln("Can't get external address: " + err.Error())
}
}
The file torrent/gateway.go has a neat DiscoverGateway() function that could be included in this package.
I understand that this function may not always work, but could not it be included in this package?
It could be made such that if you provide natpmp.NewClient
with the argument nil
, it would try to guess. Does it make sense?
Pro of removing dependency: decouples the two libraries.
Con of removing dependency: breaks existing clients. (of which there are very few.)
In the README you are linking to a draft version: https://tools.ietf.org/html/draft-cheshire-nat-pmp-03
The final version is: https://tools.ietf.org/html/rfc6886
Two questions:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.