diff options
Diffstat (limited to 'src/ninep/screen.zig')
| -rw-r--r-- | src/ninep/screen.zig | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index ba676ded..22129546 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -63,15 +63,10 @@ pub fn listenersText(p: *Pardes, buf: []u8) []const u8 { var text = std.Io.Writer.fixed(buf); if (p.fs.socket_path.len != 0) text.print("unix!{s}\n", .{p.fs.socket_path}) catch return text.buffered(); - for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { - const address = maybe orelse continue; - switch (address) { - .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch - return text.buffered(), - .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch - return text.buffered(), - } - } + if (p.fs.tcp_address) |address| switch (address) { + .ip4 => |ip| text.print("tcp!{d}.{d}.{d}.{d}!{d}\n", .{ ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch {}, + .ip6 => |ip| text.print("tcp!{f}!{d}\n", .{ std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch {}, + }; return text.buffered(); } @@ -102,9 +97,8 @@ test "listener addresses are readable canonical dials with bounded partial reads const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); p.fs.socket_path = "/tmp/a socket.sock"; - p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; - p.fs.quic_address = .{ .ip6 = .loopback(5641) }; - const expected = "unix!/tmp/a socket.sock\ntcp!127.0.0.1!5640\nquic!::1!5641\n"; + p.fs.tcp_address = .{ .ip6 = .loopback(5641) }; + const expected = "unix!/tmp/a socket.sock\ntcp!::1!5641\n"; for ([_][]const u8{ "/virtual/listeners", "/n/self/listeners" }) |path| { const bytes = try fs.read(p, path); defer gpa.free(bytes); |
