mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
Resolves conflicts
This commit is contained in:
commit
5abb066df5
5 changed files with 25 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
version: '3'
|
version: "3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
wg:
|
wg:
|
||||||
|
@ -13,6 +13,8 @@ services:
|
||||||
- EMAIL_FROM
|
- EMAIL_FROM
|
||||||
- EMAIL_FROM_NAME
|
- EMAIL_FROM_NAME
|
||||||
- SESSION_SECRET
|
- SESSION_SECRET
|
||||||
|
- WGUI_USERNAME=alpha
|
||||||
|
- WGUI_PASSWORD=this-unusual-password
|
||||||
logging:
|
logging:
|
||||||
driver: json-file
|
driver: json-file
|
||||||
options:
|
options:
|
||||||
|
|
|
@ -8,11 +8,12 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ngoduykhanh/wireguard-ui/model"
|
|
||||||
"github.com/ngoduykhanh/wireguard-ui/util"
|
|
||||||
"github.com/sdomino/scribble"
|
"github.com/sdomino/scribble"
|
||||||
"github.com/skip2/go-qrcode"
|
"github.com/skip2/go-qrcode"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
|
|
||||||
|
"github.com/ngoduykhanh/wireguard-ui/model"
|
||||||
|
"github.com/ngoduykhanh/wireguard-ui/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JsonDB struct {
|
type JsonDB struct {
|
||||||
|
@ -93,8 +94,8 @@ func (o *JsonDB) Init() error {
|
||||||
// user info
|
// user info
|
||||||
if _, err := os.Stat(userPath); os.IsNotExist(err) {
|
if _, err := os.Stat(userPath); os.IsNotExist(err) {
|
||||||
user := new(model.User)
|
user := new(model.User)
|
||||||
user.Username = util.DefaultUsername
|
user.Username = util.GetCredVar(util.UsernameEnvVar, util.DefaultUsername)
|
||||||
user.Password = util.DefaultPassword
|
user.Password = util.GetCredVar(util.PasswordEnvVar, util.DefaultPassword)
|
||||||
o.conn.Write("server", "users", user)
|
o.conn.Write("server", "users", user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ Wireguard Clients
|
||||||
</div>
|
</div>
|
||||||
<form name="frm_email_client" id="frm_email_client">
|
<form name="frm_email_client" id="frm_email_client">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<input type="hidden" id="_client_email_id" name="_client_email_id">
|
<input type="hidden" id="e_client_id" name="e_client_id">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="_client_email_email" class="control-label">Email</label>
|
<label for="e_client_email" class="control-label">Email</label>
|
||||||
<input type="text" class="form-control" id="_client_email_email" name="client_email_email">
|
<input type="text" class="form-control" id="e_client_email" name="client_email">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer justify-content-between">
|
<div class="modal-footer justify-content-between">
|
||||||
|
@ -340,8 +340,8 @@ Wireguard Clients
|
||||||
|
|
||||||
// submitEmailClient function for sending an email to the client with the configuration
|
// submitEmailClient function for sending an email to the client with the configuration
|
||||||
function submitEmailClient() {
|
function submitEmailClient() {
|
||||||
const client_id = $("#_client_email_id").val();
|
const client_id = $("#e_client_id").val();
|
||||||
const email = $("#_client_email_email").val();
|
const email = $("#e_client_email").val();
|
||||||
const data = {"id": client_id, "email": email};
|
const data = {"id": client_id, "email": email};
|
||||||
$.ajax({
|
$.ajax({
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -429,8 +429,8 @@ Wireguard Clients
|
||||||
const client = resp.Client;
|
const client = resp.Client;
|
||||||
|
|
||||||
modal.find(".modal-title").text("Email Client " + client.name);
|
modal.find(".modal-title").text("Email Client " + client.name);
|
||||||
modal.find("#_client_id").val(client.id);
|
modal.find("#e_client_id").val(client.id);
|
||||||
modal.find("#_client_email").val(client.email);
|
modal.find("#e_client_email").val(client.email);
|
||||||
},
|
},
|
||||||
error: function (jqXHR, exception) {
|
error: function (jqXHR, exception) {
|
||||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||||
|
|
|
@ -21,4 +21,6 @@ const (
|
||||||
DefaultMTU = 1450
|
DefaultMTU = 1450
|
||||||
DefaultPersistentKeepalive = 15
|
DefaultPersistentKeepalive = 15
|
||||||
DefaultConfigFilePath = "/etc/wireguard/wg0.conf"
|
DefaultConfigFilePath = "/etc/wireguard/wg0.conf"
|
||||||
|
UsernameEnvVar = "WGUI_USERNAME"
|
||||||
|
PasswordEnvVar = "WGUI_PASSWORD"
|
||||||
)
|
)
|
||||||
|
|
|
@ -368,3 +368,11 @@ func WriteWireGuardServerConfig(tmplBox *rice.Box, serverConfig model.Server, cl
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCredVar reads value from environment variable or returns fallback
|
||||||
|
func GetCredVar(key, fallback string) string {
|
||||||
|
if value, ok := os.LookupEnv(key); ok {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue