From 753653b4df62723b82d32799825135822886eac7 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 3 Sep 2026 16:20:23 +0200 Subject: refactor(node): platform abstraction for Windows portability (W1-W2-W5-W6-W7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Platform directories, signal handling, chmod guards, ffmpeg discovery, and platform-conditional CLI messages — all testable on Linux. See docs/WINDOWS-PORT.md §5 for the plan these implement. Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-node/src/meshbay_node/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'packages/meshbay-node/src/meshbay_node/config.py') diff --git a/packages/meshbay-node/src/meshbay_node/config.py b/packages/meshbay-node/src/meshbay_node/config.py index 78ee873..cfbec50 100644 --- a/packages/meshbay-node/src/meshbay_node/config.py +++ b/packages/meshbay-node/src/meshbay_node/config.py @@ -11,6 +11,8 @@ import os from dataclasses import dataclass, field from pathlib import Path +from meshbay_node.platform import config_dir, data_dir + try: import tomllib # Python 3.11+ except ImportError: @@ -25,7 +27,7 @@ DEFAULT_STUN_SERVERS: list[str] = [ "stun:stun.services.mozilla.com:3478", ] -DEFAULT_CONFIG_PATH = Path.home() / ".config" / "meshbay" / "node.toml" +DEFAULT_CONFIG_PATH = config_dir() / "node.toml" EXAMPLE_CONFIG = """\ # MeshBay Node configuration — multi-group example @@ -169,6 +171,8 @@ class NodeConfig: # machine with a Tailscale wt0 interface. ice_interfaces: list[str] = field(default_factory=list) # include-list overrides auto stun_servers: list[str] = field(default_factory=list) # empty = DEFAULT_STUN_SERVERS + ffmpeg_path: str = "ffmpeg" + ffprobe_path: str = "ffprobe" @dataclass @@ -234,7 +238,7 @@ class Config: node: NodeConfig = field(default_factory=NodeConfig) groups: list[GroupConfig] = field(default_factory=list) keystore: KeystoreConfig = field(default_factory=KeystoreConfig) - data_dir: Path = field(default_factory=lambda: Path.home() / ".local" / "share" / "meshbay") + data_dir: Path = field(default_factory=data_dir) # Back-compat: single-group access @property @@ -333,6 +337,10 @@ def load_config(path: Path = DEFAULT_CONFIG_PATH) -> Config: stun = nd.get("stun_servers") if isinstance(stun, list): cfg.node.stun_servers = [str(s) for s in stun] + if "ffmpeg_path" in nd: + cfg.node.ffmpeg_path = str(nd["ffmpeg_path"]) + if "ffprobe_path" in nd: + cfg.node.ffprobe_path = str(nd["ffprobe_path"]) # Multi-group: [[groups]] array if "groups" in raw: -- cgit v1.2.3