mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
std.Io.net.HostName.ResolvConf: ignore nameservers above max
This commit is contained in:
parent
83e4ff6f4c
commit
b215f8667a
@ -310,6 +310,8 @@ pub const ResolvConf = struct {
|
|||||||
search_buffer: [max_len]u8,
|
search_buffer: [max_len]u8,
|
||||||
search_len: usize,
|
search_len: usize,
|
||||||
|
|
||||||
|
/// According to resolv.conf(5) there is a maximum of 3 nameservers in this
|
||||||
|
/// file.
|
||||||
pub const max_nameservers = 3;
|
pub const max_nameservers = 3;
|
||||||
|
|
||||||
/// Returns `error.StreamTooLong` if a line is longer than 512 bytes.
|
/// Returns `error.StreamTooLong` if a line is longer than 512 bytes.
|
||||||
@ -394,9 +396,10 @@ pub const ResolvConf = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void {
|
fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void {
|
||||||
assert(rc.nameservers_len < rc.nameservers_buffer.len);
|
if (rc.nameservers_len < rc.nameservers_buffer.len) {
|
||||||
rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port);
|
rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port);
|
||||||
rc.nameservers_len += 1;
|
rc.nameservers_len += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nameservers(rc: *const ResolvConf) []const IpAddress {
|
pub fn nameservers(rc: *const ResolvConf) []const IpAddress {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user