diff --git a/src/util.zig b/src/util.zig index ffac4bb..f6324b9 100644 --- a/src/util.zig +++ b/src/util.zig @@ -6,13 +6,11 @@ const ArgError = error{ NotEnoughArgs, BadDomain, InvalidAddressVer, - InterfaceRequired, - InvalidInterface, EnvVarNotSet, InvalidOldHostsPath, }; -pub const IP_VER_ENUM = enum(u3) { +pub const IP_VER = enum(u3) { Both = 0, IPv4 = 4, IPv6 = 6, @@ -30,11 +28,6 @@ pub fn merge_addrs(v4: IP, v6: IP) IP { }; } -pub const IPInfo = struct { - version: IP_VER_ENUM, - interface: ?[:0]const u8, -}; - pub const Domain = struct { name: [:0]const u8, labels: [5][]const u8, @@ -53,7 +46,7 @@ pub const cwd = std.fs.cwd(); pub fn get_input() !struct { Domain, - IPInfo, + IP_VER, } { var args = std.process.args(); _ = args.next(); // consume calling binary arg @@ -62,17 +55,9 @@ pub fn get_input() !struct { const domain = try check_domain(domain_str); const ip_ver_str = args.next() orelse return ArgError.NotEnoughArgs; - const ip_ver = std.meta.intToEnum(IP_VER_ENUM, std.fmt.parseInt(u3, ip_ver_str, 10) catch return ArgError.InvalidAddressVer) catch return ArgError.InvalidAddressVer; + const ip_ver = std.meta.intToEnum(IP_VER, std.fmt.parseInt(u3, ip_ver_str, 10) catch return ArgError.InvalidAddressVer) catch return ArgError.InvalidAddressVer; - var iface: ?[:0]const u8 = null; - if (ip_ver != IP_VER_ENUM.IPv4) { - iface = args.next() orelse return ArgError.InterfaceRequired; - if (std.c.if_nametoindex(iface.?) == 0) { - return ArgError.InvalidInterface; - } - } - - return .{ domain, IPInfo{ .version = ip_ver, .interface = iface } }; + return .{ domain, ip_ver }; } fn check_domain(domain_str: [:0]const u8) !Domain {