From d0774ff2b331a8f09ad6061980c49fa4083a0cee Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 25 Jan 2026 08:30:39 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactored=20W?= =?UTF-8?q?OL=20packet=20capture=20and=20validation=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improved the efficiency and readability of the WOL packet handling by refactoring the existing code. This includes restructuring the validation logic and optimizing the capture process. --- tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index cc0c0a5..16e7e4d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -115,11 +115,11 @@ WOL Mode: {{ wol_mode }} MAC Addresses: {{ wol_mac_addresses | join(', ') }} - - name: Start tcpdump to capture WOL packet become: true ansible.builtin.shell: | - tcpdump -i {{ en_interfaces[0] }} -nn -c 1 udp port {{ wol_port }} + timeout 10 tcpdump -i {{ en_interfaces[0] }} -nn -c 1 \ + 'udp and port {{ wol_port }} and (udp[8:4] = 0xffffffff)' register: tcpdump_result async: 12 poll: 0 @@ -142,6 +142,6 @@ - name: Check if WOL packet was received ansible.builtin.assert: that: - - "'UDP' in tcpdump_status.stdout" - success_msg: "✅ Wake-on-LAN packet received by host" - fail_msg: "❌ No Wake-on-LAN packet detected" \ No newline at end of file + - tcpdump_status.rc == 0 + success_msg: "✅ Wake-on-LAN magic packet received by host" + fail_msg: "❌ Wake-on-LAN magic packet NOT detected" \ No newline at end of file