diff options
author | Jake McGinty <me@jake.su> | 2018-05-08 22:32:50 -0700 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-05-08 22:32:50 -0700 |
commit | 9edd08c8d33edefc815af2801e35e86ec702d944 (patch) | |
tree | bcd907effa2cc3b09f16d9de792c6366d43164d4 | |
parent | tests: add basic persistent keepalive timer test (diff) | |
download | wireguard-rs-9edd08c8d33edefc815af2801e35e86ec702d944.tar.xz wireguard-rs-9edd08c8d33edefc815af2801e35e86ec702d944.zip |
tests: simulate stale session recovery (dropped keepalive packet)
-rwxr-xr-x | tests/timers.sh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/timers.sh b/tests/timers.sh index 3922f93..1337197 100755 --- a/tests/timers.sh +++ b/tests/timers.sh @@ -190,17 +190,29 @@ packets2to1=$(tcpdump -r $pcap 2>/dev/null | grep "localhost.20000 > " | wc -l) packets1to2=$(tcpdump -r $pcap 2>/dev/null | grep "localhost.10000 > " | wc -l) [[ $packets2to1 -eq 21 && $packets1to2 -eq 22 ]] +section "testing stale session re-key trigger" +n1 ping -c 1 -f -W 1 192.168.241.2 +sleep 1 +n0 iptables -A INPUT -p udp --destination-port 20000 -s 127.0.0.1 -j DROP # block passive keepalive to trigger stale session re-key +sleep 11 +n0 iptables -D INPUT -p udp --destination-port 20000 -s 127.0.0.1 -j DROP # back to normal +sleep 7 + +tcpdump -r $pcap 2>/dev/null | tail -3 | grep "localhost.20000 > localhost.10000: UDP, length 148" > /dev/null +tcpdump -r $pcap 2>/dev/null | tail -2 | grep "localhost.10000 > localhost.20000: UDP, length 92" > /dev/null +tcpdump -r $pcap 2>/dev/null | tail -1 | grep "localhost.20000 > localhost.10000" > /dev/null + section "testing immediate send of persistent keepalive when set" n1 wg set wg1 peer "$pub2" persistent-keepalive 5 sleep 1 keepalives=$(tcpdump -r $pcap 2>/dev/null | grep "UDP, length 32" | wc -l) echo "keepalives $keepalives" -[[ $keepalives -eq 2 ]] +[[ $keepalives -eq 4 ]] section "waiting for the following persistent keepalive" sleep 6 keepalives=$(tcpdump -r $pcap 2>/dev/null | grep "UDP, length 32" | wc -l) echo "keepalives $keepalives" -[[ $keepalives -eq 3 ]] +[[ $keepalives -eq 5 ]] section "ALL TESTS PASSED!" |