Rename “comment”→“name” in wg key config

This commit is contained in:
Timotej Lazar 2023-04-24 09:48:04 +02:00
parent 2793385693
commit 9476a28674
3 changed files with 8 additions and 8 deletions

View file

@ -30,7 +30,7 @@ Nastavitve shranite (kot skrbnik) v <code>/etc/wireguard/wg-fri.conf</code>. VPN
Vnesite poljubno oznako in kliknite <em>Ustvari ključ</em>. Če vklopite prvo opcijo, bo vaš računalnik čez VPN usmeril ves mrežni promet, ne le tistega, ki je namenjen strežnikom na FRI. Če izklopite drugo opcijo, bodo nekatere storitve dostopne le prek naslova IP. Če ste v dvomih, pustite privzete nastavitve. Vnesite poljubno oznako in kliknite <em>Ustvari ključ</em>. Če vklopite prvo opcijo, bo vaš računalnik čez VPN usmeril ves mrežni promet, ne le tistega, ki je namenjen strežnikom na FRI. Če izklopite drugo opcijo, bodo nekatere storitve dostopne le prek naslova IP. Če ste v dvomih, pustite privzete nastavitve.
<p> <p>
<input id="comment" name="comment" pattern="[\w ]*" maxlength="16" placeholder="Oznaka ključa" /> <input id="name" name="name" pattern="[\w ]*" maxlength="16" placeholder="Ime naprave" />
<br> <br>
<input type="checkbox" id="add_default" name="add_default" /> <input type="checkbox" id="add_default" name="add_default" />
<label for="add_default">Uporabi VPN za ves promet</label> <label for="add_default">Uporabi VPN za ves promet</label>
@ -112,7 +112,7 @@ function fetch_keys() {
li.innerHTML = ' ' + (new Date(key.time*1000).toISOString().split('T')[0]) + li.innerHTML = ' ' + (new Date(key.time*1000).toISOString().split('T')[0]) +
' <code>' + key.key + '</code>' + ' <code>' + key.key + '</code>' +
(key.active ? '<font color="red"><sup></sup></font> ' : ' ') + (key.active ? '<font color="red"><sup></sup></font> ' : ' ') +
key.comment; key.name;
li.prepend(a); li.prepend(a);
keys.appendChild(li); keys.appendChild(li);
if (key.active) if (key.active)
@ -128,7 +128,7 @@ window.addEventListener('load', fetch_keys);
const request = document.getElementById('request'); const request = document.getElementById('request');
request.addEventListener('submit', event => { request.addEventListener('submit', event => {
event.preventDefault(); event.preventDefault();
const comment = document.getElementById('comment'); const name = document.getElementById('name');
const key = wireguard.generateKeypair(); const key = wireguard.generateKeypair();
const settings = document.getElementById('settings'); const settings = document.getElementById('settings');
const submit = document.getElementById('submit'); const submit = document.getElementById('submit');
@ -143,7 +143,7 @@ request.addEventListener('submit', event => {
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
pubkey: key.publicKey, pubkey: key.publicKey,
comment: comment.value, name: name.value,
use_dns: use_dns.checked, use_dns: use_dns.checked,
add_default: add_default.checked, add_default: add_default.checked,
}) })

View file

@ -1,5 +1,5 @@
[Interface] [Interface]
# {{ timestamp }} {{ current_user['username'] }} {{ comment }} # {{ timestamp }} {{ current_user['username'] }} {{ name }}
# PublicKey = {{ pubkey }} # PublicKey = {{ pubkey }}
PrivateKey = # paste private key here PrivateKey = # paste private key here
Address = {{ ip }} Address = {{ ip }}

View file

@ -49,13 +49,13 @@ def new():
else: else:
return flask.Response('no more available IP addresses', status=500, mimetype='text/plain') return flask.Response('no more available IP addresses', status=500, mimetype='text/plain')
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
comment = re.sub('[^\w ]', '', flask.request.json.get('comment', '')) name = re.sub('[^\w ]', '', flask.request.json.get('name', ''))
ips[str(ip)] = { ips[str(ip)] = {
'key': pubkey, 'key': pubkey,
'time': now.timestamp(), 'time': now.timestamp(),
'user': flask_login.current_user.get_id(), 'user': flask_login.current_user.get_id(),
'comment': comment, 'name': name,
} }
db.write('wireguard', ips) db.write('wireguard', ips)
@ -70,7 +70,7 @@ def new():
'pubkey': pubkey, 'pubkey': pubkey,
'ip': str(ip), 'ip': str(ip),
'timestamp': now, 'timestamp': now,
'comment': comment, 'name': name,
'add_default': flask.request.json.get('add_default', False), 'add_default': flask.request.json.get('add_default', False),
'use_dns': flask.request.json.get('use_dns', True), 'use_dns': flask.request.json.get('use_dns', True),
} }