core/src/translation: Support dns4 and dns6 (#1204)

* core/src/translation: Add unit tests

* core/src/translation: Support dns4 and dns6

Add dns4 and dns6 as valid protocol replacements for the origin address
to construct external addresses of a given node.

* core/nodes/network: %s/nat_translation/address_translation/

When receiving an observed address on a tcp connection that we initiated, the
observed address contains our tcp dial port, not our tcp listen port. We know
which port we are listening on, thereby we can replace the port within the
observed address.

When receiving an observed address on a tcp connection that we did **not**
initiated, the observed address should contain our listening port. In case it
differs from our listening port there might be a NAT along the path.

With the above in mind, the function name `nat_translation` is misleading.
This commit is contained in:
Max Inden
2019-07-18 18:41:09 +02:00
committed by Pierre Krieger
parent cde93f5432
commit 5861474d99
4 changed files with 97 additions and 20 deletions

View File

@ -443,7 +443,7 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
}
},
Async::Ready(NetworkBehaviourAction::ReportObservedAddr { address }) => {
for addr in self.network.nat_traversal(&address) {
for addr in self.network.address_translation(&address) {
if self.external_addrs.iter().all(|a| *a != addr) {
self.behaviour.inject_new_external_addr(&addr);
}