Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/handshake_client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 3 additions & 5 deletions src/handshake_common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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, .{});
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 3 additions & 5 deletions src/key_log.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down