aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/external-tests
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/external-tests')
-rw-r--r--contrib/external-tests/go/main.go12
-rw-r--r--contrib/external-tests/rust/src/main.rs11
2 files changed, 23 insertions, 0 deletions
diff --git a/contrib/external-tests/go/main.go b/contrib/external-tests/go/main.go
index 013a1a9..435063d 100644
--- a/contrib/external-tests/go/main.go
+++ b/contrib/external-tests/go/main.go
@@ -172,4 +172,16 @@ func main() {
if echo.ID != 921 || echo.Seq != 438 || string(echo.Data) != "WireGuard" {
log.Fatalf("incorrect echo response: %#v", echo)
}
+
+ keepalivePacket := make([]byte, 16)
+ keepalivePacket[0] = 4 // Type: Data
+ keepalivePacket[1] = 0 // Reserved
+ keepalivePacket[2] = 0 // Reserved
+ keepalivePacket[3] = 0 // Reserved
+ binary.LittleEndian.PutUint32(keepalivePacket[4:], theirIndex)
+ binary.LittleEndian.PutUint64(keepalivePacket[8:], 1) // Nonce
+ keepalivePacket = sendCipher.Encrypt(keepalivePacket, nil, nil) // Empty data means keepalive
+ if _, err := conn.Write(keepalivePacket); err != nil {
+ log.Fatalf("error writing keepalive message: %s", err)
+ }
}
diff --git a/contrib/external-tests/rust/src/main.rs b/contrib/external-tests/rust/src/main.rs
index 47c432f..9fb0f5a 100644
--- a/contrib/external-tests/rust/src/main.rs
+++ b/contrib/external-tests/rust/src/main.rs
@@ -123,4 +123,15 @@ fn main() {
assert!(icmp_reply.get_icmp_type() == IcmpTypes::EchoReply && icmp_reply.get_icmp_code() == echo_reply::IcmpCodes::NoCode);
assert!(icmp_reply.get_identifier() == 921 && icmp_reply.get_sequence_number() == 438);
assert!(icmp_reply.payload() == b"WireGuard");
+
+ let mut keepalive_packet = [0; 32];
+ keepalive_packet[0] = 4; /* Type: Data */
+ keepalive_packet[1] = 0; /* Reserved */
+ keepalive_packet[2] = 0; /* Reserved */
+ keepalive_packet[3] = 0; /* Reserved */
+ LittleEndian::write_u32(&mut keepalive_packet[4..], their_index);
+ LittleEndian::write_u64(&mut keepalive_packet[8..], 1);
+ let empty_payload = [0; 0]; /* Empty payload means keepalive */
+ noise.write_message(&empty_payload, &mut keepalive_packet[16..]).unwrap();
+ socket.send_to(&keepalive_packet, TEST_SERVER).unwrap();
}