Use FAIL as the default dest if unable to parse

This commit is contained in:
2025-04-27 16:11:12 -04:00
parent c34748dab3
commit 683a2015b0

View File

@@ -75,7 +75,7 @@ pub fn main() !void {
return clap.help(std.io.getStdErr().writer(), clap.Help, &params, .{});
}
fn parseDest(in: ?[]const u8) ![4]u8 {
fn parseDest(in: ?[]const u8) [4]u8 {
if (in) |dest| {
if (dest.len <= 4) {
var res: [4]u8 = @splat(0);
@@ -83,10 +83,10 @@ fn parseDest(in: ?[]const u8) ![4]u8 {
return res;
}
const addr = try std.net.Ip4Address.parse(dest, 0);
const addr = std.net.Ip4Address.parse(dest, 0) catch return "FAIL".*;
return @bitCast(addr.sa.addr);
}
return .{ 70, 70, 70, 70 };
return "zap".*;
}
const builtin = @import("builtin");