address.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- test-case-name: twisted.conch.test.test_address -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. Address object for SSH network connections.
  6. Maintainer: Paul Swartz
  7. @since: 12.1
  8. """
  9. from __future__ import division, absolute_import
  10. from zope.interface import implementer
  11. from twisted.internet.interfaces import IAddress
  12. from twisted.python import util
  13. @implementer(IAddress)
  14. class SSHTransportAddress(util.FancyEqMixin, object):
  15. """
  16. Object representing an SSH Transport endpoint.
  17. This is used to ensure that any code inspecting this address and
  18. attempting to construct a similar connection based upon it is not
  19. mislead into creating a transport which is not similar to the one it is
  20. indicating.
  21. @ivar address: An instance of an object which implements I{IAddress} to
  22. which this transport address is connected.
  23. """
  24. compareAttributes = ('address',)
  25. def __init__(self, address):
  26. self.address = address
  27. def __repr__(self):
  28. return 'SSHTransportAddress(%r)' % (self.address,)
  29. def __hash__(self):
  30. return hash(('SSH', self.address))