pub async fn peer_to_tcp(
addr: &str,
send: SendStream,
recv: RecvStream,
) -> Result<()>Expand description
this is the tcp proxy.
the other side has indicated they want to access our TCP device, whose id is specified in the protocol header. we will first check if the remote id is allowed to do that, but the permission system is managed not by Rust code of fastn, but by the fastn server running as the identity server. this allows fastn code to contain a lot of logic. since fastn code is sandboxed, and something end user can easily modify or get from the fastn app marketplace ecosystem, it is a good place to put as much logic as possible into fastn code.
fastn server will query database etc., will return the ip:port to connect to.
we have to decide if one tcp connection is one bidirectional stream as disused in protocol.rs.
so we will make one tcp connection from this function, and connect the send and recv streams
to tcp connection’s recv and send side respectively.