summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ttun/__main__.py2
-rw-r--r--ttun/client.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/ttun/__main__.py b/ttun/__main__.py
index cbf8e16..62664a3 100644
--- a/ttun/__main__.py
+++ b/ttun/__main__.py
@@ -66,7 +66,7 @@ def main():
66 66
67 server = Server( 67 server = Server(
68 config=client.config, 68 config=client.config,
69 on_resend=client.proxy_request, 69 on_resend=client.resend,
70 on_started=print_info, 70 on_started=print_info,
71 ) 71 )
72 72
diff --git a/ttun/client.py b/ttun/client.py
index 9e597ab..5434f0e 100644
--- a/ttun/client.py
+++ b/ttun/client.py
@@ -72,10 +72,11 @@ class Client:
72 if self.connection.open: 72 if self.connection.open:
73 return self.connection 73 return self.connection
74 74
75 def session(self):
76 return ClientSession(base_url=self.proxy_origin, cookie_jar=DummyCookieJar())
77
75 async def handle_messages(self): 78 async def handle_messages(self):
76 async with ClientSession( 79 async with self.session() as session:
77 base_url=self.proxy_origin, cookie_jar=DummyCookieJar()
78 ) as session:
79 while True: 80 while True:
80 try: 81 try:
81 request: RequestData = await self.receive() 82 request: RequestData = await self.receive()
@@ -87,6 +88,10 @@ class Client:
87 except ConnectionClosed: 88 except ConnectionClosed:
88 break 89 break
89 90
91 async def resend(self, data: RequestData):
92 async with self.session() as session:
93 await self.proxy_request(session, data)
94
90 async def proxy_request( 95 async def proxy_request(
91 self, 96 self,
92 session: ClientSession, 97 session: ClientSession,