mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 15:21:14 +00:00
generate interface and peer configuration filenames in backend only (#395)
This commit is contained in:
@@ -89,19 +89,11 @@ watch(() => props.visible, async (newValue, oldValue) => {
|
||||
|
||||
function download() {
|
||||
// credit: https://www.bitdegree.org/learn/javascript-download
|
||||
let filename = 'WireGuard-Tunnel.conf'
|
||||
if (selectedPeer.value.DisplayName) {
|
||||
filename = selectedPeer.value.DisplayName
|
||||
.replace(/ /g, "_")
|
||||
.replace(/[^a-zA-Z0-9-_]/g, "")
|
||||
.substring(0, 16)
|
||||
+ ".conf"
|
||||
}
|
||||
let text = configString.value
|
||||
|
||||
let element = document.createElement('a')
|
||||
element.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(text))
|
||||
element.setAttribute('download', filename)
|
||||
element.setAttribute('download', selectedPeer.value.Filename)
|
||||
|
||||
element.style.display = 'none'
|
||||
document.body.appendChild(element)
|
||||
|
@@ -42,7 +42,8 @@ export function freshInterface() {
|
||||
PeerDefPostDown: "",
|
||||
|
||||
TotalPeers: 0,
|
||||
EnabledPeers: 0
|
||||
EnabledPeers: 0,
|
||||
Filename: ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +121,8 @@ export function freshPeer() {
|
||||
Overridable: true,
|
||||
},
|
||||
|
||||
Filename: "",
|
||||
|
||||
// Internal values
|
||||
IgnoreGlobalSettings: false,
|
||||
IsSelected: false
|
||||
|
@@ -49,12 +49,11 @@ async function download() {
|
||||
await interfaces.LoadInterfaceConfig(interfaces.GetSelected.Identifier)
|
||||
|
||||
// credit: https://www.bitdegree.org/learn/javascript-download
|
||||
let filename = interfaces.GetSelected.Identifier + ".conf"
|
||||
let text = interfaces.configuration
|
||||
|
||||
let element = document.createElement('a')
|
||||
element.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(text))
|
||||
element.setAttribute('download', filename)
|
||||
element.setAttribute('download', interfaces.GetSelected.Filename)
|
||||
|
||||
element.style.display = 'none'
|
||||
document.body.appendChild(element)
|
||||
|
Reference in New Issue
Block a user