Skip to content

Real-time network monitor + outbound firewall — see & block every connection. Privacy-first, local-first, Rust fleet agent, SIEM exports, 8 languages. / Moniteur réseau temps réel + pare-feu sortant, agent de flotte Rust, exports SIEM. 100 % local.

ux: local node shows the display name, not the sanitized hostname

MoneyLisafa68a63cc9b5
diff --git a/backend/api/main.py b/backend/api/main.py
index 3f92efb..fcd351b 100644
--- a/backend/api/main.py
+++ b/backend/api/main.py
@@ -64,6 +64,8 @@ import logging
import os
import queue
import socket
+import subprocess
+import sys
import threading
import time
from contextlib import asynccontextmanager
@@ -246,8 +248,43 @@ _gateway_cache: dict = {"ip": None, "ts": 0.0}
def _local_hostname() -> str:
- """EN: This machine's display name, minus the mDNS ".local" suffix.
- FR: Le nom d'affichage de cette machine, sans le suffixe mDNS « .local »."""
+ """
+ EN: This machine's DISPLAY name — the one the user actually set:
+ macOS : `scutil --get ComputerName` ("MoneyLi$a")
+ Windows : COMPUTERNAME env var ("DESKTOP-ABC")
+ Linux : `hostnamectl --pretty` (may hold spaces/unicode)
+ socket.gethostname() is the FALLBACK — it returns the DNS-sanitized
+ hostname (no $, no spaces), which is not what users recognize.
+ FR: Le nom d'AFFICHAGE de cette machine — celui que l'utilisateur a
+ réellement défini :
+ macOS : `scutil --get ComputerName` (« MoneyLi$a »)
+ Windows : variable d'env COMPUTERNAME (« DESKTOP-ABC »)
+ Linux : `hostnamectl --pretty` (espaces/unicode possibles)
+ socket.gethostname() est le REPLI — il renvoie le hostname sanitisé
+ DNS (ni $ ni espaces), que l'utilisateur ne reconnaît pas.
+ """
+ try:
+ if sys.platform == "darwin":
+ out = subprocess.run(["scutil", "--get", "ComputerName"],
+ capture_output=True, text=True,
+ timeout=3).stdout.strip()
+ if out:
+ return out
+ elif sys.platform.startswith("win"):
+ name = os.environ.get("COMPUTERNAME", "").strip()
+ if name:
+ return name
+ elif sys.platform.startswith("linux"):
+ try:
+ out = subprocess.run(["hostnamectl", "--pretty"],
+ capture_output=True, text=True,
+ timeout=3).stdout.strip()
+ if out:
+ return out
+ except (OSError, subprocess.TimeoutExpired):
+ pass
+ except (OSError, subprocess.TimeoutExpired):
+ pass
try:
return socket.gethostname().removesuffix(".local")
except OSError: