_info.py 917 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- test-case-name: twisted.protocols.haproxy.test -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. IProxyInfo implementation.
  6. """
  7. from typing import Optional
  8. from zope.interface import implementer
  9. import attr
  10. from twisted.internet.interfaces import IAddress
  11. from ._interfaces import IProxyInfo
  12. @implementer(IProxyInfo)
  13. @attr.s(frozen=True, slots=True, auto_attribs=True)
  14. class ProxyInfo:
  15. """
  16. A data container for parsed PROXY protocol information.
  17. @ivar header: The raw header bytes extracted from the connection.
  18. @type header: C{bytes}
  19. @ivar source: The connection source address.
  20. @type source: L{twisted.internet.interfaces.IAddress}
  21. @ivar destination: The connection destination address.
  22. @type destination: L{twisted.internet.interfaces.IAddress}
  23. """
  24. header: bytes
  25. source: Optional[IAddress]
  26. destination: Optional[IAddress]