haskell-distributed / network-transport-tcp

TCP Realisation of Network.Transport
http://haskell-distributed.github.com
BSD 3-Clause "New" or "Revised" License
30 stars 27 forks source link

Support transports behind NAT #59

Closed avieth closed 6 years ago

avieth commented 7 years ago

This is a feature request to allow creating a Transport without giving a bind address nor external address. The intended use case is Transports behind NAT, which do not have a public address.

In this mode, createTransport would not forkServer (impossible, since there's no bind address), and all EndPoints created on this Transport would have randomly-generated addresses (maybe a standard UUIDv4). The idea is that these addresses are meaningless to every EndPoint except for itself: a loopback connection is still made by testing for equality, but nobody else can successfully connect to it by using this address.

When one of these EndPoints connects (heavyweight, new socket) to a peer, it doesn't give its address. Instead, the peer generates a random address for it, which is valid for the lifetime of the socket, and meaningless to every other EndPoint. It will be attached to the ConnectionOpened event, and so it's possible for the application to make a lightweight connection back to the un-addressable EndPoint, but only by using this ephemeral address; the actual address of the EndPoint will be different and will result in ConnectNotFound.

avieth commented 6 years ago

https://github.com/haskell-distributed/network-transport-tcp/pull/61