Opened 4 years ago

Closed 4 years ago

#7261 defect closed duplicate (duplicate)

Fix t.conch.ssh.channel.getPeer()

Reported by: Adi Roiban Owned by: Adi Roiban
Priority: normal Milestone:
Component: conch Keywords:
Cc: z3p Branch:
Author:

Description

getPeer has this strange code.

return('SSH', )+self.conn.transport.getPeer()

https://github.com/twisted/twisted/blob/trunk/twisted/conch/ssh/channel.py#L261

The error is

   return('SSH', )+self.conn.transport.getPeer()

exceptions.TypeError: can only concatenate tuple (not "SSHTransportAddress") to tuple
(Pdb) self.conn.transport.getPeer()
SSHTransportAddress(IPv4Address(TCP, '127.0.0.1', 35447))

(Pdb) self.conn.transport.getPeer().address
IPv4Address(TCP, '127.0.0.1', 35447)

There is a test for the code, but it using mocked a transport which returns a tupple with a single value!?!

This is why this test passed when SSHTransport was changed in #2997

The current transport returns a SSHTransportAddress.

I have no why a SSHTransportAddress object is required and why an IPv4Address is not enough.

It looks like SSHTransportAddress was introduced in 12.1 by Paul Swartz in #2997 but the review / patch contains no hint about why that object is needed.


I can try to fix this but I have no idea why SSHSession.getPeer should return a tupple and not in IAddress ... and also why SSHTranport.getPeer is returning an IAddress wrapped inside another IAddress.

Thanks!

Change History (2)

comment:1 Changed 4 years ago by DefaultCC Plugin

Cc: z3p added

comment:2 Changed 4 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Thanks. Sadly, duplicate of #5999.

Note: See TracTickets for help on using tickets.