Security: SecureSession

Make security sessions(secio, noise) share the same implementation
`BaseSession` to avoid duplicate implementation of buffered read.
This commit is contained in:
mhchia
2020-02-17 23:33:45 +08:00
parent 2df47a943c
commit 3c2e835725
8 changed files with 150 additions and 196 deletions

View File

@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
class Closer(ABC):
@abstractmethod
async def close(self) -> None:
...
@ -39,10 +40,6 @@ class MsgReader(ABC):
async def read_msg(self) -> bytes:
...
# @abstractmethod
# async def next_msg_len(self) -> int:
# ...
class MsgWriter(ABC):
@abstractmethod
@ -50,7 +47,7 @@ class MsgWriter(ABC):
...
class MsgReadWriter(MsgReader, MsgWriter):
class MsgReadWriteCloser(MsgReader, MsgWriter, Closer):
pass
@ -64,5 +61,5 @@ class Encrypter(ABC):
...
class EncryptedMsgReadWriter(MsgReadWriter, Encrypter):
pass
class EncryptedMsgReadWriter(MsgReadWriteCloser, Encrypter):
"""Read/write message with encryption/decryption."""