Use more relevant names for Connection fields
This commit is contained in:
parent
6ab60c0d36
commit
ead0b4f029
@ -40,17 +40,17 @@ class Connection:
|
||||
self.proxy = proxy
|
||||
self.mode = self.MODES.get(mode, TCPAbridged)
|
||||
|
||||
self.connection = None # type: TCP
|
||||
self.protocol = None # type: TCP
|
||||
|
||||
async def connect(self):
|
||||
for i in range(Connection.MAX_RETRIES):
|
||||
self.connection = self.mode(self.proxy)
|
||||
self.protocol = self.mode(self.proxy)
|
||||
|
||||
try:
|
||||
log.info("Connecting...")
|
||||
await self.connection.connect(self.address)
|
||||
await self.protocol.connect(self.address)
|
||||
except OSError:
|
||||
self.connection.close()
|
||||
self.protocol.close()
|
||||
await asyncio.sleep(1)
|
||||
else:
|
||||
break
|
||||
@ -58,11 +58,11 @@ class Connection:
|
||||
raise TimeoutError
|
||||
|
||||
def close(self):
|
||||
self.connection.close()
|
||||
self.protocol.close()
|
||||
log.info("Disconnected")
|
||||
|
||||
async def send(self, data: bytes):
|
||||
await self.connection.send(data)
|
||||
await self.protocol.send(data)
|
||||
|
||||
async def recv(self) -> bytes or None:
|
||||
return await self.connection.recv()
|
||||
return await self.protocol.recv()
|
||||
|
Loading…
Reference in New Issue
Block a user