diff --git a/README.md b/README.md index 74c446e..71d8a25 100644 --- a/README.md +++ b/README.md @@ -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` | diff --git a/custom/img/logo.png b/custom/img/logo.png new file mode 100644 index 0000000..5425633 Binary files /dev/null and b/custom/img/logo.png differ diff --git a/handler/routes.go b/handler/routes.go index ede3654..6dd0068 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -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 { diff --git a/main.go b/main.go index 1125746..f9ec553 100644 --- a/main.go +++ b/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. diff --git a/templates/base.html b/templates/base.html index 3640699..7bcd1fd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,7 @@
-