Added new client_ip accessor (#2114)
* Added new client_ip accessor for ConnInfo class, updated request to use client_ip instead of client to be more representative of what will be returned (actual ipv6 ip instead of bracket wrapped ip) * Fix ConnInfo init * add ipv6 test - maybe will work? * fixed silly indentation error * Bump testing client * Extend testing * Fix text Co-authored-by: Adam Hopkins <adam@amhopkins.com> Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
This commit is contained in:
@@ -505,7 +505,7 @@ class Request:
|
||||
:return: peer ip of the socket
|
||||
:rtype: str
|
||||
"""
|
||||
return self.conn_info.client if self.conn_info else ""
|
||||
return self.conn_info.client_ip if self.conn_info else ""
|
||||
|
||||
@property
|
||||
def port(self) -> int:
|
||||
|
||||
@@ -65,6 +65,7 @@ class ConnInfo:
|
||||
__slots__ = (
|
||||
"client_port",
|
||||
"client",
|
||||
"client_ip",
|
||||
"ctx",
|
||||
"peername",
|
||||
"server_port",
|
||||
@@ -78,6 +79,7 @@ class ConnInfo:
|
||||
self.peername = None
|
||||
self.server = self.client = ""
|
||||
self.server_port = self.client_port = 0
|
||||
self.client_ip = ""
|
||||
self.sockname = addr = transport.get_extra_info("sockname")
|
||||
self.ssl: bool = bool(transport.get_extra_info("sslcontext"))
|
||||
|
||||
@@ -96,6 +98,7 @@ class ConnInfo:
|
||||
|
||||
if isinstance(addr, tuple):
|
||||
self.client = addr[0] if len(addr) == 2 else f"[{addr[0]}]"
|
||||
self.client_ip = addr[0]
|
||||
self.client_port = addr[1]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user