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
2fdafd34ca
commit
5b88f8f566
|
|
@ -58,6 +58,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` |
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
|
|
@ -48,6 +48,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
|
|
@ -53,6 +53,9 @@ var (
|
|||
flagWgConfTemplate string
|
||||
flagBasePath string
|
||||
flagSubnetRanges string
|
||||
flagBrandText = "WireGuard UI"
|
||||
flagAccentColor = "#343a40"
|
||||
flagPageTitlePrefix string
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -94,6 +97,9 @@ func init() {
|
|||
flag.StringVar(&flagBasePath, "base-path", util.LookupEnvOrString("BASE_PATH", flagBasePath), "The base path of the URL")
|
||||
flag.StringVar(&flagSubnetRanges, "subnet-ranges", util.LookupEnvOrString("SUBNET_RANGES", flagSubnetRanges), "IP ranges to choose from when assigning an IP for a client.")
|
||||
flag.IntVar(&flagSessionMaxDuration, "session-max-duration", util.LookupEnvOrInt("SESSION_MAX_DURATION", flagSessionMaxDuration), "Max time in days a remembered session is refreshed and valid.")
|
||||
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")
|
||||
|
||||
var (
|
||||
smtpPasswordLookup = util.LookupEnvOrString("SMTP_PASSWORD", flagSmtpPassword)
|
||||
|
|
@ -143,6 +149,9 @@ func init() {
|
|||
util.WgConfTemplate = flagWgConfTemplate
|
||||
util.BasePath = util.ParseBasePath(flagBasePath)
|
||||
util.SubnetRanges = util.ParseSubnetRanges(flagSubnetRanges)
|
||||
util.BrandText = flagBrandText
|
||||
util.AccentColor = flagAccentColor
|
||||
util.PageTitlePrefix = flagPageTitlePrefix
|
||||
|
||||
lvl, _ := util.ParseLogLevel(util.LookupEnvOrString(util.LogLevel, "INFO"))
|
||||
|
||||
|
|
@ -186,6 +195,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")
|
||||
|
|
@ -210,6 +222,8 @@ func main() {
|
|||
|
||||
app.GET(util.BasePath, handler.WireGuardClients(db), handler.ValidSession, handler.RefreshSession)
|
||||
|
||||
app.GET(util.BasePath+"/logo", handler.Logo())
|
||||
|
||||
// Important: Make sure that all non-GET routes check the request content type using handler.ContentTypeJson to
|
||||
// mitigate CSRF attacks. This is effective, because browsers don't allow setting the Content-Type header on
|
||||
// cross-origin requests.
|
||||
|
|
|
|||
|
|
@ -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 -->
|
||||
|
|
@ -86,10 +86,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">
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ var (
|
|||
BasePath string
|
||||
SubnetRanges map[string]([]*net.IPNet)
|
||||
SubnetRangesOrder []string
|
||||
BrandText string
|
||||
AccentColor string
|
||||
PageTitlePrefix string
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -64,6 +67,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…
Reference in New Issue