mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00
Merge f1192d6c0b
into 2fdafd34ca
This commit is contained in:
commit
d6d02fadfc
7 changed files with 33 additions and 10 deletions
1
.github/workflows/docker-build.yml
vendored
1
.github/workflows/docker-build.yml
vendored
|
@ -1,6 +1,7 @@
|
||||||
name: Build container images
|
name: Build container images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "master"
|
- "master"
|
||||||
|
|
|
@ -481,6 +481,10 @@ func NewClient(db store.IStore) echo.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if client.FriendlyName == "" {
|
||||||
|
client.FriendlyName = client.Name + "-" + client.ID
|
||||||
|
}
|
||||||
|
|
||||||
if client.PresharedKey == "" {
|
if client.PresharedKey == "" {
|
||||||
presharedKey, err := wgtypes.GenerateKey()
|
presharedKey, err := wgtypes.GenerateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -919,6 +923,7 @@ func Status(db store.IStore) echo.HandlerFunc {
|
||||||
Connected bool
|
Connected bool
|
||||||
AllocatedIP string
|
AllocatedIP string
|
||||||
Endpoint string
|
Endpoint string
|
||||||
|
FriendlyName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeviceVM struct {
|
type DeviceVM struct {
|
||||||
|
@ -989,6 +994,7 @@ func Status(db store.IStore) echo.HandlerFunc {
|
||||||
if _client, ok := m[pVm.PublicKey]; ok {
|
if _client, ok := m[pVm.PublicKey]; ok {
|
||||||
pVm.Name = _client.Name
|
pVm.Name = _client.Name
|
||||||
pVm.Email = _client.Email
|
pVm.Email = _client.Email
|
||||||
|
pVm.FriendlyName = _client.FriendlyName
|
||||||
}
|
}
|
||||||
devVm.Peers = append(devVm.Peers, pVm)
|
devVm.Peers = append(devVm.Peers, pVm)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ type Client struct {
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
FriendlyName string `json:"friendly_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientData includes the Client and extra data
|
// ClientData includes the Client and extra data
|
||||||
|
|
|
@ -207,6 +207,10 @@
|
||||||
<label for="client_name" class="control-label">Name</label>
|
<label for="client_name" class="control-label">Name</label>
|
||||||
<input type="text" class="form-control" id="client_name" name="client_name">
|
<input type="text" class="form-control" id="client_name" name="client_name">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="client_friendly_name" class="control-label">Friendly Name</label>
|
||||||
|
<input type="text" class="form-control" id="client_friendly_name" name="client_friendly_name">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="client_email" class="control-label">Email</label>
|
<label for="client_email" class="control-label">Email</label>
|
||||||
<input type="text" class="form-control" id="client_email" name="client_email">
|
<input type="text" class="form-control" id="client_email" name="client_email">
|
||||||
|
@ -460,6 +464,7 @@
|
||||||
// submitNewClient function for new client form submission
|
// submitNewClient function for new client form submission
|
||||||
function submitNewClient() {
|
function submitNewClient() {
|
||||||
const name = $("#client_name").val();
|
const name = $("#client_name").val();
|
||||||
|
const friendly_name = $("#client_friendly_name").val();
|
||||||
const email = $("#client_email").val();
|
const email = $("#client_email").val();
|
||||||
const telegram_userid = $("#client_telegram_userid").val();
|
const telegram_userid = $("#client_telegram_userid").val();
|
||||||
const allocated_ips = $("#client_allocated_ips").val().split(",");
|
const allocated_ips = $("#client_allocated_ips").val().split(",");
|
||||||
|
@ -487,7 +492,7 @@
|
||||||
|
|
||||||
const additional_notes = $("#additional_notes").val();
|
const additional_notes = $("#additional_notes").val();
|
||||||
|
|
||||||
const data = {"name": name, "email": email, "telegram_userid": telegram_userid, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
|
const data = {"name": name, "friendly_name": friendly_name, "email": email, "telegram_userid": telegram_userid, "allocated_ips": allocated_ips, "allowed_ips": allowed_ips,
|
||||||
"extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint, "use_server_dns": use_server_dns, "enabled": enabled,
|
"extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint, "use_server_dns": use_server_dns, "enabled": enabled,
|
||||||
"public_key": public_key, "preshared_key": preshared_key, "additional_notes": additional_notes};
|
"public_key": public_key, "preshared_key": preshared_key, "additional_notes": additional_notes};
|
||||||
|
|
||||||
|
@ -623,6 +628,7 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#modal_new_client").on('shown.bs.modal', function (e) {
|
$("#modal_new_client").on('shown.bs.modal', function (e) {
|
||||||
$("#client_name").val("");
|
$("#client_name").val("");
|
||||||
|
$("#client_friendly_name").val("");
|
||||||
$("#client_email").val("");
|
$("#client_email").val("");
|
||||||
$("#client_public_key").val("");
|
$("#client_public_key").val("");
|
||||||
$("#client_preshared_key").val("");
|
$("#client_preshared_key").val("");
|
||||||
|
|
|
@ -125,6 +125,10 @@ Wireguard Clients
|
||||||
<label for="_client_name" class="control-label">Name</label>
|
<label for="_client_name" class="control-label">Name</label>
|
||||||
<input type="text" class="form-control" id="_client_name" name="_client_name">
|
<input type="text" class="form-control" id="_client_name" name="_client_name">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="_client_friendly_name" class="control-label">Name</label>
|
||||||
|
<input type="text" class="form-control" id="_client_friendly_name" name="_client_friendly_name">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="_client_email" class="control-label">Email</label>
|
<label for="_client_email" class="control-label">Email</label>
|
||||||
<input type="text" class="form-control" id="_client_email" name="client_email">
|
<input type="text" class="form-control" id="_client_email" name="client_email">
|
||||||
|
@ -628,6 +632,7 @@ Wireguard Clients
|
||||||
modal.find("#_client_id").val(client.id);
|
modal.find("#_client_id").val(client.id);
|
||||||
modal.find("#_client_telegram_userid").val(client.telegram_userid);
|
modal.find("#_client_telegram_userid").val(client.telegram_userid);
|
||||||
modal.find("#_client_name").val(client.name);
|
modal.find("#_client_name").val(client.name);
|
||||||
|
modal.find("#_client_friendly_name").val(client.name);
|
||||||
modal.find("#_client_email").val(client.email);
|
modal.find("#_client_email").val(client.email);
|
||||||
|
|
||||||
let preselectedEl
|
let preselectedEl
|
||||||
|
@ -757,6 +762,7 @@ Wireguard Clients
|
||||||
function submitEditClient() {
|
function submitEditClient() {
|
||||||
const client_id = $("#_client_id").val();
|
const client_id = $("#_client_id").val();
|
||||||
const name = $("#_client_name").val();
|
const name = $("#_client_name").val();
|
||||||
|
const friendly_name = $("#_client_friendly_name").val();
|
||||||
const email = $("#_client_email").val();
|
const email = $("#_client_email").val();
|
||||||
const telegram_userid = $("#_client_telegram_userid").val();
|
const telegram_userid = $("#_client_telegram_userid").val();
|
||||||
const allocated_ips = $("#_client_allocated_ips").val().split(",");
|
const allocated_ips = $("#_client_allocated_ips").val().split(",");
|
||||||
|
@ -784,7 +790,7 @@ Wireguard Clients
|
||||||
|
|
||||||
const additional_notes = $("#_additional_notes").val();
|
const additional_notes = $("#_additional_notes").val();
|
||||||
|
|
||||||
const data = {"id": client_id, "name": name, "email": email, "telegram_userid": telegram_userid, "allocated_ips": allocated_ips,
|
const data = {"id": client_id, "name": name, "friendly_name": friendly_name, "email": email, "telegram_userid": telegram_userid, "allocated_ips": allocated_ips,
|
||||||
"allowed_ips": allowed_ips, "extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint,
|
"allowed_ips": allowed_ips, "extra_allowed_ips": extra_allowed_ips, "endpoint": endpoint,
|
||||||
"use_server_dns": use_server_dns, "enabled": enabled, "public_key": public_key, "preshared_key": preshared_key, "additional_notes": additional_notes};
|
"use_server_dns": use_server_dns, "enabled": enabled, "public_key": public_key, "preshared_key": preshared_key, "additional_notes": additional_notes};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ Connected Peers
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
|
<th scope="col">Friendly Name</th>
|
||||||
<th scope="col">Email</th>
|
<th scope="col">Email</th>
|
||||||
<th scope="col">Allocated IPs</th>
|
<th scope="col">Allocated IPs</th>
|
||||||
<th scope="col">Endpoint</th>
|
<th scope="col">Endpoint</th>
|
||||||
|
@ -55,6 +56,7 @@ Connected Peers
|
||||||
<tr {{ if $peer.Connected }} class="table-success" {{ end }}>
|
<tr {{ if $peer.Connected }} class="table-success" {{ end }}>
|
||||||
<th scope="row">{{ $idx }}</th>
|
<th scope="row">{{ $idx }}</th>
|
||||||
<td>{{ $peer.Name }}</td>
|
<td>{{ $peer.Name }}</td>
|
||||||
|
<td>{{ $peer.FriendlyName }}</td>
|
||||||
<td>{{ $peer.Email }}</td>
|
<td>{{ $peer.Email }}</td>
|
||||||
<td>{{ $peer.AllocatedIP }}</td>
|
<td>{{ $peer.AllocatedIP }}</td>
|
||||||
<td>{{ $peer.Endpoint }}</td>
|
<td>{{ $peer.Endpoint }}</td>
|
||||||
|
|
|
@ -25,6 +25,7 @@ Table = {{ .globalSettings.Table }}
|
||||||
# Notes:
|
# Notes:
|
||||||
# {{ .Client.AdditionalNotes }}{{end}}
|
# {{ .Client.AdditionalNotes }}{{end}}
|
||||||
[Peer]
|
[Peer]
|
||||||
|
# friendly_name = {{ .Client.FriendlyName }}
|
||||||
PublicKey = {{ .Client.PublicKey }}
|
PublicKey = {{ .Client.PublicKey }}
|
||||||
{{if .Client.PresharedKey}}PresharedKey = {{ .Client.PresharedKey }}{{end}}
|
{{if .Client.PresharedKey}}PresharedKey = {{ .Client.PresharedKey }}{{end}}
|
||||||
AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
|
AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue