Skip to content

Commit

Permalink
feat: speed up auth phase (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 31, 2022
1 parent 10e8e52 commit 3eef636
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dbus_fast/aio/message_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ def done(fut):
async def _auth_readline(self) -> str:
buf = b""
while buf[-2:] != b"\r\n":
buf += await self._loop.sock_recv(self._sock, 2)
# The auth protocol is line based, so we can read until we get a
# newline.
buf += await self._loop.sock_recv(self._sock, 1024)
return buf[:-2].decode()

async def _authenticate(self) -> None:
Expand All @@ -455,6 +457,9 @@ async def _authenticate(self) -> None:
)
self._stream.flush()
if response == "BEGIN":
# The first octet received by the server after the \r\n of the BEGIN command
# from the client must be the first octet of the authenticated/encrypted stream
# of D-Bus messages.
break

def disconnect(self) -> None:
Expand Down

0 comments on commit 3eef636

Please sign in to comment.