Skip to content

Commit

Permalink
fake server: wait to become ready when setting username and password
Browse files Browse the repository at this point in the history
  • Loading branch information
spameier committed Dec 20, 2022
1 parent 5ed64f6 commit a248c27
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pyrdp/mitm/FakeServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,21 @@ def resize(self, width: int, height: int):
def check_submit(self):
self.fakeLoginScreen.check_submit()

def is_ready(self):
return self.fakeLoginScreen is not None

def wait_ready(self):
# wait until the server and the login screen is initialized
while not self.is_ready():
time.sleep(0.01)

def set_username(self, username: str):
# FIXME: properly solve this concurrency
if self.fakeLoginScreen is None:
time.sleep(0.1)
if self.fakeLoginScreen is not None:
self.fakeLoginScreen.set_username(username)
self.check_submit()
self.wait_ready()
self.fakeLoginScreen.set_username(username)
self.check_submit()

def set_password(self, password: str):
self.wait_ready()
self.fakeLoginScreen.set_password(password)
self.check_submit()

Expand Down

0 comments on commit a248c27

Please sign in to comment.