Use more relevant names for Connection fields

This commit is contained in:
Dan 2018-06-10 16:15:19 +02:00
parent 6ab60c0d36
commit ead0b4f029

View File

@ -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()