Update configuration paths and enhance allocator handling in main.zig

This commit is contained in:
2026-08-01 22:01:48 +02:00
parent a7aa1517ca
commit 569700d6bd
2 changed files with 45 additions and 7 deletions

View File

@@ -1,8 +1,46 @@
const zocket = @import("zocket");
const std = @import("std");
const builtin = @import("builtin");
pub fn main(init: std.process.Init) !void
{
_ = init;
const io = init.io;
std.debug.print("{any}\n", .{builtin.mode});
if (builtin.mode == .Debug)
{
var arena: std.heap.DebugAllocator(.{}) = .init;
defer _ = arena.deinit();
try run(io, arena.allocator(), "zocket/config.toml");
}
else
{
var arena = std.heap.ArenaAllocator.init(std.heap.smp_allocator);
defer arena.deinit();
const allocator = arena.allocator();
var tmpArena = std.heap.ArenaAllocator.init(std.heap.smp_allocator);
const tmpAllocator = tmpArena.allocator();
const exe = try std.process.executableDirPathAlloc(io, tmpAllocator);
const path = try std.fs.path.join(allocator, &.{ exe, "zocket/config.toml" });
tmpArena.deinit();
try run(io, allocator, path);
}
}
fn run(io: std.Io, allocator: std.mem.Allocator, path: []const u8) !void
{
const parsed = try zocket.config.parse(io, allocator, path);
defer parsed.deinit();
const configuration = parsed.value;
std.debug.print("{any}", .{configuration});
}

View File

@@ -1,7 +1,7 @@
[node]
id = "node-01"
data_dir = "/var/lib/wsmesh" # /$data_dir/$id/*
private_key = "/var/lib/wsmesh/node-01/identity.key" # ed25519, auto-generated on first run if missing, default = /$data_dir/$id/identity.key
data_dir = "/var/lib/zocket" # /$data_dir/$id/*
private_key = "/var/lib/zocket/node-01/identity.key" # ed25519, auto-generated on first run if missing, default = /$data_dir/$id/identity.key
# DEFAULT ASSUMPTION: ephemeral.
# A fresh keypair each restart is fine and expected as nothing is persisted to disk on purpose
# (see mesh.discoverability + mesh.trust below), everything mesh-wide is rediscovered via
@@ -25,8 +25,8 @@ bind = "0.0.0.0:8080"
[listen.client.tls]
enabled = false
cert = "/etc/wsmesh/client.crt"
key = "/etc/wsmesh/client.key"
cert = "/etc/zocket/client.crt"
key = "/etc/zocket/client.key"
[listen.client.auth]
mode = "token" # none | token
@@ -69,8 +69,8 @@ bind = "0.0.0.0:8181"
[listen.peer.tls]
enabled = false
cert = "/etc/wsmesh/peer.crt"
key = "/etc/wsmesh/peer.key"
cert = "/etc/zocket/peer.crt"
key = "/etc/zocket/peer.key"
require_client_cert = false
[listen.peer.auth]