> On Mar 17, 2015, at 6:44 AM, Adi Roiban <a...@roiban.ro> wrote:
> 
> Hi,
> 
> While trying to fix https://twistedmatrix.com/trac/ticket/5999 I found
> out about the SSHTransportAddress introduced in 12.1.
> 
> SSHTransportAddress is just an IAddress wrapping in a non-tranparent
> way another IAddress.
> 
> It was introduces in #2997 which was accepted without any reason why
> we need SSHTransportAddress and why SSHTransportAddress is better than
> an IAddress.
> I could not find any documentation describing why we need this new class.

The reason that we need this new type of address is to ensure that any code 
inspecting this address and attempting to construct a similar connection based 
upon it is not mislead into creating a transport which is not similar to the 
one it is indicating.

Arguably, SSHTransportAddress is missing lots of important information: is the 
address indicative of a client, or a server?  If a client, what hostname was 
specified?  If a server, what user is connected?  Two SSH connections to the 
same IP address / port number are not necessarily equivalent, but the current 
implementation of SSHTransportAddress would compare that way, which is 
unfortunate.

> In case I have not got this wrong, exarkun argued that we need
> SSHTransportAddress in order to find out the type of transport in use
> https://twistedmatrix.com/trac/ticket/5999#comment:11
> 
> I find it stupid to use transport.getHost() and transport.getPeer() to
> find out what transport you have rather than doing a check on the
> transport itself.
> 
> # I am for this check
> if IConchTransport.providedBy(someTransport):
>    pass
> 
> # rather this one.
> if isinstance(someTransport.getHost(), SSHTransportAddress):
>    pass
> 
> I understand the need for endpoints but has somebody implemented an
> endpoint which reads an SSHTransportAddress?

No, and that's exactly the point - if they had written one that connects 
IPv4Addresses into endpoints, but not SSHTransportAddresses, they shouldn't be 
able to make a new connection and treat it as equivalent; it has totally 
different properties.

> Am I the only one who fails to see the advantages of using
> SSHTransportAddress over a normal IAddress?

SSHTransportAddress is useful, but its only utility is in explicitly breaking 
use-cases that in fact should not work, so it's a bit user-hostile, so I can 
see why you'd feel it is useless.  If it were retrofitted to keep enough 
information to be useful in its own right, then that would be a lot better.

-glyph

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to