66from typing_extensions import Literal
77
88from . import ProxyProtocolResult
9+ from .tlv import ProxyProtocolTLV
910
1011__all__ = ['ProxyProtocolResult' , 'ProxyProtocolResultLocal' ,
1112 'ProxyProtocolResultUnknown' , 'ProxyProtocolResultIPv4' ,
@@ -34,6 +35,10 @@ def source(self) -> None:
3435 def dest (self ) -> None :
3536 return None
3637
38+ @property
39+ def tlv (self ) -> ProxyProtocolTLV :
40+ return ProxyProtocolTLV ()
41+
3742
3843class ProxyProtocolResultUnknown (ProxyProtocolResult ):
3944 """Indicates that the source of the connection is unknown."""
@@ -64,6 +69,10 @@ def source(self) -> None:
6469 def dest (self ) -> None :
6570 return None
6671
72+ @property
73+ def tlv (self ) -> ProxyProtocolTLV :
74+ return ProxyProtocolTLV ()
75+
6776
6877class ProxyProtocolResultIPv4 (ProxyProtocolResult ):
6978 """The original connection was made with an IPv4 socket. The
@@ -72,15 +81,17 @@ class ProxyProtocolResultIPv4(ProxyProtocolResult):
7281
7382 """
7483
75- __slots__ = ['_source' , '_dest' , '_protocol' ]
84+ __slots__ = ['_source' , '_dest' , '_protocol' , '_tlv' ]
7685
7786 def __init__ (self , source : Tuple [IPv4Address , int ],
7887 dest : Tuple [IPv4Address , int ], * ,
79- protocol : Optional [SocketKind ] = None ) -> None :
88+ protocol : Optional [SocketKind ] = None ,
89+ tlv : ProxyProtocolTLV = ProxyProtocolTLV ()) -> None :
8090 super ().__init__ ()
8191 self ._source = source
8292 self ._dest = dest
8393 self ._protocol = protocol
94+ self ._tlv = tlv
8495
8596 @property
8697 def proxied (self ) -> Literal [True ]:
@@ -102,6 +113,10 @@ def family(self) -> AddressFamily:
102113 def protocol (self ) -> Optional [SocketKind ]:
103114 return self ._protocol
104115
116+ @property
117+ def tlv (self ) -> ProxyProtocolTLV :
118+ return self ._tlv
119+
105120 @property
106121 def _peername (self ) -> Tuple [str , int ]:
107122 return str (self .source [0 ]), self .source [1 ]
@@ -125,15 +140,17 @@ class ProxyProtocolResultIPv6(ProxyProtocolResult):
125140
126141 """
127142
128- __slots__ = ['_source' , '_dest' , '_protocol' ]
143+ __slots__ = ['_source' , '_dest' , '_protocol' , '_tlv' ]
129144
130145 def __init__ (self , source : Tuple [IPv6Address , int ],
131146 dest : Tuple [IPv6Address , int ], * ,
132- protocol : Optional [SocketKind ] = None ) -> None :
147+ protocol : Optional [SocketKind ] = None ,
148+ tlv : ProxyProtocolTLV = ProxyProtocolTLV ()) -> None :
133149 super ().__init__ ()
134150 self ._source = source
135151 self ._dest = dest
136152 self ._protocol = protocol
153+ self ._tlv = tlv
137154
138155 @property
139156 def proxied (self ) -> Literal [True ]:
@@ -155,6 +172,10 @@ def family(self) -> AddressFamily:
155172 def protocol (self ) -> Optional [SocketKind ]:
156173 return self ._protocol
157174
175+ @property
176+ def tlv (self ) -> ProxyProtocolTLV :
177+ return self ._tlv
178+
158179 @property
159180 def _peername (self ) -> Tuple [str , int , int , int ]:
160181 return str (self .source [0 ]), self .source [1 ], 0 , 0
@@ -178,14 +199,16 @@ class ProxyProtocolResultUnix(ProxyProtocolResult):
178199
179200 """
180201
181- __slots__ = ['_source' , '_dest' , '_protocol' ]
202+ __slots__ = ['_source' , '_dest' , '_protocol' , '_tlv' ]
182203
183204 def __init__ (self , source : str , dest : str , * ,
184- protocol : Optional [SocketKind ] = None ) -> None :
205+ protocol : Optional [SocketKind ] = None ,
206+ tlv : ProxyProtocolTLV = ProxyProtocolTLV ()) -> None :
185207 super ().__init__ ()
186208 self ._source = source
187209 self ._dest = dest
188210 self ._protocol = protocol
211+ self ._tlv = tlv
189212
190213 @property
191214 def proxied (self ) -> Literal [True ]:
@@ -207,6 +230,10 @@ def family(self) -> AddressFamily:
207230 def protocol (self ) -> Optional [SocketKind ]:
208231 return self ._protocol
209232
233+ @property
234+ def tlv (self ) -> ProxyProtocolTLV :
235+ return self ._tlv
236+
210237 @property
211238 def _peername (self ) -> str :
212239 return self .source
0 commit comments