mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-04-19 08:55:12 +00:00
Finished create configuration from backup
This commit is contained in:
parent
78b65a799e
commit
c3a55f8b69
@ -440,7 +440,7 @@ class WireguardConfiguration:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
def __init__(self, name: str = None, data: dict = None):
|
def __init__(self, name: str = None, data: dict = None, backup: dict = None):
|
||||||
print(f"[WGDashboard] Initialized Configuration: {name}")
|
print(f"[WGDashboard] Initialized Configuration: {name}")
|
||||||
|
|
||||||
self.__parser: configparser.ConfigParser = configparser.ConfigParser(strict=False)
|
self.__parser: configparser.ConfigParser = configparser.ConfigParser(strict=False)
|
||||||
@ -463,18 +463,31 @@ class WireguardConfiguration:
|
|||||||
self.SaveConfig: bool = True
|
self.SaveConfig: bool = True
|
||||||
self.Name = name
|
self.Name = name
|
||||||
self.__configPath = os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], f'{self.Name}.conf')
|
self.__configPath = os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], f'{self.Name}.conf')
|
||||||
|
|
||||||
if name is not None:
|
if name is not None:
|
||||||
|
if data is not None and "Backup" in data.keys():
|
||||||
|
db = self.__importDatabase(
|
||||||
|
os.path.join(
|
||||||
|
DashboardConfig.GetConfig("Server", "wg_conf_path")[1],
|
||||||
|
'WGDashboard_Backup',
|
||||||
|
data["Backup"].replace(".conf", ".sql")))
|
||||||
|
else:
|
||||||
|
self.__createDatabase()
|
||||||
|
|
||||||
self.__parseConfigurationFile()
|
self.__parseConfigurationFile()
|
||||||
|
self.__initPeersList()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.Name = data["ConfigurationName"]
|
self.Name = data["ConfigurationName"]
|
||||||
self.__configPath = os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], f'{self.Name}.conf')
|
self.__configPath = os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], f'{self.Name}.conf')
|
||||||
|
|
||||||
for i in dir(self):
|
for i in dir(self):
|
||||||
if str(i) in data.keys():
|
if str(i) in data.keys():
|
||||||
if isinstance(getattr(self, i), bool):
|
if isinstance(getattr(self, i), bool):
|
||||||
setattr(self, i, _strToBool(data[i]))
|
setattr(self, i, _strToBool(data[i]))
|
||||||
else:
|
else:
|
||||||
setattr(self, i, str(data[i]))
|
setattr(self, i, str(data[i]))
|
||||||
|
|
||||||
self.__parser["Interface"] = {
|
self.__parser["Interface"] = {
|
||||||
"PrivateKey": self.PrivateKey,
|
"PrivateKey": self.PrivateKey,
|
||||||
"Address": self.Address,
|
"Address": self.Address,
|
||||||
@ -485,13 +498,15 @@ class WireguardConfiguration:
|
|||||||
"PostDown": self.PostDown,
|
"PostDown": self.PostDown,
|
||||||
"SaveConfig": "true"
|
"SaveConfig": "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(self.__configPath, "w+") as configFile:
|
if "Backup" not in data.keys():
|
||||||
self.__parser.write(configFile)
|
self.__createDatabase()
|
||||||
|
with open(self.__configPath, "w+") as configFile:
|
||||||
|
self.__parser.write(configFile)
|
||||||
self.__createDatabase()
|
self.__initPeersList()
|
||||||
self.__initPeersList()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __initPeersList(self):
|
def __initPeersList(self):
|
||||||
self.Peers: list[Peer] = []
|
self.Peers: list[Peer] = []
|
||||||
@ -588,6 +603,18 @@ class WireguardConfiguration:
|
|||||||
):
|
):
|
||||||
yield line
|
yield line
|
||||||
|
|
||||||
|
def __importDatabase(self, sqlFilePath) -> bool:
|
||||||
|
self.__dropDatabase()
|
||||||
|
self.__createDatabase()
|
||||||
|
if not os.path.exists(sqlFilePath):
|
||||||
|
return False
|
||||||
|
with open(sqlFilePath, 'r') as f:
|
||||||
|
for l in f.readlines():
|
||||||
|
l = l.rstrip("\n")
|
||||||
|
if len(l) > 0:
|
||||||
|
sqlUpdate(l)
|
||||||
|
return True
|
||||||
|
|
||||||
def __getPublicKey(self) -> str:
|
def __getPublicKey(self) -> str:
|
||||||
return _generatePublicKey(self.PrivateKey)[1]
|
return _generatePublicKey(self.PrivateKey)[1]
|
||||||
|
|
||||||
@ -993,14 +1020,7 @@ class WireguardConfiguration:
|
|||||||
return False
|
return False
|
||||||
self.__parseConfigurationFile()
|
self.__parseConfigurationFile()
|
||||||
self.__dropDatabase()
|
self.__dropDatabase()
|
||||||
self.__createDatabase()
|
self.__importDatabase(targetSQL)
|
||||||
if (os.path.exists(targetSQL)):
|
|
||||||
with open(targetSQL, 'r') as sqlFile:
|
|
||||||
for l in sqlFile.readlines():
|
|
||||||
l = l.rstrip('\n')
|
|
||||||
if len(l) > 0:
|
|
||||||
sqlUpdate(l)
|
|
||||||
|
|
||||||
self.__initPeersList()
|
self.__initPeersList()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -1414,16 +1434,13 @@ class DashboardConfig:
|
|||||||
Private Functions
|
Private Functions
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def _strToBool(value: str) -> bool:
|
def _strToBool(value: str) -> bool:
|
||||||
return value.lower() in ("yes", "true", "t", "1", 1)
|
return value.lower() in ("yes", "true", "t", "1", 1)
|
||||||
|
|
||||||
|
|
||||||
def _regexMatch(regex, text):
|
def _regexMatch(regex, text):
|
||||||
pattern = re.compile(regex)
|
pattern = re.compile(regex)
|
||||||
return pattern.search(text) is not None
|
return pattern.search(text) is not None
|
||||||
|
|
||||||
|
|
||||||
def _getConfigurationList():
|
def _getConfigurationList():
|
||||||
for i in os.listdir(DashboardConfig.GetConfig("Server", "wg_conf_path")[1]):
|
for i in os.listdir(DashboardConfig.GetConfig("Server", "wg_conf_path")[1]):
|
||||||
if _regexMatch("^(.{1,}).(conf)$", i):
|
if _regexMatch("^(.{1,}).(conf)$", i):
|
||||||
@ -1437,8 +1454,6 @@ def _getConfigurationList():
|
|||||||
except WireguardConfiguration.InvalidConfigurationFileException as e:
|
except WireguardConfiguration.InvalidConfigurationFileException as e:
|
||||||
print(f"{i} have an invalid configuration file.")
|
print(f"{i} have an invalid configuration file.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _checkIPWithRange(ip):
|
def _checkIPWithRange(ip):
|
||||||
ip_patterns = (
|
ip_patterns = (
|
||||||
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)",
|
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|\/)){4}([0-9]{1,2})(,|$)",
|
||||||
@ -1455,7 +1470,6 @@ def _checkIPWithRange(ip):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _checkIP(ip):
|
def _checkIP(ip):
|
||||||
ip_patterns = (
|
ip_patterns = (
|
||||||
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}",
|
r"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}",
|
||||||
@ -1471,7 +1485,6 @@ def _checkIP(ip):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _checkDNS(dns):
|
def _checkDNS(dns):
|
||||||
dns = dns.replace(' ', '').split(',')
|
dns = dns.replace(' ', '').split(',')
|
||||||
for i in dns:
|
for i in dns:
|
||||||
@ -1479,7 +1492,6 @@ def _checkDNS(dns):
|
|||||||
return False, f"{i} does not appear to be an valid DNS address"
|
return False, f"{i} does not appear to be an valid DNS address"
|
||||||
return True, ""
|
return True, ""
|
||||||
|
|
||||||
|
|
||||||
def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]:
|
def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]:
|
||||||
try:
|
try:
|
||||||
publicKey = subprocess.check_output(f"wg pubkey", input=privateKey.encode(), shell=True,
|
publicKey = subprocess.check_output(f"wg pubkey", input=privateKey.encode(), shell=True,
|
||||||
@ -1488,7 +1500,6 @@ def _generatePublicKey(privateKey) -> tuple[bool, str] | tuple[bool, None]:
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
def _generatePrivateKey() -> [bool, str]:
|
def _generatePrivateKey() -> [bool, str]:
|
||||||
try:
|
try:
|
||||||
publicKey = subprocess.check_output(f"wg genkey", shell=True,
|
publicKey = subprocess.check_output(f"wg genkey", shell=True,
|
||||||
@ -1696,23 +1707,11 @@ def API_getWireguardConfigurations():
|
|||||||
@app.route(f'{APP_PREFIX}/api/addWireguardConfiguration', methods=["POST"])
|
@app.route(f'{APP_PREFIX}/api/addWireguardConfiguration', methods=["POST"])
|
||||||
def API_addWireguardConfiguration():
|
def API_addWireguardConfiguration():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
keys = [
|
|
||||||
"ConfigurationName",
|
|
||||||
"Address",
|
|
||||||
"ListenPort",
|
|
||||||
"PrivateKey",
|
|
||||||
"PublicKey",
|
|
||||||
"PresharedKey",
|
|
||||||
"PreUp",
|
|
||||||
"PreDown",
|
|
||||||
"PostUp",
|
|
||||||
"PostDown",
|
|
||||||
]
|
|
||||||
requiredKeys = [
|
requiredKeys = [
|
||||||
"ConfigurationName", "Address", "ListenPort", "PrivateKey"
|
"ConfigurationName", "Address", "ListenPort", "PrivateKey"
|
||||||
]
|
]
|
||||||
for i in keys:
|
for i in requiredKeys:
|
||||||
if i not in data.keys() or (i in requiredKeys and len(str(data[i])) == 0):
|
if i not in data.keys():
|
||||||
return ResponseObject(False, "Please provide all required parameters.")
|
return ResponseObject(False, "Please provide all required parameters.")
|
||||||
|
|
||||||
# Check duplicate names, ports, address
|
# Check duplicate names, ports, address
|
||||||
@ -1732,7 +1731,24 @@ def API_addWireguardConfiguration():
|
|||||||
f"Already have a configuration with the address \"{data['Address']}\"",
|
f"Already have a configuration with the address \"{data['Address']}\"",
|
||||||
"Address")
|
"Address")
|
||||||
|
|
||||||
WireguardConfigurations[data['ConfigurationName']] = WireguardConfiguration(data=data)
|
if "Backup" in data.keys():
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(
|
||||||
|
DashboardConfig.GetConfig("Server", "wg_conf_path")[1],
|
||||||
|
'WGDashboard_Backup',
|
||||||
|
data["Backup"])) or not os.path.exists(os.path.join(
|
||||||
|
DashboardConfig.GetConfig("Server", "wg_conf_path")[1],
|
||||||
|
'WGDashboard_Backup',
|
||||||
|
data["Backup"].replace('.conf', '.sql'))):
|
||||||
|
return ResponseObject(False, "Backup file does not exist")
|
||||||
|
|
||||||
|
shutil.copy(
|
||||||
|
os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], 'WGDashboard_Backup', data["Backup"]),
|
||||||
|
os.path.join(DashboardConfig.GetConfig("Server", "wg_conf_path")[1], f'{data["ConfigurationName"]}.conf')
|
||||||
|
)
|
||||||
|
WireguardConfigurations[data['ConfigurationName']] = WireguardConfiguration(data=data, name=data['ConfigurationName'])
|
||||||
|
else:
|
||||||
|
WireguardConfigurations[data['ConfigurationName']] = WireguardConfiguration(data=data)
|
||||||
return ResponseObject()
|
return ResponseObject()
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,10 +156,10 @@ export default {
|
|||||||
modalOpen: false
|
modalOpen: false
|
||||||
},
|
},
|
||||||
backupRestore: {
|
backupRestore: {
|
||||||
modalOpen: true
|
modalOpen: false
|
||||||
},
|
},
|
||||||
deleteConfiguration: {
|
deleteConfiguration: {
|
||||||
modalOpen: false
|
modalOpen: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -685,17 +685,19 @@ export default {
|
|||||||
@close="this.selectPeers.modalOpen = false"
|
@close="this.selectPeers.modalOpen = false"
|
||||||
></SelectPeers>
|
></SelectPeers>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|
||||||
|
<Transition name="zoom">
|
||||||
|
<DeleteConfiguration
|
||||||
|
@backup="backupRestore.modalOpen = true"
|
||||||
|
@close="deleteConfiguration.modalOpen = false"
|
||||||
|
v-if="deleteConfiguration.modalOpen"></DeleteConfiguration>
|
||||||
|
</Transition>
|
||||||
<Transition name="zoom">
|
<Transition name="zoom">
|
||||||
<ConfigurationBackupRestore
|
<ConfigurationBackupRestore
|
||||||
@close="backupRestore.modalOpen = false"
|
@close="backupRestore.modalOpen = false"
|
||||||
@refreshPeersList="this.getPeers()"
|
@refreshPeersList="this.getPeers()"
|
||||||
v-if="backupRestore.modalOpen"></ConfigurationBackupRestore>
|
v-if="backupRestore.modalOpen"></ConfigurationBackupRestore>
|
||||||
</Transition>
|
</Transition>
|
||||||
<Transition name="zoom">
|
|
||||||
<DeleteConfiguration
|
|
||||||
@close="deleteConfiguration.modalOpen = false"
|
|
||||||
v-if="deleteConfiguration.modalOpen"></DeleteConfiguration>
|
|
||||||
</Transition>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
<script>
|
<script>
|
||||||
import LocaleText from "@/components/text/localeText.vue";
|
import LocaleText from "@/components/text/localeText.vue";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "message",
|
name: "message",
|
||||||
|
methods: {dayjs},
|
||||||
components: {LocaleText},
|
components: {LocaleText},
|
||||||
props: {
|
props: {
|
||||||
message: Object
|
message: Object
|
||||||
@ -16,16 +18,22 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="card shadow rounded-3 position-relative mb-2 message ms-auto"
|
<div class="card shadow rounded-3 position-relative message ms-auto"
|
||||||
:class="{
|
:class="{
|
||||||
'text-bg-danger': this.message.type === 'danger',
|
'text-bg-danger': this.message.type === 'danger',
|
||||||
'text-bg-success': this.message.type === 'success',
|
'text-bg-success': this.message.type === 'success',
|
||||||
'text-bg-warning': this.message.type === 'warning'}"
|
'text-bg-warning': this.message.type === 'warning'}"
|
||||||
:id="this.message.id">
|
:id="this.message.id">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<small class="fw-bold d-block" style="text-transform: uppercase">
|
<div class="d-flex">
|
||||||
<LocaleText t="FROM "></LocaleText>
|
<small class="fw-bold d-block" style="text-transform: uppercase">
|
||||||
{{this.message.from}}</small>
|
<LocaleText t="FROM "></LocaleText>
|
||||||
|
{{this.message.from}}
|
||||||
|
</small>
|
||||||
|
<small class="ms-auto">
|
||||||
|
{{dayjs().format("hh:mm A")}}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
{{this.message.content}}
|
{{this.message.content}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,13 +3,17 @@ import {computed, onMounted, reactive, ref, watch} from "vue";
|
|||||||
import LocaleText from "@/components/text/localeText.vue";
|
import LocaleText from "@/components/text/localeText.vue";
|
||||||
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
|
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
|
||||||
import {parse} from "cidr-tools";
|
import {parse} from "cidr-tools";
|
||||||
|
import {fetchPost} from "@/utilities/fetch.js";
|
||||||
|
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||||
|
import {useRouter} from "vue-router";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
selectedConfigurationBackup: Object
|
selectedConfigurationBackup: Object
|
||||||
})
|
})
|
||||||
|
|
||||||
const newConfiguration = reactive({
|
const newConfiguration = reactive({
|
||||||
ConfigurationName: props.selectedConfigurationBackup.filename.split("_")[0]
|
ConfigurationName: props.selectedConfigurationBackup.filename.split("_")[0],
|
||||||
|
Backup: props.selectedConfigurationBackup.filename
|
||||||
})
|
})
|
||||||
|
|
||||||
const lineSplit = props.selectedConfigurationBackup.content.split("\n");
|
const lineSplit = props.selectedConfigurationBackup.content.split("\n");
|
||||||
@ -76,7 +80,6 @@ const validateForm = computed(() => {
|
|||||||
&& validatePrivateKey.value
|
&& validatePrivateKey.value
|
||||||
&& validateConfigurationName.value
|
&& validateConfigurationName.value
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.querySelector("main").scrollTo({
|
document.querySelector("main").scrollTo({
|
||||||
top: 0,
|
top: 0,
|
||||||
@ -90,7 +93,6 @@ onMounted(() => {
|
|||||||
immediate: true
|
immediate: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const availableIPAddress = computed(() => {
|
const availableIPAddress = computed(() => {
|
||||||
let p;
|
let p;
|
||||||
try{
|
try{
|
||||||
@ -100,7 +102,6 @@ const availableIPAddress = computed(() => {
|
|||||||
}
|
}
|
||||||
return p.end - p.start
|
return p.end - p.start
|
||||||
})
|
})
|
||||||
|
|
||||||
const peersCount = computed(() => {
|
const peersCount = computed(() => {
|
||||||
if (props.selectedConfigurationBackup.database){
|
if (props.selectedConfigurationBackup.database){
|
||||||
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
||||||
@ -108,7 +109,6 @@ const peersCount = computed(() => {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const restrictedPeersCount = computed(() => {
|
const restrictedPeersCount = computed(() => {
|
||||||
if (props.selectedConfigurationBackup.database){
|
if (props.selectedConfigurationBackup.database){
|
||||||
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
||||||
@ -116,10 +116,19 @@ const restrictedPeersCount = computed(() => {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
const dashboardStore = DashboardConfigurationStore()
|
||||||
|
const router = useRouter();
|
||||||
|
const submitRestore = async () => {
|
||||||
|
if (validateForm.value){
|
||||||
|
await fetchPost("/api/addWireguardConfiguration", newConfiguration, async (res) => {
|
||||||
|
if (res.status){
|
||||||
|
dashboardStore.newMessage("Server", "Configuration restored", "success")
|
||||||
|
await store.getConfigurations()
|
||||||
|
await router.push(`/configuration/${newConfiguration.ConfigurationName}/peers`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -137,7 +146,7 @@ const restrictedPeersCount = computed(() => {
|
|||||||
<input type="text" class="form-control rounded-3" placeholder="ex. wg1" id="ConfigurationName"
|
<input type="text" class="form-control rounded-3" placeholder="ex. wg1" id="ConfigurationName"
|
||||||
v-model="newConfiguration.ConfigurationName"
|
v-model="newConfiguration.ConfigurationName"
|
||||||
:class="[validateConfigurationName ? 'is-valid':'is-invalid']"
|
:class="[validateConfigurationName ? 'is-valid':'is-invalid']"
|
||||||
:disabled="loading"
|
disabled
|
||||||
required>
|
required>
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
<div v-if="error">{{errorMessage}}</div>
|
<div v-if="error">{{errorMessage}}</div>
|
||||||
@ -162,16 +171,9 @@ const restrictedPeersCount = computed(() => {
|
|||||||
</small></label>
|
</small></label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control rounded-start-3" id="PrivateKey" required
|
<input type="text" class="form-control rounded-start-3" id="PrivateKey" required
|
||||||
:disabled="loading"
|
|
||||||
:class="[validatePrivateKey ? 'is-valid':'is-invalid']"
|
:class="[validatePrivateKey ? 'is-valid':'is-invalid']"
|
||||||
v-model="newConfiguration.PrivateKey" disabled
|
v-model="newConfiguration.PrivateKey" disabled
|
||||||
>
|
>
|
||||||
<button class="btn btn-outline-primary rounded-end-3" type="button"
|
|
||||||
title="Regenerate Private Key"
|
|
||||||
@click="wireguardGenerateKeypair()"
|
|
||||||
>
|
|
||||||
<i class="bi bi-arrow-repeat"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -195,7 +197,7 @@ const restrictedPeersCount = computed(() => {
|
|||||||
max="65353"
|
max="65353"
|
||||||
v-model="newConfiguration.ListenPort"
|
v-model="newConfiguration.ListenPort"
|
||||||
:class="[validateListenPort ? 'is-valid':'is-invalid']"
|
:class="[validateListenPort ? 'is-valid':'is-invalid']"
|
||||||
:disabled="loading"
|
disabled
|
||||||
required>
|
required>
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
<div v-if="error">{{errorMessage}}</div>
|
<div v-if="error">{{errorMessage}}</div>
|
||||||
@ -225,7 +227,7 @@ const restrictedPeersCount = computed(() => {
|
|||||||
placeholder="Ex: 10.0.0.1/24" id="Address"
|
placeholder="Ex: 10.0.0.1/24" id="Address"
|
||||||
v-model="newConfiguration.Address"
|
v-model="newConfiguration.Address"
|
||||||
:class="[validateAddress ? 'is-valid':'is-invalid']"
|
:class="[validateAddress ? 'is-valid':'is-invalid']"
|
||||||
:disabled="loading"
|
disabled
|
||||||
required>
|
required>
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
<div v-if="error">{{errorMessage}}</div>
|
<div v-if="error">{{errorMessage}}</div>
|
||||||
@ -250,25 +252,33 @@ const restrictedPeersCount = computed(() => {
|
|||||||
<label class="text-muted mb-1" for="PreUp"><small>
|
<label class="text-muted mb-1" for="PreUp"><small>
|
||||||
<LocaleText t="PreUp"></LocaleText>
|
<LocaleText t="PreUp"></LocaleText>
|
||||||
</small></label>
|
</small></label>
|
||||||
<input type="text" class="form-control rounded-3" id="PreUp" v-model="newConfiguration.PreUp">
|
<input type="text" class="form-control rounded-3" id="PreUp"
|
||||||
|
disabled
|
||||||
|
v-model="newConfiguration.PreUp">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted mb-1" for="PreDown"><small>
|
<label class="text-muted mb-1" for="PreDown"><small>
|
||||||
<LocaleText t="PreDown"></LocaleText>
|
<LocaleText t="PreDown"></LocaleText>
|
||||||
</small></label>
|
</small></label>
|
||||||
<input type="text" class="form-control rounded-3" id="PreDown" v-model="newConfiguration.PreDown">
|
<input type="text" class="form-control rounded-3" id="PreDown"
|
||||||
|
disabled
|
||||||
|
v-model="newConfiguration.PreDown">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted mb-1" for="PostUp"><small>
|
<label class="text-muted mb-1" for="PostUp"><small>
|
||||||
<LocaleText t="PostUp"></LocaleText>
|
<LocaleText t="PostUp"></LocaleText>
|
||||||
</small></label>
|
</small></label>
|
||||||
<input type="text" class="form-control rounded-3" id="PostUp" v-model="newConfiguration.PostUp">
|
<input type="text" class="form-control rounded-3" id="PostUp"
|
||||||
|
disabled
|
||||||
|
v-model="newConfiguration.PostUp">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted mb-1" for="PostDown"><small>
|
<label class="text-muted mb-1" for="PostDown"><small>
|
||||||
<LocaleText t="PostDown"></LocaleText>
|
<LocaleText t="PostDown"></LocaleText>
|
||||||
</small></label>
|
</small></label>
|
||||||
<input type="text" class="form-control rounded-3" id="PostDown" v-model="newConfiguration.PostDown">
|
<input type="text" class="form-control rounded-3" id="PostDown"
|
||||||
|
disabled
|
||||||
|
v-model="newConfiguration.PostDown">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -305,9 +315,10 @@ const restrictedPeersCount = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<button class="btn btn-dark btn-brand rounded-3 px-3 py-2 shadow ms-auto"
|
<button class="btn btn-dark btn-brand rounded-3 px-3 py-2 shadow ms-auto"
|
||||||
:disabled="!validateForm"
|
:disabled="!validateForm || loading"
|
||||||
|
@click="submitRestore()"
|
||||||
>
|
>
|
||||||
<i class="bi bi-clock-history me-2"></i> Restore
|
<i class="bi bi-clock-history me-2"></i> {{ !loading ? 'Restore':'Restoring...'}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,8 +32,6 @@ export const DashboardConfigurationStore = defineStore('DashboardConfigurationSt
|
|||||||
}else{
|
}else{
|
||||||
this.CrossServerConfiguration = JSON.parse(currentConfiguration)
|
this.CrossServerConfiguration = JSON.parse(currentConfiguration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
syncCrossServerConfiguration(){
|
syncCrossServerConfiguration(){
|
||||||
window.localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
window.localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
||||||
@ -82,7 +80,6 @@ export const DashboardConfigurationStore = defineStore('DashboardConfigurationSt
|
|||||||
applyLocale(key){
|
applyLocale(key){
|
||||||
if (this.Locale === null)
|
if (this.Locale === null)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
const reg = Object.keys(this.Locale)
|
const reg = Object.keys(this.Locale)
|
||||||
const match = reg.filter(x => {
|
const match = reg.filter(x => {
|
||||||
return key.match(new RegExp('^' + x + '$', 'g')) !== null
|
return key.match(new RegExp('^' + x + '$', 'g')) !== null
|
||||||
|
@ -29,7 +29,7 @@ const selectedConfiguration = ref("")
|
|||||||
<LocaleText t="Restore Configuration"></LocaleText>
|
<LocaleText t="Restore Configuration"></LocaleText>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div name="restore" v-if="backups" >
|
<div v-if="backups" >
|
||||||
<div class="d-flex mb-5 align-items-center steps" role="button"
|
<div class="d-flex mb-5 align-items-center steps" role="button"
|
||||||
:class="{active: !confirm}"
|
:class="{active: !confirm}"
|
||||||
@click="confirm = false" key="step1">
|
@click="confirm = false" key="step1">
|
||||||
@ -58,21 +58,21 @@ const selectedConfiguration = ref("")
|
|||||||
</Transition>
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
<div id="step1Detail" v-if="!confirm">
|
<div id="step1Detail" v-if="!confirm">
|
||||||
|
<!-- <div class="mb-4">-->
|
||||||
|
<!-- <h5>Backup of existing WireGuard Configurations</h5>-->
|
||||||
|
<!-- <hr>-->
|
||||||
|
<!-- <div class="d-flex gap-3 flex-column">-->
|
||||||
|
<!-- <BackupGroup-->
|
||||||
|
<!-- @select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"-->
|
||||||
|
<!-- :open="selectedConfiguration === c"-->
|
||||||
|
<!-- :selectedConfigurationBackup="selectedConfigurationBackup"-->
|
||||||
|
<!-- v-for="c in Object.keys(backups.ExistingConfigurations)"-->
|
||||||
|
<!-- :configuration-name="c" :backups="backups.ExistingConfigurations[c]"></BackupGroup>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!-- </div>-->
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<h5>Backup of existing WireGuard Configurations</h5>
|
<!-- <h5>Backup of non-existing WireGuard Configurations</h5>-->
|
||||||
<hr>
|
<!-- <hr>-->
|
||||||
<div class="d-flex gap-3 flex-column">
|
|
||||||
<BackupGroup
|
|
||||||
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
|
|
||||||
:open="selectedConfiguration === c"
|
|
||||||
:selectedConfigurationBackup="selectedConfigurationBackup"
|
|
||||||
v-for="c in Object.keys(backups.ExistingConfigurations)"
|
|
||||||
:configuration-name="c" :backups="backups.ExistingConfigurations[c]"></BackupGroup>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="mb-4">
|
|
||||||
<h5>Backup of non-existing WireGuard Configurations</h5>
|
|
||||||
<hr>
|
|
||||||
<div class="d-flex gap-3 flex-column">
|
<div class="d-flex gap-3 flex-column">
|
||||||
<BackupGroup
|
<BackupGroup
|
||||||
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
|
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
|
||||||
@ -80,6 +80,13 @@ const selectedConfiguration = ref("")
|
|||||||
:open="selectedConfiguration === c"
|
:open="selectedConfiguration === c"
|
||||||
v-for="c in Object.keys(backups.NonExistingConfigurations)"
|
v-for="c in Object.keys(backups.NonExistingConfigurations)"
|
||||||
:configuration-name="c" :backups="backups.NonExistingConfigurations[c]"></BackupGroup>
|
:configuration-name="c" :backups="backups.NonExistingConfigurations[c]"></BackupGroup>
|
||||||
|
<div v-if="Object.keys(backups.NonExistingConfigurations).length === 0">
|
||||||
|
<div class="card rounded-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="mb-0">You don't have any configuration to restore</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user