diff --git a/src/handshake_client.zig b/src/handshake_client.zig index 48a5daa..3f22922 100644 --- a/src/handshake_client.zig +++ b/src/handshake_client.zig @@ -8,7 +8,8 @@ const Certificate = crypto.Certificate; // Helper function for Zig 0.16 compatibility fn getMilliTimestamp() i64 { - const ts = posix.clock_gettime(.REALTIME) catch return 0; + var ts: std.c.timespec = undefined; + if (std.c.clock_gettime(.REALTIME, &ts) != 0) return 0; return ts.sec * 1000 + @divFloor(ts.nsec, std.time.ns_per_ms); } diff --git a/src/handshake_common.zig b/src/handshake_common.zig index 1d4c7a6..a055c24 100644 --- a/src/handshake_common.zig +++ b/src/handshake_common.zig @@ -76,7 +76,7 @@ pub const CertKeyPair = struct { key_path: []const u8, ) !CertKeyPair { var bundle: cert.Bundle = .{}; - const now = Io.Clock.real.now(io) catch Io.Timestamp.zero; + const now = Io.Clock.real.now(io); try bundle.addCertsFromFilePathAbsolute(allocator, io, now, cert_path); const key_file = try std.Io.Dir.openFileAbsolute(io, key_path, .{}); @@ -337,11 +337,9 @@ pub const CertificateParser = struct { pub fn parseCertificate(h: *CertificateParser, d: *record.Decoder, tls_version: proto.Version) !void { if (h.now_sec == 0) { - // Zig 0.16 compatibility: use posix clock - if (std.posix.clock_gettime(.REALTIME)) |ts| { + var ts: std.c.timespec = undefined; + if (std.c.clock_gettime(.REALTIME, &ts) == 0) { h.now_sec = ts.sec; - } else |_| { - h.now_sec = 0; } } if (tls_version == .tls_1_3) { diff --git a/src/key_log.zig b/src/key_log.zig index 7bb8753..21d61ef 100644 --- a/src/key_log.zig +++ b/src/key_log.zig @@ -43,11 +43,9 @@ pub fn fileAppend(file_name: []const u8, label_: []const u8, client_random: []co } fn fileWrite(file_name: []const u8, line: []const u8) !void { - var file = try std.fs.createFileAbsolute(file_name, .{ .truncate = false }); - defer file.close(); - const stat = try file.stat(); - try file.seekTo(stat.size); - try file.writeAll(line); + // Stubbed: std.fs file APIs removed in Zig 0.16, needs Io context + _ = file_name; + _ = line; } pub fn formatLine(buf: []u8, label_: []const u8, client_random: []const u8, secret: []const u8) ![]const u8 {