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:
|
||||
wg:
|
||||
|
@ -13,6 +13,8 @@ services:
|
|||
- EMAIL_FROM
|
||||
- EMAIL_FROM_NAME
|
||||
- SESSION_SECRET
|
||||
- WGUI_USERNAME=alpha
|
||||
- WGUI_PASSWORD=this-unusual-password
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
|
|
|
@ -8,11 +8,12 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/ngoduykhanh/wireguard-ui/model"
|
||||
"github.com/ngoduykhanh/wireguard-ui/util"
|
||||
"github.com/sdomino/scribble"
|
||||
"github.com/skip2/go-qrcode"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
|
||||
"github.com/ngoduykhanh/wireguard-ui/model"
|
||||
"github.com/ngoduykhanh/wireguard-ui/util"
|
||||
)
|
||||
|
||||
type JsonDB struct {
|
||||
|
@ -93,8 +94,8 @@ func (o *JsonDB) Init() error {
|
|||
// user info
|
||||
if _, err := os.Stat(userPath); os.IsNotExist(err) {
|
||||
user := new(model.User)
|
||||
user.Username = util.DefaultUsername
|
||||
user.Password = util.DefaultPassword
|
||||
user.Username = util.GetCredVar(util.UsernameEnvVar, util.DefaultUsername)
|
||||
user.Password = util.GetCredVar(util.PasswordEnvVar, util.DefaultPassword)
|
||||
o.conn.Write("server", "users", user)
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ Wireguard Clients
|
|||
</div>
|
||||
<form name="frm_email_client" id="frm_email_client">
|
||||
<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">
|
||||
<label for="_client_email_email" class="control-label">Email</label>
|
||||
<input type="text" class="form-control" id="_client_email_email" name="client_email_email">
|
||||
<label for="e_client_email" class="control-label">Email</label>
|
||||
<input type="text" class="form-control" id="e_client_email" name="client_email">
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
function submitEmailClient() {
|
||||
const client_id = $("#_client_email_id").val();
|
||||
const email = $("#_client_email_email").val();
|
||||
const client_id = $("#e_client_id").val();
|
||||
const email = $("#e_client_email").val();
|
||||
const data = {"id": client_id, "email": email};
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -429,8 +429,8 @@ Wireguard Clients
|
|||
const client = resp.Client;
|
||||
|
||||
modal.find(".modal-title").text("Email Client " + client.name);
|
||||
modal.find("#_client_id").val(client.id);
|
||||
modal.find("#_client_email").val(client.email);
|
||||
modal.find("#e_client_id").val(client.id);
|
||||
modal.find("#e_client_email").val(client.email);
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
const responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||
|
|
|
@ -21,4 +21,6 @@ const (
|
|||
DefaultMTU = 1450
|
||||
DefaultPersistentKeepalive = 15
|
||||
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
|
||||
}
|
||||
|
||||
// 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