Fix ip and socket data format on V6

This commit is contained in:
Dan Palmer 2017-12-11 14:42:18 +00:00
parent 10a378bd46
commit 48c2dcb110
No known key found for this signature in database
GPG Key ID: DD869B28A1B7AA92

View File

@ -1,5 +1,6 @@
import sys
import json
import socket
from cgi import parse_header
from collections import namedtuple
from http.cookies import SimpleCookie
@ -185,9 +186,18 @@ class Request(dict):
return self._socket
def _get_address(self):
sock = self.transport.get_extra_info('socket')
if sock.family == socket.AF_INET:
self._socket = (self.transport.get_extra_info('peername') or
(None, None))
self._ip, self._port = self._socket
elif sock.family == socket.AF_INET6:
self._socket = (self.transport.get_extra_info('peername') or
(None, None, None, None))
self._ip, self._port, *_ = self._socket
else:
self._ip, self._port = (None, None)
@property
def remote_addr(self):