upip: Be sure to create socket with params returned by getaddrinfo().

To use address as returned by getaddrinfo(), we should create a socket
compatible with address family, etc., returned by the same call alongside
the address itself.
pull/255/merge
Paul Sokolovsky 2018-01-27 13:22:37 +02:00
rodzic f2114d889d
commit 559d51c0ee
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -117,16 +117,16 @@ def url_open(url):
proto, _, host, urlpath = url.split('/', 3)
try:
ai = usocket.getaddrinfo(host, 443)
ai = usocket.getaddrinfo(host, 443, 0, usocket.SOCK_STREAM)
except OSError as e:
fatal("Unable to resolve %s (no Internet?)" % host, e)
#print("Address infos:", ai)
addr = ai[0][4]
ai = ai[0]
s = usocket.socket(ai[0][0])
s = usocket.socket(ai[0], ai[1], ai[2])
try:
#print("Connect address:", addr)
s.connect(addr)
s.connect(ai[-1])
if proto == "https:":
s = ussl.wrap_socket(s, server_hostname=host)