add async_stagger reference for backported happy eyeballs open_connection

This commit is contained in:
jesopo 2020-04-11 11:33:53 +01:00
parent c4009e1c07
commit 923809ab43
2 changed files with 13 additions and 5 deletions

View file

@ -1,6 +1,7 @@
from ssl import SSLContext
from typing import Optional, Tuple
from asyncio import open_connection, StreamReader, StreamWriter
from ssl import SSLContext
from typing import Optional, Tuple
from asyncio import StreamReader, StreamWriter
from async_stagger import open_connection
from .interface import ITCPTransport, ITCPReader, ITCPWriter
from .security import tls_context
@ -34,9 +35,15 @@ class TCPTransport(ITCPTransport):
if tls:
cur_ssl = tls_context(tls_verify)
local_addr: Optional[Tuple[str, int]] = None
if not bindhost is None:
local_addr = (bindhost, 53567)
reader, writer = await open_connection(
hostname,
port,
ssl=cur_ssl,
local_addr=(bindhost, 0))
server_hostname=hostname,
ssl =cur_ssl,
local_addr =local_addr)
return (TCPReader(reader), TCPWriter(writer))

View file

@ -2,3 +2,4 @@ anyio ==1.3.0
asyncio-throttle ==1.0.1
dataclasses ==0.6
ircstates ==0.8.7
async_stagger ==0.3.0