Browse Source
Merge pull request #3 from dathost/master
Wait for auth response packet
pull/7/head
Richard Neumann
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
1 deletions
-
rcon/client.py
|
|
@ -4,7 +4,7 @@ from socket import socket |
|
|
|
from typing import Optional |
|
|
|
|
|
|
|
from rcon.exceptions import RequestIdMismatch, WrongPassword |
|
|
|
from rcon.proto import Packet |
|
|
|
from rcon.proto import Packet, Type |
|
|
|
|
|
|
|
|
|
|
|
__all__ = ['Client'] |
|
|
@ -63,6 +63,9 @@ class Client: |
|
|
|
with self._socket.makefile('wb') as file: |
|
|
|
file.write(bytes(packet)) |
|
|
|
|
|
|
|
return self.read() |
|
|
|
|
|
|
|
def read(self) -> Packet: |
|
|
|
with self._socket.makefile('rb') as file: |
|
|
|
return Packet.read(file) |
|
|
|
|
|
|
@ -70,6 +73,9 @@ class Client: |
|
|
|
"""Performs a login.""" |
|
|
|
response = self.communicate(Packet.make_login(passwd)) |
|
|
|
|
|
|
|
while response.type != Type.SERVERDATA_AUTH_RESPONSE: |
|
|
|
response = self.read() |
|
|
|
|
|
|
|
if response.id == -1: |
|
|
|
raise WrongPassword() |
|
|
|
|
|
|
|