[Twisted-Python] Why would someone need SSHTransportAddress?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon May 19 09:59:12 MDT 2014


On 06:27 am, adi at roiban.ro wrote:
>This email is bases on comment from 
>https://twistedmatrix.com/trac/ticket/5999
>
>I fail to see the reason why SSHTransportAddress exist and why would
>anyone need It.

Here are a couple ideas.

You have a library that accepts a connection and does some things with 
it.  You want to log the operations that are taken using the connection 
and you want to include information in those logs about which connection 
you did things with.  You choose to use the addresses of the local and 
remote sides of the connection to identify it.

You have a library that accepts a connection and wants to be able to set 
up another connection like it to the same remote address.  You get the 
remote address using the transport's `getPeer` method.

Though you may have established the SSH connection over a TCP/IPv4 
connection, neither of these uses can be accomplished if the SSH 
connection, when treated as a transport, merely uses an `IPv4Address` 
instance to represent the address of the remote end of the connection. 
Using `IPv4Address` gives you no way to differentiate between an SSH 
connection running over a TCP/IPv4 connection and a plain TCP/IPv4 
connection without SSH.

In practice, `SSHTransportAddress` is missing the information you would 
need to implement either of these scenarios.  However, that seems more 
like an argument for adding the missing information to that address type 
rather than discarding the address type.

Jean-Paul



More information about the Twisted-Python mailing list