-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
25 lines (22 loc) · 1.18 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function convertToURL() {
const name = document.getElementById('name').value;
const address = document.getElementById('address').value;
const port = document.getElementById('port').value;
const secretKey = document.getElementById('secretKey').value;
const publicKey = document.getElementById('publicKey').value;
const mtu = document.getElementById('mtu').value;
const peerSecretKey = document.getElementById('peerSecretKey').value;
const peerPublicKey = document.getElementById('peerPublicKey').value;
const allowedIPs = document.getElementById('allowedIPs').value;
const url = `wireguard://${encodeURIComponent(peerSecretKey)}@${address}:${port}/?publickey=${encodeURIComponent(peerPublicKey)}&address=${encodeURIComponent(allowedIPs)}&mtu=${encodeURIComponent(mtu)}#${encodeURIComponent(name)}`;
document.getElementById('wg-uri').innerText = url;
}
function copyToClipboard() {
const urlElement = document.getElementById('wg-uri');
const urlText = urlElement.innerText;
navigator.clipboard.writeText(urlText).then(() => {
alert("URL copied to clipboard!");
}).catch(err => {
console.error('Failed to copy: ', err);
});
}