Update configuration paths and enhance allocator handling in main.zig
This commit is contained in:
40
src/main.zig
40
src/main.zig
@@ -1,8 +1,46 @@
|
|||||||
const zocket = @import("zocket");
|
const zocket = @import("zocket");
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
pub fn main(init: std.process.Init) !void
|
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});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[node]
|
[node]
|
||||||
id = "node-01"
|
id = "node-01"
|
||||||
data_dir = "/var/lib/wsmesh" # /$data_dir/$id/*
|
data_dir = "/var/lib/zocket" # /$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
|
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.
|
# DEFAULT ASSUMPTION: ephemeral.
|
||||||
# A fresh keypair each restart is fine and expected as nothing is persisted to disk on purpose
|
# 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
|
# (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]
|
[listen.client.tls]
|
||||||
enabled = false
|
enabled = false
|
||||||
cert = "/etc/wsmesh/client.crt"
|
cert = "/etc/zocket/client.crt"
|
||||||
key = "/etc/wsmesh/client.key"
|
key = "/etc/zocket/client.key"
|
||||||
|
|
||||||
[listen.client.auth]
|
[listen.client.auth]
|
||||||
mode = "token" # none | token
|
mode = "token" # none | token
|
||||||
@@ -69,8 +69,8 @@ bind = "0.0.0.0:8181"
|
|||||||
|
|
||||||
[listen.peer.tls]
|
[listen.peer.tls]
|
||||||
enabled = false
|
enabled = false
|
||||||
cert = "/etc/wsmesh/peer.crt"
|
cert = "/etc/zocket/peer.crt"
|
||||||
key = "/etc/wsmesh/peer.key"
|
key = "/etc/zocket/peer.key"
|
||||||
require_client_cert = false
|
require_client_cert = false
|
||||||
|
|
||||||
[listen.peer.auth]
|
[listen.peer.auth]
|
||||||
|
|||||||
Reference in New Issue
Block a user