Remove /wireguard/{config} endpoint

This commit is contained in:
billz 2024-03-08 20:17:22 +01:00
parent f61e1b5c1a
commit 9c5c0cfb88
2 changed files with 0 additions and 18 deletions

View file

@ -154,8 +154,3 @@ async def get_wireguard(api_key: APIKey = Depends(auth.get_api_key)):
'client_config_active': wireguard.client_config_active() 'client_config_active': wireguard.client_config_active()
} }
@app.get("/wireguard/{config}", tags=["WireGuard"])
async def client_config_list(config, api_key: APIKey = Depends(auth.get_api_key)):
return{
'client_config': wireguard.client_config_list(config)
}

View file

@ -19,18 +19,5 @@ def client_config_active():
active_config = output.split("/etc/wireguard/") active_config = output.split("/etc/wireguard/")
return(active_config[1]) return(active_config[1])
def client_config_list(client_config):
pattern = r'^[a-zA-Z0-9_-]+$'
if not re.match(pattern, client_config):
raise ValueError("Invalid client_config")
config_path = f"/etc/wireguard/{client_config}"
try:
with open(config_path, 'r') as f:
output = f.read().strip()
return output.split('\n')
except FileNotFoundError:
raise FileNotFoundError("Client configuration file not found")
#TODO: where is the logfile?? #TODO: where is the logfile??
#TODO: is service connected? #TODO: is service connected?