mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-06-07 00:46:58 +03:00
Additional configuration env variables
WGUI_BRAND_TEXT - The brand text of the web application WGUI_ACCENT_COLOR - The color of the interface sidebar WGUI_LOGO_FILE_PATH - The file path of the website logo WGUI_PAGE_TITLE_PREFIX - The HTML title prefix for all pages
This commit is contained in:
parent
b55543f424
commit
956496d840
7 changed files with 41 additions and 7 deletions
|
@ -53,6 +53,10 @@ docker-compose up
|
|||
| `WGUI_TABLE` | The default WireGuard table value settings | `auto` |
|
||||
| `WGUI_CONFIG_FILE_PATH` | The default WireGuard config file path used in global settings | `/etc/wireguard/wg0.conf` |
|
||||
| `WGUI_LOG_LEVEL` | The default log level. Possible values: `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `INFO` |
|
||||
| `WGUI_BRAND_TEXT` | The brand text of the web application | `WireGuard UI` |
|
||||
| `WGUI_ACCENT_COLOR` | The color of the interface sidebar | `#343a40` |
|
||||
| `WGUI_LOGO_FILE_PATH` | The file path of the website logo | Embedded WireGuard logo |
|
||||
| `WGUI_PAGE_TITLE_PREFIX` | The HTML title prefix for all pages | N/A |
|
||||
| `WG_CONF_TEMPLATE` | The custom `wg.conf` config file template. Please refer to our [default template](https://github.com/ngoduykhanh/wireguard-ui/blob/master/templates/wg.conf) | N/A |
|
||||
| `EMAIL_FROM_ADDRESS` | The sender email address | N/A |
|
||||
| `EMAIL_FROM_NAME` | The sender name | `WireGuard UI` |
|
||||
|
|
BIN
custom/img/logo.png
Normal file
BIN
custom/img/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
|
@ -42,6 +42,15 @@ func Favicon() echo.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
func Logo() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
if logo, ok := os.LookupEnv(util.LogoFilePathEnvVar); ok {
|
||||
return c.File(logo)
|
||||
}
|
||||
return c.Redirect(http.StatusFound, util.BasePath+"/static/custom/img/logo.png")
|
||||
}
|
||||
}
|
||||
|
||||
// LoginPage handler
|
||||
func LoginPage() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
|
|
14
main.go
14
main.go
|
@ -41,6 +41,9 @@ var (
|
|||
flagSessionSecret string = util.RandomString(32)
|
||||
flagWgConfTemplate string
|
||||
flagBasePath string
|
||||
flagBrandText string = "WireGuard UI"
|
||||
flagAccentColor string = "#343a40"
|
||||
flagPageTitlePrefix string
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -80,6 +83,10 @@ func init() {
|
|||
flag.StringVar(&flagSessionSecret, "session-secret", util.LookupEnvOrString("SESSION_SECRET", flagSessionSecret), "The key used to encrypt session cookies.")
|
||||
flag.StringVar(&flagWgConfTemplate, "wg-conf-template", util.LookupEnvOrString("WG_CONF_TEMPLATE", flagWgConfTemplate), "Path to custom wg.conf template.")
|
||||
flag.StringVar(&flagBasePath, "base-path", util.LookupEnvOrString("BASE_PATH", flagBasePath), "The base path of the URL")
|
||||
flag.StringVar(&flagBrandText, "brand-text", util.LookupEnvOrString("WGUI_BRAND_TEXT", flagBrandText), "The UI brand text or name")
|
||||
flag.StringVar(&flagAccentColor, "accent-color", util.LookupEnvOrString("WGUI_ACCENT_COLOR", flagAccentColor), "The UI accent color")
|
||||
flag.StringVar(&flagPageTitlePrefix, "page-title-prefix", util.LookupEnvOrString("WGUI_PAGE_TITLE_PREFIX", flagPageTitlePrefix), "The prefix of the page title")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
// update runtime config
|
||||
|
@ -98,6 +105,9 @@ func init() {
|
|||
util.SessionSecret = []byte(flagSessionSecret)
|
||||
util.WgConfTemplate = flagWgConfTemplate
|
||||
util.BasePath = util.ParseBasePath(flagBasePath)
|
||||
util.BrandText = flagBrandText
|
||||
util.AccentColor = flagAccentColor
|
||||
util.PageTitlePrefix = flagPageTitlePrefix
|
||||
|
||||
// print only if log level is INFO or lower
|
||||
if lvl, _ := util.ParseLogLevel(util.LookupEnvOrString(util.LogLevel, "INFO")); lvl <= log.INFO {
|
||||
|
@ -133,6 +143,9 @@ func main() {
|
|||
extraData["gitCommit"] = gitCommit
|
||||
extraData["basePath"] = util.BasePath
|
||||
extraData["loginDisabled"] = flagDisableLogin
|
||||
extraData["brandText"] = flagBrandText;
|
||||
extraData["accentColor"] = flagAccentColor;
|
||||
extraData["pageTitlePrefix"] = flagPageTitlePrefix;
|
||||
|
||||
// strip the "templates/" prefix from the embedded directory so files can be read by their direct name (e.g.
|
||||
// "base.html" instead of "templates/base.html")
|
||||
|
@ -170,6 +183,7 @@ func main() {
|
|||
app.GET(util.BasePath+"/about", handler.AboutPage())
|
||||
app.GET(util.BasePath+"/_health", handler.Health())
|
||||
app.GET(util.BasePath+"/favicon", handler.Favicon())
|
||||
app.GET(util.BasePath+"/logo", handler.Logo())
|
||||
app.POST(util.BasePath+"/new-client", handler.NewClient(db), handler.ValidSession, handler.ContentTypeJson)
|
||||
app.POST(util.BasePath+"/update-client", handler.UpdateClient(db), handler.ValidSession, handler.ContentTypeJson)
|
||||
app.POST(util.BasePath+"/email-client", handler.EmailClient(db, sendmail, defaultEmailSubject, defaultEmailContent), handler.ValidSession, handler.ContentTypeJson)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>{{template "title" .}}</title>
|
||||
<title>{{.pageTitlePrefix}}{{template "title" .}}</title>
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Favicon -->
|
||||
|
@ -84,10 +84,10 @@
|
|||
<!-- /.navbar -->
|
||||
|
||||
<!-- Main Sidebar Container -->
|
||||
<aside class="main-sidebar sidebar-dark-primary elevation-4">
|
||||
<aside class="main-sidebar sidebar-dark-primary elevation-4" style="background-color: {{.accentColor}};">
|
||||
<!-- Brand Logo -->
|
||||
<a href="{{.basePath}}" class="brand-link">
|
||||
<span class="brand-text"> WIREGUARD UI</span>
|
||||
<span class="brand-text"> {{.brandText}}</span>
|
||||
</a>
|
||||
|
||||
<!-- Sidebar -->
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>WireGuard UI</title>
|
||||
<title>{{.brandText}}</title>
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Favicon -->
|
||||
|
@ -24,8 +24,8 @@
|
|||
|
||||
<body class="hold-transition login-page">
|
||||
<div class="login-box">
|
||||
<div class="login-logo">
|
||||
<a href="https://github.com/ngoduykhanh/wireguard-ui">WireGuard UI</a>
|
||||
<div class="login-logo pb-3">
|
||||
<img class="img-fluid" src="{{.basePath}}/logo">
|
||||
</div>
|
||||
<!-- /.login-logo -->
|
||||
<div class="card">
|
||||
|
|
|
@ -19,6 +19,9 @@ var (
|
|||
SessionSecret []byte
|
||||
WgConfTemplate string
|
||||
BasePath string
|
||||
BrandText string
|
||||
AccentColor string
|
||||
PageTitlePrefix string
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -53,6 +56,10 @@ const (
|
|||
DefaultClientExtraAllowedIpsEnvVar = "WGUI_DEFAULT_CLIENT_EXTRA_ALLOWED_IPS"
|
||||
DefaultClientUseServerDNSEnvVar = "WGUI_DEFAULT_CLIENT_USE_SERVER_DNS"
|
||||
DefaultClientEnableAfterCreationEnvVar = "WGUI_DEFAULT_CLIENT_ENABLE_AFTER_CREATION"
|
||||
BrandTextEnvVar = "WGUI_BRAND_TEXT"
|
||||
AccentColorEnvVar = "WGUI_ACCENT_COLOR"
|
||||
PageTitlePrefixEnvVar = "WGUI_PAGE_TITLE_PREFIX"
|
||||
LogoFilePathEnvVar = "WGUI_LOGO_FILE_PATH"
|
||||
)
|
||||
|
||||
func ParseBasePath(basePath string) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue