This commit is contained in:
tuxgyver
2026-06-29 10:19:16 +02:00
parent 2f9ca6b553
commit ea2e6d772b
5 changed files with 82 additions and 33 deletions
+4 -18
View File
@@ -48,11 +48,7 @@ def build_client_config(cfg: Config) -> str:
def get_client_config_path(cfg: Config) -> str:
name = cfg.wg.get("interface_name", "wgs0")
if is_windows():
config_dir = get_config_dir()
else:
config_dir = get_wg_config_dir()
return os.path.join(config_dir, f"{name}.conf")
return os.path.join(get_config_dir(), f"{name}.conf")
def write_client_config(cfg: Config) -> tuple[bool, str]:
@@ -65,18 +61,8 @@ def write_client_config(cfg: Config) -> tuple[bool, str]:
if not is_windows():
os.chmod(path, 0o600)
return True, path
except PermissionError:
# Écriture via sudo sur Linux
config_dir_path = get_config_dir()
tmp = os.path.join(config_dir_path, "wgs_tmp.conf")
with open(tmp, "w") as f:
f.write(content)
code, _, err = run_privileged(["cp", tmp, path])
os.unlink(tmp)
if code == 0:
run_privileged(["chmod", "600", path])
return True, path
return False, err
except Exception as e:
return False, str(e)
def is_connected(cfg: Config) -> bool:
@@ -341,7 +327,7 @@ def generate_server_config(
"[Peer]",
f"PublicKey = {srv_pub}",
f"PresharedKey = {psk}",
"AllowedIPs = 0.0.0.0/0",
"AllowedIPs = 10.8.0.0/24",
"Endpoint = <SERVER_IP>:" + str(server_port),
"PersistentKeepalive = 25",
])