mirror of
https://github.com/donaldzou/WGDashboard
synced 2025-02-26 05:58:47 +00:00
Update code for #446
This commit is contained in:
parent
ba6d6b8851
commit
a7317af413
@ -1660,12 +1660,17 @@ class Peer:
|
||||
if len(filename) == 0:
|
||||
filename = "UntitledPeer"
|
||||
filename = "".join(filename.split(' '))
|
||||
filename = f"{filename}_{self.configuration.Name}"
|
||||
filename = f"{filename}"
|
||||
illegal_filename = [".", ",", "/", "?", "<", ">", "\\", ":", "*", '|' '\"', "com1", "com2", "com3",
|
||||
"com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4",
|
||||
"lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "con", "nul", "prn"]
|
||||
for i in illegal_filename:
|
||||
filename = filename.replace(i, "")
|
||||
|
||||
finalFilename = ""
|
||||
for i in filename:
|
||||
if re.match("^[a-zA-Z0-9_=+.-]{1,15}$", i):
|
||||
finalFilename += i
|
||||
|
||||
peerConfiguration = f'''[Interface]
|
||||
PrivateKey = {self.private_key}
|
||||
@ -1685,7 +1690,7 @@ PersistentKeepalive = {str(self.keepalive)}
|
||||
if len(self.preshared_key) > 0:
|
||||
peerConfiguration += f"PresharedKey = {self.preshared_key}\n"
|
||||
return {
|
||||
"fileName": filename,
|
||||
"fileName": finalFilename,
|
||||
"file": peerConfiguration
|
||||
}
|
||||
|
||||
@ -2724,7 +2729,7 @@ def API_downloadAllPeers(configName):
|
||||
untitledPeer = 0
|
||||
for i in configuration.Peers:
|
||||
file = i.downloadPeer()
|
||||
if file["fileName"] == "UntitledPeer_" + configName:
|
||||
if file["fileName"] == "UntitledPeer":
|
||||
file["fileName"] = str(untitledPeer) + "_" + file["fileName"]
|
||||
untitledPeer += 1
|
||||
peerData.append(file)
|
||||
|
@ -75,7 +75,9 @@ export default {
|
||||
},
|
||||
downloadAllPeer(){
|
||||
fetchGet(`/api/downloadAllPeers/${this.configuration.Name}`, {}, (res) => {
|
||||
console.log(res);
|
||||
res.data.forEach(x => {
|
||||
x.fileName = x.fileName + '.conf'
|
||||
})
|
||||
window.wireguard.generateZipFiles(res, this.configuration.Name)
|
||||
})
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ export default {
|
||||
<div class="mt-md-5 mt-3">
|
||||
<div class="container-fluid">
|
||||
<SystemStatus></SystemStatus>
|
||||
<div class="d-flex mb-4 configurationListTitle align-items-md-center gap-3 flex-column flex-md-row">
|
||||
<div class="d-flex mb-4 configurationListTitle align-items-md-center gap-2 flex-column flex-md-row">
|
||||
<h2 class="text-body d-flex mb-0">
|
||||
<LocaleText t="WireGuard Configurations"></LocaleText>
|
||||
</h2>
|
||||
|
Loading…
Reference in New Issue
Block a user