diff --git a/README.md b/README.md index 598a994..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` | @@ -68,7 +69,7 @@ Note: | `SMTP_USERNAME` | The SMTP username | N/A | | `SMTP_PASSWORD` | The SMTP user password | N/A | | `SMTP_AUTH_TYPE` | The SMTP authentication type. Possible values: `PLAIN`, `LOGIN`, `NONE` | `NONE` | -| `SMTP_ENCRYPTION` | the encryption method. Possible values: `SSL`, `SSLTLS`, `TLS`, `STARTTLS` | `STARTTLS` | +| `SMTP_ENCRYPTION` | the encryption method. Possible values: `NONE`, `SSL`, `SSLTLS`, `TLS`, `STARTTLS` | `STARTTLS` | ### Defaults for server configuration 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/emailer/smtp.go b/emailer/smtp.go index d1fdbae..f77db7c 100644 --- a/emailer/smtp.go +++ b/emailer/smtp.go @@ -33,6 +33,8 @@ func authType(authType string) mail.AuthType { func encryptionType(encryptionType string) mail.Encryption { switch strings.ToUpper(encryptionType) { + case "NONE": + return mail.EncryptionNone case "SSL": return mail.EncryptionSSL case "SSLTLS": diff --git a/handler/routes.go b/handler/routes.go index 3ddbb2d..04f3208 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 { @@ -607,6 +617,8 @@ func Status(db store.IStore) echo.HandlerFunc { LastHandshakeTime time.Time LastHandshakeRel time.Duration Connected bool + AllocatedIP string + Endpoint string } type DeviceVM struct { @@ -654,12 +666,21 @@ func Status(db store.IStore) echo.HandlerFunc { for i := range devices { devVm := DeviceVM{Name: devices[i].Name} for j := range devices[i].Peers { + var allocatedIPs string + for _, ip := range devices[i].Peers[j].AllowedIPs { + if len(allocatedIPs) > 0 { + allocatedIPs += "
" + } + allocatedIPs += ip.String() + } pVm := PeerVM{ PublicKey: devices[i].Peers[j].PublicKey.String(), ReceivedBytes: devices[i].Peers[j].ReceiveBytes, TransmitBytes: devices[i].Peers[j].TransmitBytes, LastHandshakeTime: devices[i].Peers[j].LastHandshakeTime, LastHandshakeRel: time.Since(devices[i].Peers[j].LastHandshakeTime), + AllocatedIP: allocatedIPs, + Endpoint: devices[i].Peers[j].Endpoint.String(), } pVm.Connected = pVm.LastHandshakeRel.Minutes() < 3. @@ -808,3 +829,13 @@ func ApplyServerConfig(db store.IStore, tmplBox *rice.Box) echo.HandlerFunc { return c.JSON(http.StatusOK, jsonHTTPResponse{true, "Applied server config successfully"}) } } + +// AboutPage handler +func AboutPage() echo.HandlerFunc { + return func(c echo.Context) error { + return c.Render(http.StatusOK, "about.html", map[string]interface{}{ + "baseData": model.BaseData{Active: "about", CurrentUser: currentUser(c)}, + }) + } +} + diff --git a/main.go b/main.go index 3f0cd13..cbfa8b7 100644 --- a/main.go +++ b/main.go @@ -61,7 +61,7 @@ func init() { flag.StringVar(&flagSmtpUsername, "smtp-username", util.LookupEnvOrString("SMTP_USERNAME", flagSmtpUsername), "SMTP Username") flag.StringVar(&flagSmtpPassword, "smtp-password", util.LookupEnvOrString("SMTP_PASSWORD", flagSmtpPassword), "SMTP Password") flag.BoolVar(&flagSmtpNoTLSCheck, "smtp-no-tls-check", util.LookupEnvOrBool("SMTP_NO_TLS_CHECK", flagSmtpNoTLSCheck), "Disable TLS verification for SMTP. This is potentially dangerous.") - flag.StringVar(&flagSmtpEncryption, "smtp-encryption", util.LookupEnvOrString("SMTP_ENCRYPTION", flagSmtpEncryption), "SMTP Encryption : SSL, SSLTLS, TLS or STARTTLS (by default)") + flag.StringVar(&flagSmtpEncryption, "smtp-encryption", util.LookupEnvOrString("SMTP_ENCRYPTION", flagSmtpEncryption), "SMTP Encryption : NONE, SSL, SSLTLS, TLS or STARTTLS (by default)") flag.StringVar(&flagSmtpAuthType, "smtp-auth-type", util.LookupEnvOrString("SMTP_AUTH_TYPE", flagSmtpAuthType), "SMTP Auth Type : PLAIN, LOGIN or NONE.") flag.StringVar(&flagSendgridApiKey, "sendgrid-api-key", util.LookupEnvOrString("SENDGRID_API_KEY", flagSendgridApiKey), "Your sendgrid api key.") flag.StringVar(&flagEmailFrom, "email-from", util.LookupEnvOrString("EMAIL_FROM_ADDRESS", flagEmailFrom), "'From' email address.") @@ -147,7 +147,9 @@ func main() { sendmail = emailer.NewSmtpMail(util.SmtpHostname, util.SmtpPort, util.SmtpUsername, util.SmtpPassword, util.SmtpNoTLSCheck, util.SmtpAuthType, util.EmailFromName, util.EmailFrom, util.SmtpEncryption) } + app.GET(util.BasePath+"/about", handler.AboutPage()) 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/router/router.go b/router/router.go index 0f9facc..9aeaf1b 100644 --- a/router/router.go +++ b/router/router.go @@ -93,6 +93,11 @@ func New(tmplBox *rice.Box, extraData map[string]string, secret []byte) *echo.Ec log.Fatal(err) } + aboutPageString, err := tmplBox.String("about.html") + if err != nil { + log.Fatal(err) + } + // create template list funcs := template.FuncMap{ "StringsJoin": strings.Join, @@ -105,6 +110,7 @@ func New(tmplBox *rice.Box, extraData map[string]string, secret []byte) *echo.Ec templates["global_settings.html"] = template.Must(template.New("global_settings").Funcs(funcs).Parse(tmplBaseString + tmplGlobalSettingsString)) templates["status.html"] = template.Must(template.New("status").Funcs(funcs).Parse(tmplBaseString + tmplStatusString)) templates["wake_on_lan_hosts.html"] = template.Must(template.New("wake_on_lan_hosts").Funcs(funcs).Parse(tmplBaseString + tmplWakeOnLanHostsString)) + templates["about.html"] = template.Must(template.New("about").Funcs(funcs).Parse(tmplBaseString + aboutPageString)) e.Logger.SetLevel(log.DEBUG) e.Pre(middleware.RemoveTrailingSlash()) diff --git a/templates/about.html b/templates/about.html new file mode 100644 index 0000000..4fc6b77 --- /dev/null +++ b/templates/about.html @@ -0,0 +1,139 @@ +{{ define "title"}} +About +{{ end }} + +{{ define "top_css"}} +{{ end }} + +{{ define "username"}} +{{ .username }} +{{ end }} + +{{ define "page_title"}} +About +{{ end }} + +{{ define "page_content"}} +
+
+ +
+ +
+
+
+

About Wireguard-UI

+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + + +
+
+
+ +
+
+ Copyright © + + Wireguard UI. + All rights reserved. + +
+
+ +
+
+ +
+
+{{ end }} + +{{ define "bottom_js"}} + +{{ end }} diff --git a/templates/base.html b/templates/base.html index fd337a7..1987ab0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,8 @@ {{template "title" .}} + + @@ -44,17 +46,17 @@ - - - - - - - - - - - + - +