Support IPv6 address syntax for hosts

This commit is contained in:
Juhani Krekelä 2021-10-17 18:28:36 +03:00
parent e186c7a85d
commit 057af32553
1 changed files with 2 additions and 0 deletions

View File

@ -253,6 +253,8 @@ def proxy(sock, host):
print('Bad port number', file=sys.stderr)
sock.sendall(b'HTTP/1.0 400 Bad Request\r\n\r\nBad port number\n')
return
if remote_host[:1] == b'[' and remote_host[-1:] == b']': #IPv6
remote_host = remote_host[1:-1]
try:
remote_host = remote_host.decode('ascii')
except UnicodeDecodeError: