Simplified https test
This commit is contained in:
parent
a91fb8eb8f
commit
81bdd64a7e
|
@ -1,6 +1,5 @@
|
||||||
import structio
|
import structio
|
||||||
import sys
|
import sys
|
||||||
import ssl
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
_print = print
|
_print = print
|
||||||
|
@ -13,9 +12,7 @@ def print(*args, **kwargs):
|
||||||
|
|
||||||
async def test(host: str, port: int, bufsize: int = 4096):
|
async def test(host: str, port: int, bufsize: int = 4096):
|
||||||
print(f"Attempting a connection to {host}:{port}")
|
print(f"Attempting a connection to {host}:{port}")
|
||||||
context = ssl.create_default_context()
|
socket = await structio.socket.connect_ssl_socket(host, port)
|
||||||
context.server_hostname = host
|
|
||||||
socket = await structio.socket.connect_ssl_socket(host, port, ssl_context=context)
|
|
||||||
print("Connected")
|
print("Connected")
|
||||||
# Ensures the code below doesn't run for more than 5 seconds
|
# Ensures the code below doesn't run for more than 5 seconds
|
||||||
with structio.skip_after(5) as scope:
|
with structio.skip_after(5) as scope:
|
||||||
|
|
Loading…
Reference in New Issue