From 69bb6e8bb4782cfbe9a12972684aa79c1fecfc5e Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 24 Feb 2025 02:09:42 -0700 Subject: [PATCH] a --- intercepting-communication/udp-1/run | 8 ++------ intercepting-communication/udp-2/run | 10 ++-------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/intercepting-communication/udp-1/run b/intercepting-communication/udp-1/run index 301ebd6..2928be7 100755 --- a/intercepting-communication/udp-1/run +++ b/intercepting-communication/udp-1/run @@ -16,12 +16,8 @@ class ServerHost(Host): while True: try: client_message, (client_host, client_port) = server_socket.recvfrom(1024) - while True: - if not client_message: - break - if client_message == b"Hello, World!\n": - server_socket.sendto(flag.encode(), (client_host, client_port)) - break + if client_message == b"Hello, World!\n": + server_socket.sendto(flag.encode(), (client_host, client_port)) except ConnectionError: continue diff --git a/intercepting-communication/udp-2/run b/intercepting-communication/udp-2/run index 050b92d..b149631 100755 --- a/intercepting-communication/udp-2/run +++ b/intercepting-communication/udp-2/run @@ -16,14 +16,8 @@ class ServerHost(Host): while True: try: client_message, (client_host, client_port) = server_socket.recvfrom(1024) - while True: - if client_port != 31338: - break - if not client_message: - break - if client_message == b"Hello, World!\n": - server_socket.sendto(flag.encode(), (client_host, client_port)) - break + if client_port == 31338 and client_message == b"Hello, World!\n": + server_socket.sendto(flag.encode(), (client_host, client_port)) except ConnectionError: continue