Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed May 29, 2023
1 parent dad8940 commit a4e35ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ Module.symvers
Mkfile.old
dkms.conf
zig-*
wg.*
6 changes: 2 additions & 4 deletions test/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,18 @@ fn list_devices() void {
log.err("Unable to get device", .{});
continue;
}
var msg: []const u8 = undefined;
if ((device.*.flags & wireguard.WGDEVICE_HAS_PUBLIC_KEY) != 0) {
wireguard.wg_key_to_base64(@ptrCast([*c]u8, &key), &device.*.public_key);

var bf: [key.len]u8 = undefined;
msg = std.fmt.bufPrint(&bf, "{s} has public key {s}", .{ device_name, @ptrCast([*c]u8, &key) }) catch unreachable;
log.info("{s} has public key {s}", .{ device_name, @ptrCast([*c]u8, &key) });
} else {
log.info("{s} has no public key.", .{device_name});
}
{
peer = device.*.first_peer;
while (peer != null) : (peer = peer.*.next_peer) {
wireguard.wg_key_to_base64(@ptrCast([*c]u8, &key), @ptrCast([*c]u8, &peer.*.public_key));
log.info("{s} - peer {s}", .{ msg, @ptrCast([*c]u8, &key) });
std.debug.print("- peer {s}", .{@ptrCast([*c]u8, &key)});
}
}
wireguard.wg_free_device(device);
Expand Down

0 comments on commit a4e35ec

Please sign in to comment.