| ... | @@ -310,6 +310,8 @@ pub const ResolvConf = struct { | ... | @@ -310,6 +310,8 @@ pub const ResolvConf = struct { |
| 310 | search_buffer: [max_len]u8, | 310 | search_buffer: [max_len]u8, |
| 311 | search_len: usize, | 311 | search_len: usize, |
| 312 | | 312 | |
| | 313 | /// According to resolv.conf(5) there is a maximum of 3 nameservers in this |
| | 314 | /// file. |
| 313 | pub const max_nameservers = 3; | 315 | pub const max_nameservers = 3; |
| 314 | | 316 | |
| 315 | /// Returns `error.StreamTooLong` if a line is longer than 512 bytes. | 317 | /// Returns `error.StreamTooLong` if a line is longer than 512 bytes. |
| ... | @@ -394,9 +396,10 @@ pub const ResolvConf = struct { | ... | @@ -394,9 +396,10 @@ pub const ResolvConf = struct { |
| 394 | } | 396 | } |
| 395 | | 397 | |
| 396 | fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void { | 398 | fn addNumeric(rc: *ResolvConf, io: Io, name: []const u8, port: u16) !void { |
| 397 | assert(rc.nameservers_len < rc.nameservers_buffer.len); | 399 | if (rc.nameservers_len < rc.nameservers_buffer.len) { |
| 398 | rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port); | 400 | rc.nameservers_buffer[rc.nameservers_len] = try .resolve(io, name, port); |
| 399 | rc.nameservers_len += 1; | 401 | rc.nameservers_len += 1; |
| | 402 | } |
| 400 | } | 403 | } |
| 401 | | 404 | |
| 402 | pub fn nameservers(rc: *const ResolvConf) []const IpAddress { | 405 | pub fn nameservers(rc: *const ResolvConf) []const IpAddress { |