summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rwxr-xr-xclient/client.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/client/client.py b/client/client.py
index 0388073..bc4da96 100755
--- a/client/client.py
+++ b/client/client.py
@@ -166,20 +166,27 @@ def main():
166 # Main loop 166 # Main loop
167 running = True 167 running = True
168 while running: 168 while running:
169 # Receive MFA prompt from server 169 try:
170 header = conn.recv(HEADER_LENGTH).decode(FORMAT) 170 # Receive MFA prompt from server
171 if header == "": 171 header = conn.recv(HEADER_LENGTH).decode(FORMAT)
172 die("error: lost connection to server") 172 if header == "":
173 prompt_len = int(header) 173 die("error: lost connection to server")
174 prompt = conn.recv(prompt_len).decode(FORMAT) 174 prompt_len = int(header)
175 # Ask user for response 175 prompt = conn.recv(prompt_len).decode(FORMAT)
176 answer = prompt_user(prompt) 176 # Ask user for response
177 # Send answer to MFA server 177 answer = prompt_user(prompt)
178 answer_length = len(answer) 178 # Send answer to MFA server
179 length_msg = str(answer_length) 179 length_msg = str(len(answer))
180 length_msg += ' ' * (HEADER_LENGTH - len(length_msg)) 180 # Handle very large input
181 conn.send(length_msg.encode(FORMAT)) 181 if len(length_msg) > HEADER_LENGTH:
182 conn.send(answer.encode(FORMAT)) 182 die("error: response too big")
183 length_msg += ' ' * (HEADER_LENGTH - len(length_msg))
184 conn.send(length_msg.encode(FORMAT))
185 conn.send(answer.encode(FORMAT))
186 except KeyboardInterrupt:
187 #conn.send(DISCONNECT_MESSAGE.encode(FORMAT))
188 conn.close()
189 die("")
183 190
184 191
185 192