Support custom event loops

This commit is contained in:
Lonami Exo
2018-06-14 19:35:12 +02:00
parent 908dfa148b
commit 0f14f3b16a
11 changed files with 48 additions and 40 deletions

View File

@@ -12,8 +12,8 @@ class ConnectionTcpObfuscated(ConnectionTcpAbridged):
every message with a randomly generated key using the
AES-CTR mode so the packets are harder to discern.
"""
def __init__(self, proxy=None, timeout=timedelta(seconds=5)):
super().__init__(proxy, timeout)
def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)):
super().__init__(loop=loop, proxy=proxy, timeout=timeout)
self._aes_encrypt, self._aes_decrypt = None, None
self.read = lambda s: self._aes_decrypt.encrypt(self.conn.read(s))
self.write = lambda d: self.conn.write(self._aes_encrypt.encrypt(d))
@@ -45,6 +45,3 @@ class ConnectionTcpObfuscated(ConnectionTcpAbridged):
random[56:64] = self._aes_encrypt.encrypt(bytes(random))[56:64]
await self.conn.write(bytes(random))
return result
def clone(self):
return ConnectionTcpObfuscated(self._proxy, self._timeout)