diff --git a/README.md b/README.md index a946f80..489314c 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Note: | `WGUI_USERNAME` | The username for the login page. Used for db initialization only | `admin` | | `WGUI_PASSWORD` | The password for the user on the login page. Will be hashed automatically. Used for db initialization only | `admin` | | `WGUI_PASSWORD_HASH` | The password hash for the user on the login page. (alternative to `WGUI_PASSWORD`). Used for db initialization only | N/A | +| `WGUI_FAVICON_FILE_PATH` | The file path used as website favicon | Embedded WireGuard logo | | `WGUI_ENDPOINT_ADDRESS` | The default endpoint address used in global settings | Resolved to your public ip address | | `WGUI_DNS` | The default DNS servers (comma-separated-list) used in the global settings | `1.1.1.1` | | `WGUI_MTU` | The default MTU used in global settings | `1450` | diff --git a/custom/img/favicon.ico b/custom/img/favicon.ico new file mode 100644 index 0000000..7852f45 Binary files /dev/null and b/custom/img/favicon.ico differ diff --git a/handler/routes.go b/handler/routes.go index 3ddbb2d..18a7d17 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net/http" + "os" "sort" "strings" "time" @@ -32,6 +33,15 @@ func Health() echo.HandlerFunc { } } +func Favicon() echo.HandlerFunc { + return func(c echo.Context) error { + if favicon, ok := os.LookupEnv(util.FaviconFilePathEnvVar); ok { + return c.File(favicon) + } + return c.Redirect(http.StatusFound, util.BasePath+"/static/custom/img/favicon.ico") + } +} + // LoginPage handler func LoginPage() echo.HandlerFunc { return func(c echo.Context) error { diff --git a/main.go b/main.go index 98a0e7c..683b5e8 100644 --- a/main.go +++ b/main.go @@ -148,6 +148,7 @@ func main() { } app.GET(util.BasePath+"/_health", handler.Health()) + app.GET(util.BasePath+"/favicon", handler.Favicon()) 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) diff --git a/templates/base.html b/templates/base.html index fd337a7..0f5d686 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,8 @@ {{template "title" .}} + + diff --git a/templates/login.html b/templates/login.html index c75aa39..515eb1a 100644 --- a/templates/login.html +++ b/templates/login.html @@ -7,6 +7,8 @@ WireGuard UI + + diff --git a/util/config.go b/util/config.go index 63044ca..7f5d221 100644 --- a/util/config.go +++ b/util/config.go @@ -34,6 +34,7 @@ const ( UsernameEnvVar = "WGUI_USERNAME" PasswordEnvVar = "WGUI_PASSWORD" PasswordHashEnvVar = "WGUI_PASSWORD_HASH" + FaviconFilePathEnvVar = "WGUI_FAVICON_FILE_PATH" EndpointAddressEnvVar = "WGUI_ENDPOINT_ADDRESS" DNSEnvVar = "WGUI_DNS" MTUEnvVar = "WGUI_MTU"