feat: nomad
This commit is contained in:
@@ -181,16 +181,17 @@ def start_browser() -> None:
|
|||||||
# Config helpers
|
# Config helpers
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
def _rns_config_path() -> Path:
|
_CONFIG_PATHS = {
|
||||||
"""Return the path to the RNS config file."""
|
"reticulum": lambda: Path(os.environ.get("RNS_SERVER_CONFIG_DIR", os.environ.get("RNS_CONFIG_DIR", str(Path.home() / ".reticulum")))) / "config",
|
||||||
configdir = os.environ.get("RNS_CONFIG_DIR", str(Path.home() / ".reticulum"))
|
"nomadnet": lambda: Path(os.environ.get("NOMADNET_CONFIG_DIR", str(Path.home() / ".nomadnetwork"))) / "config",
|
||||||
return Path(configdir) / "config"
|
}
|
||||||
|
|
||||||
|
|
||||||
def _nomadnet_config_path() -> Path:
|
def _config_path(kind: str) -> Path:
|
||||||
"""Return the path to the NomadNet config file."""
|
resolver = _CONFIG_PATHS.get(kind)
|
||||||
configdir = os.environ.get("NOMADNET_CONFIG_DIR", str(Path.home() / ".nomadnetwork"))
|
if not resolver:
|
||||||
return Path(configdir) / "config"
|
raise ValueError(f"Unknown config kind: {kind}")
|
||||||
|
return resolver()
|
||||||
|
|
||||||
|
|
||||||
def _restart_nomadnet() -> bool:
|
def _restart_nomadnet() -> bool:
|
||||||
@@ -405,46 +406,27 @@ async def _request_remote_page(hash_hex: str, path: str) -> str | None:
|
|||||||
# Reticulum config endpoints
|
# Reticulum config endpoints
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@router.get("/browse/config/reticulum")
|
@router.post("/browse/restart")
|
||||||
async def get_reticulum_config():
|
|
||||||
"""Return the current Reticulum config file contents."""
|
|
||||||
path = _rns_config_path()
|
|
||||||
if not path.exists():
|
|
||||||
return {"content": ""}
|
|
||||||
return {"content": path.read_text(encoding="utf-8")}
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/browse/config/reticulum")
|
|
||||||
async def save_reticulum_config(body: dict):
|
|
||||||
"""Write Reticulum config."""
|
|
||||||
content = body.get("content", "")
|
|
||||||
path = _rns_config_path()
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
path.write_text(content, encoding="utf-8")
|
|
||||||
return {"ok": True}
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/browse/config/nomadnet")
|
|
||||||
async def get_nomadnet_config():
|
|
||||||
"""Return the current NomadNet config file contents."""
|
|
||||||
path = _nomadnet_config_path()
|
|
||||||
if not path.exists():
|
|
||||||
return {"content": ""}
|
|
||||||
return {"content": path.read_text(encoding="utf-8")}
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/browse/config/nomadnet")
|
|
||||||
async def save_nomadnet_config(body: dict):
|
|
||||||
"""Write NomadNet config."""
|
|
||||||
content = body.get("content", "")
|
|
||||||
path = _nomadnet_config_path()
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
path.write_text(content, encoding="utf-8")
|
|
||||||
return {"ok": True}
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/browse/config/restart")
|
|
||||||
async def restart_services():
|
async def restart_services():
|
||||||
"""Restart NomadNet to apply config changes."""
|
"""Restart NomadNet to apply config changes."""
|
||||||
restarted = _restart_nomadnet()
|
restarted = _restart_nomadnet()
|
||||||
return {"ok": True, "nomadnet_restarted": restarted}
|
return {"ok": True, "nomadnet_restarted": restarted}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/browse/config/{kind}")
|
||||||
|
async def get_config(kind: str):
|
||||||
|
"""Return config file contents for reticulum or nomadnet."""
|
||||||
|
path = _config_path(kind)
|
||||||
|
if not path.exists():
|
||||||
|
return {"content": ""}
|
||||||
|
return {"content": path.read_text(encoding="utf-8")}
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/browse/config/{kind}")
|
||||||
|
async def save_config(kind: str, body: dict):
|
||||||
|
"""Write config file for reticulum or nomadnet."""
|
||||||
|
content = body.get("content", "")
|
||||||
|
path = _config_path(kind)
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text(content, encoding="utf-8")
|
||||||
|
return {"ok": True}
|
||||||
|
|||||||
10
compose.yml
10
compose.yml
@@ -10,17 +10,19 @@ services:
|
|||||||
- SOURCES_DIR=/data/sources
|
- SOURCES_DIR=/data/sources
|
||||||
- NOMADNET_CONTAINER=nomadnet
|
- NOMADNET_CONTAINER=nomadnet
|
||||||
- RNS_CONFIG_DIR=/rns
|
- RNS_CONFIG_DIR=/rns
|
||||||
|
- RNS_SERVER_CONFIG_DIR=/rns-server
|
||||||
- NOMADNET_CONFIG_DIR=/nomadnet
|
- NOMADNET_CONFIG_DIR=/nomadnet
|
||||||
- LOG_LEVEL=DEBUG
|
- LOG_LEVEL=DEBUG
|
||||||
volumes:
|
volumes:
|
||||||
- pages:/data/pages
|
- pages:/data/pages
|
||||||
- sources:/data/sources
|
- sources:/data/sources
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
- reticulum:/rns
|
- ./reticulum-client.conf:/rns/config
|
||||||
- ./reticulum.conf:/rns/config
|
- ./reticulum.conf:/rns-server/config
|
||||||
- nomadnet-config:/nomadnet
|
|
||||||
- ./nomadnet.conf:/nomadnet/config
|
- ./nomadnet.conf:/nomadnet/config
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- nomadnet
|
||||||
|
|
||||||
nomadnet:
|
nomadnet:
|
||||||
image: ghcr.io/markqvist/nomadnet:latest
|
image: ghcr.io/markqvist/nomadnet:latest
|
||||||
@@ -30,7 +32,6 @@ services:
|
|||||||
- pages:/root/.nomadnetwork/storage/pages
|
- pages:/root/.nomadnetwork/storage/pages
|
||||||
- nomadnet-config:/root/.nomadnetwork
|
- nomadnet-config:/root/.nomadnetwork
|
||||||
- ./nomadnet.conf:/root/.nomadnetwork/config
|
- ./nomadnet.conf:/root/.nomadnetwork/config
|
||||||
- reticulum:/root/.reticulum
|
|
||||||
- ./reticulum.conf:/root/.reticulum/config
|
- ./reticulum.conf:/root/.reticulum/config
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
@@ -38,4 +39,3 @@ volumes:
|
|||||||
pages:
|
pages:
|
||||||
sources:
|
sources:
|
||||||
nomadnet-config:
|
nomadnet-config:
|
||||||
reticulum:
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ export async function saveConfig(kind: "reticulum" | "nomadnet", content: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function restartServices(): Promise<{ nomadnet_restarted: boolean }> {
|
export async function restartServices(): Promise<{ nomadnet_restarted: boolean }> {
|
||||||
const res = await fetch("/api/browse/config/restart", { method: "POST" });
|
const res = await fetch("/api/browse/restart", { method: "POST" });
|
||||||
if (!res.ok) throw new Error(await res.text());
|
if (!res.ok) throw new Error(await res.text());
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|||||||
23
reticulum-client.conf
Normal file
23
reticulum-client.conf
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[reticulum]
|
||||||
|
enable_transport = False
|
||||||
|
share_instance = No
|
||||||
|
|
||||||
|
[logging]
|
||||||
|
loglevel = 4
|
||||||
|
|
||||||
|
[interfaces]
|
||||||
|
# Connect to NomadNet's TCP server
|
||||||
|
[[NomadNet Link]]
|
||||||
|
type = TCPClientInterface
|
||||||
|
enabled = Yes
|
||||||
|
target_host = nomadnet
|
||||||
|
target_port = 4242
|
||||||
|
|
||||||
|
[[Quad4]]
|
||||||
|
type = TCPClientInterface
|
||||||
|
interface_enabled = true
|
||||||
|
target_host = 62.151.179.77
|
||||||
|
target_port = 45657
|
||||||
|
mode = full
|
||||||
|
name = Quad4
|
||||||
|
selected_interface_mode = 1
|
||||||
@@ -14,24 +14,3 @@
|
|||||||
listen_ip = 0.0.0.0
|
listen_ip = 0.0.0.0
|
||||||
listen_port = 4242
|
listen_port = 4242
|
||||||
|
|
||||||
[[Quad4]]
|
|
||||||
type = TCPClientInterface
|
|
||||||
interface_enabled = true
|
|
||||||
target_host = 62.151.179.77
|
|
||||||
target_port = 45657
|
|
||||||
mode = full
|
|
||||||
name = Quad4
|
|
||||||
selected_interface_mode = 1
|
|
||||||
|
|
||||||
[[Hispagatos_org_HQ]]
|
|
||||||
type = BackboneInterface
|
|
||||||
enabled = yes
|
|
||||||
remote = reticulum.hispagatos.org
|
|
||||||
target_port = 4242
|
|
||||||
transport_identity = 305c8452b222c9d367bc9e482956a4fa
|
|
||||||
|
|
||||||
[[NomadNet Link]]
|
|
||||||
type = TCPClientInterface
|
|
||||||
enabled = Yes
|
|
||||||
target_host = nomadnet
|
|
||||||
target_port = 4242
|
|
||||||
|
|||||||
Reference in New Issue
Block a user