jackpal/go-nat-pmp

Add support for PCP

zorun opened this issue · 4 comments

zorun commented

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

What common routers support PCP? Apple? EdgeRouter?

Apple products and other common routers (the "Fritzbox", a super common router in Germany is one of them). According to this ticket on syncthing, some custom built routers also support it.

I am attaching a link to the RFC, just in case: http://datatracker.ietf.org/doc/rfc6887/?include_text=1

PCP is a neat protocol, but it's significantly larger in scope than NAT-PNP. PCP is upwards compatible with NAT-PNP at the network packet layer, but I think a good Golang API for PCP would look different than the current go-nat-pmp API. I think it would be better to have a separate go-PCP library with a PCP-centered API.

I am not currently working on golang networking code, so unfortunately I don't have any plans to implement a golang PCP library.

But it's totally a good idea!

JFYI: guys from IPFS created a fork and working of adding a support ipfs/kubo#2797
There is also a PoC https://github.com/sashahilton00/go-pcp