1.0.2 - fix network settings, permissions and branding
Wydanie WGTools-Extended / release (push) Successful in 14s

This commit is contained in:
asminme committed 2026-10-30 02:14:52 +01:00
1 parent 9c23169339
commit aadc19341d
18 files changed
+241 -80

No files matched your search

+22 -6
View File
@@ -192,6 +192,10 @@ class CreateServerRequest(BaseModel):
policy_table: str = Field(default="", max_length=12)
nat_enabled: bool = True
ip_forwarding: bool = True
listen_address: str = Field(default="", max_length=15)
listen_interface: str = Field(default="", max_length=15)
snat_address: str = Field(default="", max_length=15)
forward_sources: str = Field(default="", max_length=4096)
class CreateInterfaceRequest(CreateServerRequest):
@@ -220,6 +224,10 @@ class ServerSettingsRequest(BaseModel):
ip_forwarding: bool = True
forward_from_vpn: bool = True
forward_to_vpn: bool = True
listen_address: str | None = Field(default=None, max_length=15)
listen_interface: str | None = Field(default=None, max_length=15)
snat_address: str | None = Field(default=None, max_length=15)
forward_sources: str | None = Field(default=None, max_length=4096)
class HttpsRequest(BaseModel):
@@ -517,6 +525,8 @@ def request_interface(request: Request) -> str:
access = get_user_access(int(current["id"])) if current else {"role": "admin", "interfaces": []}
default_iface = (access["interfaces"][0] if access["role"] == "user" and access["interfaces"] else WG_INTERFACE)
value = (request.cookies.get("wgtools_interface") or default_iface).strip()
if access["role"] == "user" and access["interfaces"] and value not in access["interfaces"]:
value = default_iface
if not IFACE_RE.fullmatch(value) or is_internal_interface(value):
fallback = str(WG_INTERFACE or "wg0").strip()
return fallback if IFACE_RE.fullmatch(fallback) and not is_internal_interface(fallback) else "wg0"
@@ -675,15 +685,13 @@ async def require_authentication(request: Request, call_next):
access = get_user_access(int(current["id"]))
request.state.access = access
if access["role"] != "admin":
allowed = {"/clients", "/api/interfaces", "/api/snapshot", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/delete"}
if path == "/":
return RedirectResponse(url=app_url(request, "/clients"), status_code=303)
allowed = {"/", "/clients", "/api/interfaces", "/api/snapshot", "/api/metrics/history", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/delete"}
if path not in allowed or (path == "/api/app-settings" and request.method != "GET"):
return JSONResponse(status_code=403, content={"ok": False, "error": "Brak uprawnień"})
if path.startswith("/api/clients/") or path.startswith("/api/extended/forwardings") or path == "/api/snapshot":
iface = request_interface(request)
if iface not in access["interfaces"]:
return JSONResponse(status_code=403, content={"ok": False, "error": "Brak dostępu do tej sieci"})
return JSONResponse(status_code=403, content={"ok": False, "error": "Administrator nie przydzielił Ci jeszcze żadnej sieci."})
required = None
if path == '/api/clients/create':
required = 'add'
@@ -1593,7 +1601,7 @@ def api_snapshot(request: Request, view: str = "full"):
iface = request_interface(request)
selected_view = str(view or "full").strip().lower()
if request.state.access["role"] != "admin":
selected_view = "clients"
selected_view = "dashboard" if selected_view == "dashboard" else "clients"
if selected_view not in {"full", "clients", "dashboard", "server"}:
selected_view = "full"
data = run_helper("snapshot", {"view": selected_view}, interface=iface)
@@ -1771,6 +1779,14 @@ def api_extended_forward_delete(payload: ExtendedForwardDeleteRequest, request:
return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
@app.get("/api/server/host-ips")
def api_host_ips(request: Request):
try:
return run_helper("extended_host_ips", interface=request_interface(request))
except HelperError as exc:
return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
@app.get("/api/server/extended-listen")
def api_extended_listen_get(request: Request):
try:
@@ -1811,7 +1827,7 @@ def api_extended_snat_apply(payload: ExtendedSnatRequest, request: Request):
def api_server_settings_apply(payload: ServerSettingsRequest, request: Request):
try:
iface = request_interface(request)
result = run_helper("server_settings_apply", payload.model_dump(), interface=iface)
result = run_helper("server_settings_apply", payload.model_dump(exclude_none=True), interface=iface)
reconcile_node()
audit_action(request, "server.settings_applied", object=iface, result="applied", details=payload.model_dump())
return result