mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 15:56:17 +00:00
Completed feature for #843
This commit is contained in:
@@ -490,12 +490,12 @@ def API_updateDashboardConfigurationItem():
|
|||||||
valid, msg = DashboardConfig.SetConfig(
|
valid, msg = DashboardConfig.SetConfig(
|
||||||
data["section"], data["key"], data['value'])
|
data["section"], data["key"], data['value'])
|
||||||
if not valid:
|
if not valid:
|
||||||
return ResponseObject(False, msg, status_code=404)
|
return ResponseObject(False, msg)
|
||||||
if data['section'] == "Server":
|
if data['section'] == "Server":
|
||||||
if data['key'] == 'wg_conf_path':
|
if data['key'] == 'wg_conf_path':
|
||||||
WireguardConfigurations.clear()
|
WireguardConfigurations.clear()
|
||||||
WireguardConfigurations.clear()
|
WireguardConfigurations.clear()
|
||||||
InitWireguardConfigurationsList()
|
InitWireguardConfigurationsList()
|
||||||
return ResponseObject(True, data=DashboardConfig.GetConfig(data["section"], data["key"])[1])
|
return ResponseObject(True, data=DashboardConfig.GetConfig(data["section"], data["key"])[1])
|
||||||
|
|
||||||
@app.get(f'{APP_PREFIX}/api/getDashboardAPIKeys')
|
@app.get(f'{APP_PREFIX}/api/getDashboardAPIKeys')
|
||||||
|
@@ -251,7 +251,7 @@ class DashboardConfig:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def GetConfig(self, section, key) ->tuple[bool, bool] | tuple[bool, str] | tuple[bool, list[str]] | tuple[bool, None]:
|
def GetConfig(self, section, key) ->tuple[bool, bool] | tuple[bool, str] | tuple[bool, list[str]] | tuple[bool, None]:
|
||||||
if section not in self.__config:
|
if section not in self.__config:
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
@@ -2,6 +2,9 @@
|
|||||||
Peer
|
Peer
|
||||||
"""
|
"""
|
||||||
import os, subprocess, uuid, random, re
|
import os, subprocess, uuid, random, re
|
||||||
|
|
||||||
|
import jinja2
|
||||||
|
|
||||||
from .PeerJob import PeerJob
|
from .PeerJob import PeerJob
|
||||||
from .PeerShareLink import PeerShareLink
|
from .PeerShareLink import PeerShareLink
|
||||||
from .Utilities import GenerateWireguardPublicKey, ValidateIPAddressesWithRange, ValidateDNSAddress
|
from .Utilities import GenerateWireguardPublicKey, ValidateIPAddressesWithRange, ValidateDNSAddress
|
||||||
@@ -136,7 +139,10 @@ class Peer:
|
|||||||
interfaceSection = {
|
interfaceSection = {
|
||||||
"PrivateKey": self.private_key,
|
"PrivateKey": self.private_key,
|
||||||
"Address": self.allowed_ip,
|
"Address": self.allowed_ip,
|
||||||
"MTU": self.mtu,
|
"MTU": (
|
||||||
|
self.configuration.configurationInfo.OverridePeerSettings.MTU
|
||||||
|
if self.configuration.configurationInfo.OverridePeerSettings.MTU else self.mtu
|
||||||
|
),
|
||||||
"DNS": (
|
"DNS": (
|
||||||
self.configuration.configurationInfo.OverridePeerSettings.DNS
|
self.configuration.configurationInfo.OverridePeerSettings.DNS
|
||||||
if self.configuration.configurationInfo.OverridePeerSettings.DNS else self.DNS
|
if self.configuration.configurationInfo.OverridePeerSettings.DNS else self.DNS
|
||||||
@@ -144,9 +150,16 @@ class Peer:
|
|||||||
}
|
}
|
||||||
peerSection = {
|
peerSection = {
|
||||||
"PublicKey": self.configuration.PublicKey,
|
"PublicKey": self.configuration.PublicKey,
|
||||||
"AllowedIPs": self.endpoint_allowed_ip,
|
"AllowedIPs": (
|
||||||
"Endpoint": f'{self.configuration.DashboardConfig.GetConfig("Peers", "remote_endpoint")[1]}:{self.configuration.ListenPort}',
|
self.configuration.configurationInfo.OverridePeerSettings.EndpointAllowedIPs
|
||||||
"PersistentKeepalive": self.keepalive,
|
if self.configuration.configurationInfo.OverridePeerSettings.EndpointAllowedIPs else self.endpoint_allowed_ip
|
||||||
|
),
|
||||||
|
"Endpoint": f'{(self.configuration.configurationInfo.OverridePeerSettings.PeerRemoteEndpoint if self.configuration.configurationInfo.OverridePeerSettings.PeerRemoteEndpoint else self.configuration.DashboardConfig.GetConfig("Peers", "remote_endpoint")[1])}:{(self.configuration.configurationInfo.OverridePeerSettings.ListenPort if self.configuration.configurationInfo.OverridePeerSettings.ListenPort else self.configuration.ListenPort)}',
|
||||||
|
"PersistentKeepalive": (
|
||||||
|
self.configuration.configurationInfo.OverridePeerSettings.PersistentKeepalive
|
||||||
|
if self.configuration.configurationInfo.OverridePeerSettings.PersistentKeepalive
|
||||||
|
else self.keepalive
|
||||||
|
),
|
||||||
"PresharedKey": self.preshared_key
|
"PresharedKey": self.preshared_key
|
||||||
}
|
}
|
||||||
combine = [interfaceSection.items(), peerSection.items()]
|
combine = [interfaceSection.items(), peerSection.items()]
|
||||||
@@ -161,7 +174,7 @@ class Peer:
|
|||||||
peerConfiguration += f"{key} = {val}\n"
|
peerConfiguration += f"{key} = {val}\n"
|
||||||
return {
|
return {
|
||||||
"fileName": finalFilename,
|
"fileName": finalFilename,
|
||||||
"file": peerConfiguration
|
"file": jinja2.Template(peerConfiguration).render(configuration=self.configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
def getJobs(self):
|
def getJobs(self):
|
||||||
|
@@ -4,6 +4,7 @@ import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.
|
|||||||
import {computed, watch} from "vue";
|
import {computed, watch} from "vue";
|
||||||
const store = DashboardConfigurationStore();
|
const store = DashboardConfigurationStore();
|
||||||
import "@/utilities/wireguard.js"
|
import "@/utilities/wireguard.js"
|
||||||
|
import {fetchGet} from "@/utilities/fetch.js";
|
||||||
store.initCrossServerConfiguration();
|
store.initCrossServerConfiguration();
|
||||||
if (window.IS_WGDASHBOARD_DESKTOP){
|
if (window.IS_WGDASHBOARD_DESKTOP){
|
||||||
store.IsElectronApp = true;
|
store.IsElectronApp = true;
|
||||||
@@ -15,7 +16,9 @@ watch(store.CrossServerConfiguration, () => {
|
|||||||
deep: true
|
deep: true
|
||||||
});
|
});
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
fetchGet("/api/locale", {}, (res) => {
|
||||||
|
store.Locale = res.data
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@@ -11,13 +11,15 @@ import router from './router/router.js'
|
|||||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||||
let Locale;
|
let Locale;
|
||||||
await fetch("/api/locale")
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(res => Locale = res.data)
|
|
||||||
.catch(() => {
|
|
||||||
Locale = null
|
|
||||||
})
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
|
// await fetch("/api/locale")
|
||||||
|
// .then(res => res.json())
|
||||||
|
// .then(res => Locale = res.data)
|
||||||
|
// .catch(() => {
|
||||||
|
// Locale = null
|
||||||
|
// })
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
pinia.use(piniaPluginPersistedstate)
|
pinia.use(piniaPluginPersistedstate)
|
||||||
@@ -27,6 +29,4 @@ pinia.use(({ store }) => {
|
|||||||
|
|
||||||
|
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
const store = DashboardConfigurationStore()
|
|
||||||
store.Locale = Locale;
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
@@ -20,7 +20,7 @@ export const DashboardConfigurationStore = defineStore('DashboardConfigurationSt
|
|||||||
ActiveServerConfiguration: undefined,
|
ActiveServerConfiguration: undefined,
|
||||||
IsElectronApp: false,
|
IsElectronApp: false,
|
||||||
ShowNavBar: false,
|
ShowNavBar: false,
|
||||||
Locale: undefined,
|
Locale: null,
|
||||||
HelpAgent: {
|
HelpAgent: {
|
||||||
Enable: false
|
Enable: false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user