Added /wg
parent
7b3f7c5c66
commit
8ce161c560
|
@ -5,9 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ title or metadata.title }}</title>
|
||||
<meta name="description" content="{{ description or metadata.description }}">
|
||||
<link rel="stylesheet" href="{{ 'base.css' | url }}">
|
||||
<link rel="alternate" href="{{ metadata.feed.path | url }}" type="application/atom+xml" title="{{ metadata.title }}">
|
||||
<link rel="alternate" href="{{ metadata.jsonfeed.path | url }}" type="application/json" title="{{ metadata.title }}">
|
||||
<link rel="stylesheet" href="/base.css">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
title: Wireguard Dashboard
|
||||
layout: base.njk
|
||||
---
|
||||
|
||||
<h1>GF4 {{title}}</h1>
|
||||
|
||||
<p>Use this console to edit your network-connected devices. </p>
|
||||
|
||||
<div id="add">
|
||||
<input type="text" id="add-name" text="hostname"></input>
|
||||
<button onclick="addPeer">Add</button>
|
||||
</div>
|
||||
|
||||
<ul id="peers"></ul>
|
||||
|
||||
<script>
|
||||
/* global window fetch */
|
||||
const add_name_el = document.getElementById('add-name')
|
||||
const peers_el = document.getElementById('peers')
|
||||
|
||||
// Get user object
|
||||
let user; (async (url) => {
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
user = await res.json()
|
||||
} catch (err) {
|
||||
console.error(`Failed to fetch ${url}`)
|
||||
if (err) console.error(err)
|
||||
} console.log(`Retrieved ${user.name} from ${url}`)
|
||||
|
||||
// Populate page with peers
|
||||
for (const peer of user.peers) {
|
||||
peers_el.innerHTML += `<li><a href="//${peer.name}.${user.name}.gf4/">${peer.name}</a>: ${peer.ipv4} ${peer.ipv6} <button onclick="delPeer(${peer.name})">Delete</button></li>\n`
|
||||
}
|
||||
|
||||
})('https://wgapi.ksn.gf4/list')
|
||||
|
||||
// Edit peers
|
||||
const addPeer = () => {
|
||||
window.location.href = `https://wgapi.ksn.gf4/add?name=${add_name_el.value}&token=${user.token}`
|
||||
}
|
||||
const delPeer = (name) => {
|
||||
window.location.href = `https://wgapi.ksn.gf4/del?name=${name}&token=${user.token}`
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue