In go-libp2p, is it possible to get a boolean value indicating whether my host is behind a NAT? This would allow applications using libp2p to have different behavior when they are behind NAT – for example, not joining the DHT. I know IPFS is interested in this.
Yes, you can do this through an AutoNAT instance. You have to be aware of NATStatusUnknown, which may be returned if we haven’t discovered any autonat peers or the service hasn’t been able to assert NAT status yet.
Note that there is currently one burried in the autorelay code; we plan to make it part of the Omnihost with the host refactor and expose it to the user so that we can easily assert NAT status.