diff --git a/cmd/wg-portal/assets/tpl/admin_create_clients.gohtml b/cmd/wg-portal/assets/tpl/admin_create_clients.gohtml new file mode 100644 index 0000000..ba8e337 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_create_clients.gohtml @@ -0,0 +1,73 @@ + + + + + + {{ .Static.WebsiteTitle }} - Admin + + + + + + + + + + + {{template "prt_nav.gohtml" .}} +
+

Create new clients

+

Enter valid user email addresses to quickly create new accounts.

+ {{template "prt_flashes.gohtml" .}} +
+ +
+
+ + +
+
+
+
+ + +
+
+ + + Cancel +
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_create_clients.html b/cmd/wg-portal/assets/tpl/admin_create_clients.html deleted file mode 100644 index 3d59b41..0000000 --- a/cmd/wg-portal/assets/tpl/admin_create_clients.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Admin - - - - - - - - - - - {{template "prt_nav.html" .}} -
-

Create new clients

-

Enter valid user email addresses to quickly create new accounts.

- {{template "prt_flashes.html" .}} -
- -
-
- - -
-
-
-
- - -
-
- - - Cancel -
-
- {{template "prt_footer.html" .}} - - - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_edit_client.gohtml b/cmd/wg-portal/assets/tpl/admin_edit_client.gohtml new file mode 100644 index 0000000..b43e6fe --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_edit_client.gohtml @@ -0,0 +1,213 @@ + + + + + + {{ .Static.WebsiteTitle }} - Admin + + + + + + + + {{template "prt_nav.gohtml" .}} +
+ {{template "prt_flashes.gohtml" .}} + + + {{if eq .Device.Type "server"}} + {{if .Peer.IsNew}} +

Create a new client

+ {{else}} +

Edit client: {{.Peer.Identifier}}

+ {{end}} + +
+ + + + + + {{if .EditableKeys}} +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ {{else}} + + +
+
+ + +
+
+ {{end}} +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+
+ + +
+
+
+ + + + Cancel +
+ {{end}} + + + {{if eq .Device.Type "client"}} + {{if .Peer.IsNew}} +

Create a new remote endpoint

+ {{else}} +

Edit remote endpoint: {{.Peer.Identifier}}

+ {{end}} + +
+ + + + + + +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+
+
+ + + + Cancel +
+ {{end}} +
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_edit_client.html b/cmd/wg-portal/assets/tpl/admin_edit_client.html deleted file mode 100644 index 812d7ef..0000000 --- a/cmd/wg-portal/assets/tpl/admin_edit_client.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Admin - - - - - - - - {{template "prt_nav.html" .}} -
- {{template "prt_flashes.html" .}} - - - {{if eq .Device.Type "server"}} - {{if .Peer.IsNew}} -

Create a new client

- {{else}} -

Edit client: {{.Peer.Identifier}}

- {{end}} - -
- - - - - - {{if .EditableKeys}} -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- {{else}} - - -
-
- - -
-
- {{end}} -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - -
-
- -
-
-
- - -
-
- - -
-
-
- - - - Cancel -
- {{end}} - - - {{if eq .Device.Type "client"}} - {{if .Peer.IsNew}} -

Create a new remote endpoint

- {{else}} -

Edit remote endpoint: {{.Peer.Identifier}}

- {{end}} - -
- - - - - - -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - -
-
- -
-
-
- - -
-
-
- - - - Cancel -
- {{end}} -
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_edit_interface.gohtml b/cmd/wg-portal/assets/tpl/admin_edit_interface.gohtml new file mode 100644 index 0000000..50d5573 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_edit_interface.gohtml @@ -0,0 +1,263 @@ + + + + + + {{ .Static.WebsiteTitle }} - Admin + + + + + + + + {{template "prt_nav.gohtml" .}} +
+

Edit interface {{.Device.DeviceName}}

+ {{template "prt_flashes.gohtml" .}} + + + +
+ +
+
+ + + +

Server's interface configuration

+
+
+ + +
+
+ {{if .EditableKeys}} +
+
+ + +
+
+
+
+ + +
+
+ {{else}} + +
+
+ + +
+
+ {{end}} +
+
+ + +
+
+ + +
+
+

Client's global configuration (g)

+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+

Interface configuration hooks

+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + + Cancel + Apply Global Settings (g) to clients +
+
+ + +
+
+ + + +

Client's interface configuration

+
+
+ + +
+
+ {{if .EditableKeys}} +
+
+ + +
+
+
+
+ + +
+
+ {{else}} + +
+
+ + +
+
+ {{end}} +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+

Interface configuration hooks

+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ + + Cancel +
+
+
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_edit_interface.html b/cmd/wg-portal/assets/tpl/admin_edit_interface.html deleted file mode 100644 index 841c6c7..0000000 --- a/cmd/wg-portal/assets/tpl/admin_edit_interface.html +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Admin - - - - - - - - {{template "prt_nav.html" .}} -
-

Edit interface {{.Device.DeviceName}}

- {{template "prt_flashes.html" .}} - - - -
- -
-
- - - -

Server's interface configuration

-
-
- - -
-
- {{if .EditableKeys}} -
-
- - -
-
-
-
- - -
-
- {{else}} - -
-
- - -
-
- {{end}} -
-
- - -
-
- - -
-
-

Client's global configuration (g)

-
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-

Interface configuration hooks

-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- - - Cancel - Apply Global Settings (g) to clients -
-
- - -
-
- - - -

Client's interface configuration

-
-
- - -
-
- {{if .EditableKeys}} -
-
- - -
-
-
-
- - -
-
- {{else}} - -
-
- - -
-
- {{end}} -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
-

Interface configuration hooks

-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - - Cancel -
-
-
-
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_index.gohtml b/cmd/wg-portal/assets/tpl/admin_index.gohtml new file mode 100644 index 0000000..383d682 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_index.gohtml @@ -0,0 +1,277 @@ + + + + + + + {{ .Static.WebsiteTitle }} - Admin + + + + + + + +{{template "prt_nav.gohtml" .}} +
+ + {{template "prt_flashes.gohtml" .}} +
+
+
+
+ Interface status for {{.Interface.Identifier}} {{if eq $.Interface.Type "server"}}(server mode){{end}}{{if eq $.Interface.Type "client"}}(client mode){{end}} +
+ +     + +     + +     + +
+
+
+
+ {{if eq $.Interface.Type "server"}} +
+ + + + + + + + + + + + + + + + + + + + + + + +
Public Key:{{.Interface.PublicKey}}
Public Endpoint:{{.Interface.PeerDefEndpoint}}
Listening Port:{{.Interface.ListenPort}}
Enabled Peers:{{len .InterfacePeers}}
Total Peers:{{.TotalPeers}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
IP Address:{{.Interface.AddressStr}}
Default allowed IP's:{{.Interface.PeerDefAllowedIPsStr}}
Default DNS servers:{{.Interface.PeerDefDnsStr}}
Default MTU:{{.Interface.Mtu}}
Default Keepalive Interval:{{.Interface.PeerDefPersistentKeepalive}}
+
+ {{end}} + {{if eq $.Interface.Type "client"}} +
+ + + + + + + + + + + + + + + +
Public Key:{{.Interface.PublicKey}}
Enabled Endpoints:{{len .InterfacePeers}}
Total Endpoints:{{.TotalPeers}}
+
+
+ + + + + + + + + + + + + + + +
IP Address:{{.Interface.AddressStr}}
DNS servers:{{.Interface.DnsStr}}
Default MTU:{{.Interface.Mtu}}
+
+ {{end}} +
+
+
+
+
+ +
+
+ {{if eq $.Interface.Type "server"}} +

Current VPN Peers

+ {{end}} + {{if eq $.Interface.Type "client"}} +

Current VPN Endpoints

+ {{end}} +
+
+ + {{if eq $.Interface.Type "server"}} + + {{end}} + +
+
+
+ + + + + + + {{if eq $.Interface.Type "server"}} + + {{end}} + {{if eq $.Interface.Type "server"}} + + {{end}} + {{if eq $.Interface.Type "client"}} + + {{end}} + + + + + + {{range $i, $p :=$.PagedInterfacePeers}} + {{$peerUser:= $p.Email}} + + + + + {{if eq $.Device.Type "server"}} + + {{end}} + {{if eq $.Device.Type "server"}} + + {{end}} + {{if eq $.Device.Type "client"}} + + {{end}} + + + + + + + {{end}} + +
Identifier Public Key User IP's Endpoint Handshake
+ + + + {{$p.Identifier}}{{$p.PublicKey}}{{$p.Email}}{{$p.IPsStr}}{{$p.Endpoint}}{{$p.LastHandshake}} + {{if eq $.Session.IsAdmin true}} + + {{end}} +
+
+
+
+ +
+
+

User details

+ {{if not $peerUser}} +

No user information available...

+ {{else}} +
    +
  • Firstname: {{$peerUser.Firstname}}
  • +
  • Lastname: {{$peerUser.Lastname}}
  • +
  • Phone: {{$peerUser.Phone}}
  • +
  • Mail: {{$peerUser.Email}}
  • +
+ {{end}} +

Connection / Traffic

+ {{if not $p.Peer}} +

No Traffic data available...

+ {{else}} +

{{if $p.DeactivatedAt}}-{{else}} {{$p.Peer.Endpoint}}{{end}}

+

{{if $p.DeactivatedAt}}-{{else}} {{formatBytes $p.Peer.ReceiveBytes}} / {{formatBytes $p.Peer.TransmitBytes}}{{end}}

+ {{end}} +
+ {{if eq $.Device.Type "server"}} +
+
{{$p.Config}}
+
+ {{end}} +
+ Delete +
+
+
+
+ {{if eq $.Device.Type "server"}} + + {{end}} +
+
+ {{if eq $.Device.Type "server"}} +
+ Download + Email +
+ {{end}} +
+
+
+
+

Currently listed peers: {{len $.PagedInterfacePeers}}

+
+
+ {{template "prt_footer.gohtml" .}} + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_index.html b/cmd/wg-portal/assets/tpl/admin_index.html deleted file mode 100644 index 4738c5b..0000000 --- a/cmd/wg-portal/assets/tpl/admin_index.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - {{ .Static.WebsiteTitle }} - Admin - - - - - - - -{{template "prt_nav.html" .}} -
- - {{template "prt_flashes.html" .}} -
-
-
-
- Interface status for {{.Device.DeviceName}} {{if eq $.Device.Type "server"}}(server mode){{end}}{{if eq $.Device.Type "client"}}(client mode){{end}} -
- -     - -     - -
-
-
-
- {{if eq $.Device.Type "server"}} -
- - - - - - - - - - - - - - - - - - - - - - - -
Public Key:{{.Device.PublicKey}}
Public Endpoint:{{.Device.DefaultEndpoint}}
Listening Port:{{.Device.ListenPort}}
Enabled Peers:{{len .Device.Interface.Peers}}
Total Peers:{{.TotalPeers}}
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
IP Address:{{.Device.IPsStr}}
Default allowed IP's:{{.Device.DefaultAllowedIPsStr}}
Default DNS servers:{{.Device.DNSStr}}
Default MTU:{{.Device.Mtu}}
Default Keepalive Interval:{{.Device.DefaultPersistentKeepalive}}
-
- {{end}} - {{if eq $.Device.Type "client"}} -
- - - - - - - - - - - - - - - -
Public Key:{{.Device.PublicKey}}
Enabled Endpoints:{{len .Device.Interface.Peers}}
Total Endpoints:{{.TotalPeers}}
-
-
- - - - - - - - - - - - - - - -
IP Address:{{.Device.IPsStr}}
DNS servers:{{.Device.DNSStr}}
Default MTU:{{.Device.Mtu}}
-
- {{end}} -
-
-
-
-
- -
-
- {{if eq $.Device.Type "server"}} -

Current VPN Peers

- {{end}} - {{if eq $.Device.Type "client"}} -

Current VPN Endpoints

- {{end}} -
-
- - {{if eq $.Device.Type "server"}} - - {{end}} - -
-
-
- - - - - - - {{if eq $.Device.Type "server"}} - - {{end}} - {{if eq $.Device.Type "server"}} - - {{end}} - {{if eq $.Device.Type "client"}} - - {{end}} - - - - - - {{range $i, $p :=.Peers}} - {{$peerUser:= $p.Email}} - - - - - {{if eq $.Device.Type "server"}} - - {{end}} - {{if eq $.Device.Type "server"}} - - {{end}} - {{if eq $.Device.Type "client"}} - - {{end}} - - - - - - - {{end}} - -
Identifier Public Key E-Mail IP's Endpoint Handshake
- - - - {{$p.Identifier}}{{$p.PublicKey}}{{$p.Email}}{{$p.IPsStr}}{{$p.Endpoint}}{{$p.LastHandshake}} - {{if eq $.Session.IsAdmin true}} - - {{end}} -
-
-
-
- -
-
-

User details

- {{if not $peerUser}} -

No user information available...

- {{else}} -
    -
  • Firstname: {{$peerUser.Firstname}}
  • -
  • Lastname: {{$peerUser.Lastname}}
  • -
  • Phone: {{$peerUser.Phone}}
  • -
  • Mail: {{$peerUser.Email}}
  • -
- {{end}} -

Connection / Traffic

- {{if not $p.Peer}} -

No Traffic data available...

- {{else}} -

{{if $p.DeactivatedAt}}-{{else}} {{$p.Peer.Endpoint}}{{end}}

-

{{if $p.DeactivatedAt}}-{{else}} {{formatBytes $p.Peer.ReceiveBytes}} / {{formatBytes $p.Peer.TransmitBytes}}{{end}}

- {{end}} -
- {{if eq $.Device.Type "server"}} -
-
{{$p.Config}}
-
- {{end}} -
- Delete -
-
-
-
- {{if eq $.Device.Type "server"}} - - {{end}} -
-
- {{if eq $.Device.Type "server"}} -
- Download - Email -
- {{end}} -
-
-
-
-

Currently listed peers: {{len .Peers}}

-
-
- {{template "prt_footer.html" .}} - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_user_edit.gohtml b/cmd/wg-portal/assets/tpl/admin_user_edit.gohtml new file mode 100644 index 0000000..5b34884 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_user_edit.gohtml @@ -0,0 +1,90 @@ + + + + + + {{ .Static.WebsiteTitle }} - Users + + + + + + + + {{template "prt_nav.gohtml" .}} +
+ {{if eq .User.CreatedAt .Epoch}} +

Create a new user

+ {{else}} +

Edit user {{.User.Email}}

+ {{end}} + + {{template "prt_flashes.gohtml" .}} + +
+ + {{if eq .User.CreatedAt .Epoch}} +
+
+ + +
+
+ {{else}} + + {{end}} +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+
+ + + Cancel +
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_user_edit.html b/cmd/wg-portal/assets/tpl/admin_user_edit.html deleted file mode 100644 index 9891f32..0000000 --- a/cmd/wg-portal/assets/tpl/admin_user_edit.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Users - - - - - - - - {{template "prt_nav.html" .}} -
- {{if eq .User.CreatedAt .Epoch}} -

Create a new user

- {{else}} -

Edit user {{.User.Email}}

- {{end}} - - {{template "prt_flashes.html" .}} - -
- - {{if eq .User.CreatedAt .Epoch}} -
-
- - -
-
- {{else}} - - {{end}} -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
- - -
-
-
- - - Cancel -
-
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_user_index.gohtml b/cmd/wg-portal/assets/tpl/admin_user_index.gohtml new file mode 100644 index 0000000..c0f2de9 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/admin_user_index.gohtml @@ -0,0 +1,72 @@ + + + + + + + {{ .Static.WebsiteTitle }} - Users + + + + + + + + {{template "prt_nav.gohtml" .}} +
+ + {{template "prt_flashes.gohtml" .}} +
+
+

All Users

+
+
+ M +
+
+
+ + + + + + + + + + + + + {{range $i, $u :=.Users}} + + + + + + + + + {{end}} + +
E-Mail Lastname Firstname Source Is Admin
{{$u.Email}}{{$u.Lastname}}{{$u.Firstname}}{{$u.Source}}{{if $u.IsAdmin}}True{{else}}False{{end}} + {{if eq $.Session.IsAdmin true}} + {{if eq $u.Source "db"}} + + {{end}} + {{end}} +
+

Currently listed users: {{len .Users}}

+
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/admin_user_index.html b/cmd/wg-portal/assets/tpl/admin_user_index.html deleted file mode 100644 index 87dd814..0000000 --- a/cmd/wg-portal/assets/tpl/admin_user_index.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Users - - - - - - - - {{template "prt_nav.html" .}} -
-

WireGuard VPN Users

- {{template "prt_flashes.html" .}} -
-
-

All Users

-
-
- M -
-
-
- - - - - - - - - - - - - {{range $i, $u :=.Users}} - - - - - - - - - {{end}} - -
E-Mail Lastname Firstname Source Is Admin
{{$u.Email}}{{$u.Lastname}}{{$u.Firstname}}{{$u.Source}}{{if $u.IsAdmin}}True{{else}}False{{end}} - {{if eq $.Session.IsAdmin true}} - {{if eq $u.Source "db"}} - - {{end}} - {{end}} -
-

Currently listed users: {{len .Users}}

-
-
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/email.gohtml b/cmd/wg-portal/assets/tpl/email.gohtml new file mode 100644 index 0000000..3bc2238 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/email.gohtml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + Email Template + + + + + + + + + + +
+ + + + +
+ + + + + + +
+ + + + +
+ + + + + + +
+ + + + +
+
+ + + {{if $.User}} + + {{else}} + + {{end}} + + + + +
Hello {{$.User.Firstname}} {{$.User.Lastname}}Hello
You or your administrator probably requested this VPN configuration. Scan the Qrcode or open the attached configuration file ({{$.Peer.GetConfigFileName}}) in the WireGuard VPN client to establish a secure VPN connection.
+
+
+
+ + + + + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + +
About WireGuard
WireGuard is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.
+ + + + +
Download WireGuard VPN Client
+
+
+
+
+ + + + + + + +
+ + + + + + + +
This mail was generated using WireGuard Portal.
Visit WireGuard Portal
+
+ +
+
+ + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/email.html b/cmd/wg-portal/assets/tpl/email.html deleted file mode 100644 index 3bc2238..0000000 --- a/cmd/wg-portal/assets/tpl/email.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - Email Template - - - - - - - - - - -
- - - - -
- - - - - - -
- - - - -
- - - - - - -
- - - - -
-
- - - {{if $.User}} - - {{else}} - - {{end}} - - - - -
Hello {{$.User.Firstname}} {{$.User.Lastname}}Hello
You or your administrator probably requested this VPN configuration. Scan the Qrcode or open the attached configuration file ({{$.Peer.GetConfigFileName}}) in the WireGuard VPN client to establish a secure VPN connection.
-
-
-
- - - - - - - -
- - - - -
- - - - -
- - - - - - - - - - - - -
About WireGuard
WireGuard is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.
- - - - -
Download WireGuard VPN Client
-
-
-
-
- - - - - - - -
- - - - - - - -
This mail was generated using WireGuard Portal.
Visit WireGuard Portal
-
- -
-
- - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/error.gohtml b/cmd/wg-portal/assets/tpl/error.gohtml new file mode 100644 index 0000000..1a12e1c --- /dev/null +++ b/cmd/wg-portal/assets/tpl/error.gohtml @@ -0,0 +1,33 @@ + + + + + + {{ .Static.WebsiteTitle }} - Error + + + + + + + + {{template "prt_nav.gohtml" .}} +
+
+
+

{{.Data.Code}}

+
+

{{.Data.Message}}

+

{{.Data.Details}}

← Back to Dashboard +
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/error.html b/cmd/wg-portal/assets/tpl/error.html deleted file mode 100644 index b2cda50..0000000 --- a/cmd/wg-portal/assets/tpl/error.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Error - - - - - - - - {{template "prt_nav.html" .}} -
-
-
-

{{.Data.Code}}

-
-

{{.Data.Message}}

-

{{.Data.Details}}

← Back to Dashboard -
-
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/index.gohtml b/cmd/wg-portal/assets/tpl/index.gohtml new file mode 100644 index 0000000..57c5f59 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/index.gohtml @@ -0,0 +1,85 @@ + + + + + + + {{ .Static.WebsiteTitle }} + + + + + + + + {{template "prt_nav.gohtml" .}} +
+ + {{template "prt_flashes.gohtml" .}} +

WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.

+

More Information

+
+
+
+
WireGuard Installation
+
+

Installation

+

Installation instructions for client software can be found on the official WireGuard website.

+ Open Instructions +
+
+
+
+
+
About WireGuard
+
+

About

+

WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography.

+ More details +
+
+
+
+
+
About WireGuard Portal
+
+

WireGuard Portal

+

WireGuard Portal is a simple, web based configuration portal for WireGuard.

+ More details +
+
+
+
+ +
+

VPN Profiles

+

You can access and download your personal VPN configurations via your Userprofile.

+
+

To find all your configured profiles click on the button below.

+

+ Open My Profile +

+
+ + {{with eq $.Session.LoggedIn true}}{{with eq $.Session.IsAdmin true}} +
+

Administration Area

+

In the administration area you can manage WireGuard peers and the server interface as well as users that are allowed to log in to the WireGuard Portal.

+
+

To find all your configured profiles click on the button below.

+

+ Open WireGuard Administration + Open User Administration +

+
+ {{end}}{{end}} + +
+ {{template "prt_footer.gohtml" .}} + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/index.html b/cmd/wg-portal/assets/tpl/index.html deleted file mode 100644 index 11601b6..0000000 --- a/cmd/wg-portal/assets/tpl/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - {{ .Static.WebsiteTitle }} - - - - - - - - {{template "prt_nav.html" .}} -
- - {{template "prt_flashes.html" .}} -

WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner, and more useful than IPsec, while avoiding the massive headache. It intends to be considerably more performant than OpenVPN.

-

More Information

-
-
-
-
WireGuard Installation
-
-

Installation

-

Installation instructions for client software can be found on the official WireGuard website.

- Open Instructions -
-
-
-
-
-
About WireGuard
-
-

About

-

WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography.

- More details -
-
-
-
-
-
About WireGuard Portal
-
-

WireGuard Portal

-

WireGuard Portal is a simple, web based configuration portal for WireGuard.

- More details -
-
-
-
- -
-

VPN Profiles

-

You can access and download your personal VPN configurations via your Userprofile.

-
-

To find all your configured profiles click on the button below.

-

- Open My Profile -

-
- - {{with eq $.Session.LoggedIn true}}{{with eq $.Session.IsAdmin true}} -
-

Administration Area

-

In the administration area you can manage WireGuard peers and the server interface as well as users that are allowed to log in to the WireGuard Portal.

-
-

To find all your configured profiles click on the button below.

-

- Open WireGuard Administration - Open User Administration -

-
- {{end}}{{end}} - -
- {{template "prt_footer.html" .}} - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/login.gohtml b/cmd/wg-portal/assets/tpl/login.gohtml new file mode 100644 index 0000000..14cb66b --- /dev/null +++ b/cmd/wg-portal/assets/tpl/login.gohtml @@ -0,0 +1,82 @@ + + + + + + + {{ .Static.WebsiteTitle }} - Login + + + + + + + + +
+
+
+
+
+
Please sign in
+
+
+
+ +
+ +
+ + +
+ +
+
+ +
+ + +
+
+ +
+
+ +
+
+ + {{range $idx, $prov := $.LoginProviders}} + {{with ne $idx 0}} +
+ {{end}} + {{$prov.Name}} + {{end}} +
+
+ +
+ {{template "prt_flashes.gohtml" .}} +
+
+
+ + +
+
+
+
+
+
+ {{template "prt_footer.gohtml" .}} + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/login.html b/cmd/wg-portal/assets/tpl/login.html deleted file mode 100644 index 3262831..0000000 --- a/cmd/wg-portal/assets/tpl/login.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - {{ .Static.WebsiteTitle }} - Login - - - - - - - - -
-
-
-
-
-
Please sign in
-
-
-
- -
- -
- - -
- -
-
- -
- - -
-
- -
-
- -
-
- - {{range $idx, $prov := $.LoginProviders}} - {{with ne $idx 0}} -
- {{end}} - {{$prov.Name}} - {{end}} -
-
- -
- {{template "prt_flashes.html" .}} -
-
-
- - -
-
-
-
-
-
- {{template "prt_footer.html" .}} - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_flashes.gohtml b/cmd/wg-portal/assets/tpl/prt_flashes.gohtml new file mode 100644 index 0000000..f21c787 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/prt_flashes.gohtml @@ -0,0 +1,5 @@ +{{range $flash := $.Alerts}} + +{{end}} \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_flashes.html b/cmd/wg-portal/assets/tpl/prt_flashes.html deleted file mode 100644 index f21c787..0000000 --- a/cmd/wg-portal/assets/tpl/prt_flashes.html +++ /dev/null @@ -1,5 +0,0 @@ -{{range $flash := $.Alerts}} - -{{end}} \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_footer.gohtml b/cmd/wg-portal/assets/tpl/prt_footer.gohtml new file mode 100644 index 0000000..3e4d7b9 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/prt_footer.gohtml @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_footer.html b/cmd/wg-portal/assets/tpl/prt_footer.html deleted file mode 100644 index 3e4d7b9..0000000 --- a/cmd/wg-portal/assets/tpl/prt_footer.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_nav.gohtml b/cmd/wg-portal/assets/tpl/prt_nav.gohtml new file mode 100644 index 0000000..2b10eec --- /dev/null +++ b/cmd/wg-portal/assets/tpl/prt_nav.gohtml @@ -0,0 +1,66 @@ + +{{if $.Interface}}{{if not (isConfigValid $.Interface)}} +
+
Warning: WireGuard Interface {{$.Interface.Identifier}} is not fully configured! Configurations may be incomplete and non functional!
+
+{{end}}{{end}} \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/prt_nav.html b/cmd/wg-portal/assets/tpl/prt_nav.html deleted file mode 100644 index 7f1c540..0000000 --- a/cmd/wg-portal/assets/tpl/prt_nav.html +++ /dev/null @@ -1,66 +0,0 @@ - -{{if $.Interface}}{{if not $.Interface.IsValid}} -
-
Warning: WireGuard Interface {{$.Interface.Identifier}} is not fully configured! Configurations may be incomplete and non functional!
-
-{{end}}{{end}} \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/user_index.gohtml b/cmd/wg-portal/assets/tpl/user_index.gohtml new file mode 100644 index 0000000..2fe6322 --- /dev/null +++ b/cmd/wg-portal/assets/tpl/user_index.gohtml @@ -0,0 +1,112 @@ + + + + + + {{ .Static.WebsiteTitle }} - Profile + + + + + + + + {{template "prt_nav.gohtml" .}} +
+

WireGuard VPN User-Portal

+ +

Your VPN Profiles

+
+ + + + + + + + + + + + + {{range $i, $p :=.Peers}} + {{$peerUser:=$p.Email}} + + + + + + + + + + + + {{end}} + +
Identifier Public Key E-Mail IP's Handshake
+ + + + {{$p.Identifier}}{{$p.PublicKey}}{{$p.Email}}{{$p.IPsStr}}{{$p.LastHandshake}}
+
+
+
+ +
+
+

User details

+ {{if not $peerUser}} +

No user information available...

+ {{else}} +
    +
  • Firstname: {{$peerUser.Firstname}}
  • +
  • Lastname: {{$peerUser.Lastname}}
  • +
  • Phone: {{$peerUser.Phone}}
  • +
  • Mail: {{$peerUser.Email}}
  • +
+ {{end}} +

Traffic

+ {{if not $p.Peer}} +

No Traffic data available...

+ {{else}} +

{{if $p.DeactivatedAt}}-{{else}} {{formatBytes $p.Peer.ReceiveBytes}} / {{formatBytes $p.Peer.TransmitBytes}}{{end}}

+ {{end}} +
+
+
{{$p.Config}}
+
+
+
+
+ +
+
+
+ Download + Email +
+
+
+
+
+

Currently listed peers: {{len .Peers}}

+
+
+ {{template "prt_footer.gohtml" .}} + + + + + + + + + \ No newline at end of file diff --git a/cmd/wg-portal/assets/tpl/user_index.html b/cmd/wg-portal/assets/tpl/user_index.html deleted file mode 100644 index b5bc2ab..0000000 --- a/cmd/wg-portal/assets/tpl/user_index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - {{ .Static.WebsiteTitle }} - Profile - - - - - - - - {{template "prt_nav.html" .}} -
-

WireGuard VPN User-Portal

- -

Your VPN Profiles

-
- - - - - - - - - - - - - {{range $i, $p :=.Peers}} - {{$peerUser:=$p.Email}} - - - - - - - - - - - - {{end}} - -
Identifier Public Key E-Mail IP's Handshake
- - - - {{$p.Identifier}}{{$p.PublicKey}}{{$p.Email}}{{$p.IPsStr}}{{$p.LastHandshake}}
-
-
-
- -
-
-

User details

- {{if not $peerUser}} -

No user information available...

- {{else}} -
    -
  • Firstname: {{$peerUser.Firstname}}
  • -
  • Lastname: {{$peerUser.Lastname}}
  • -
  • Phone: {{$peerUser.Phone}}
  • -
  • Mail: {{$peerUser.Email}}
  • -
- {{end}} -

Traffic

- {{if not $p.Peer}} -

No Traffic data available...

- {{else}} -

{{if $p.DeactivatedAt}}-{{else}} {{formatBytes $p.Peer.ReceiveBytes}} / {{formatBytes $p.Peer.TransmitBytes}}{{end}}

- {{end}} -
-
-
{{$p.Config}}
-
-
-
-
- -
-
-
- Download - Email -
-
-
-
-
-

Currently listed peers: {{len .Peers}}

-
-
- {{template "prt_footer.html" .}} - - - - - - - - - \ No newline at end of file diff --git a/cmd/wg-portal/server.go b/cmd/wg-portal/server.go index c3d176f..ea3e674 100644 --- a/cmd/wg-portal/server.go +++ b/cmd/wg-portal/server.go @@ -93,13 +93,15 @@ }) s.server.Use(sessions.Sessions("authsession", cookieStore)) s.server.SetFuncMap(template.FuncMap{ - "formatBytes": byteCountSI, - "urlEncode": url.QueryEscape, - "startsWith": strings.HasPrefix, + "formatBytes": byteCountSI, + "urlEncode": url.QueryEscape, + "startsWith": strings.HasPrefix, + "isConfigValid": isConfigValid, + "getSortIcon": getSortIcon, }) // Setup templates - templates, err := template.New("").Funcs(s.server.FuncMap).ParseFS(Templates, "assets/tpl/*.html") + templates, err := template.New("").Funcs(s.server.FuncMap).ParseFS(Templates, "assets/tpl/*.gohtml") if err != nil { return errors.WithMessage(err, "failed to parse templates") } @@ -176,3 +178,23 @@ return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "kMGTPE"[exp]) } + +func isConfigValid(cfg interface{}) bool { + switch v := cfg.(type) { + case persistence.InterfaceConfig: + return v.IsValid() + default: + return false + } +} + +func getSortIcon(s ui.SessionData, table, field string) string { + if s.SortedBy[table] != field { + return "fa-sort" + } + if s.SortDirection[table] == "asc" { + return "fa-sort-alpha-down" + } else { + return "fa-sort-alpha-up" + } +} diff --git a/cmd/wg-portal/ui/pages_admin.go b/cmd/wg-portal/ui/pages_admin.go index 303ebf9..2ede0a4 100644 --- a/cmd/wg-portal/ui/pages_admin.go +++ b/cmd/wg-portal/ui/pages_admin.go @@ -3,6 +3,8 @@ import ( "net/http" + "github.com/h44z/wg-portal/internal/persistence" + "github.com/gin-gonic/gin" ) @@ -10,13 +12,49 @@ return func(c *gin.Context) { currentSession := h.session.GetData(c) - c.HTML(http.StatusOK, "admin_index.html", gin.H{ - "Route": c.Request.URL.Path, - "Alerts": h.session.GetFlashes(c), - "Session": currentSession, - "Static": h.getStaticData(), - "Interface": nil, // TODO: load interface specified in the session - "InterfaceNames": map[string]string{"wgX": "wgX descr"}, + c.HTML(http.StatusOK, "admin_index.gohtml", gin.H{ + "Route": c.Request.URL.Path, + "Alerts": h.session.GetFlashes(c), + "Session": currentSession, + "Static": h.getStaticData(), + "Interface": persistence.InterfaceConfig{ + BaseModel: persistence.BaseModel{}, + Identifier: "wg0", + KeyPair: persistence.KeyPair{}, + ListenPort: 0, + AddressStr: "", + DnsStr: "", + DnsSearchStr: "", + Mtu: 0, + FirewallMark: 0, + RoutingTable: "", + PreUp: "", + PostUp: "", + PreDown: "", + PostDown: "", + SaveConfig: false, + Enabled: false, + DisplayName: "wgX descr", + Type: persistence.InterfaceTypeServer, + DriverType: "", + PeerDefNetworkStr: "", + PeerDefDnsStr: "", + PeerDefDnsSearchStr: "", + PeerDefEndpoint: "", + PeerDefAllowedIPsStr: "", + PeerDefMtu: 0, + PeerDefPersistentKeepalive: 0, + PeerDefFirewallMark: 0, + PeerDefRoutingTable: "", + PeerDefPreUp: "", + PeerDefPostUp: "", + PeerDefPreDown: "", + PeerDefPostDown: "", + }, + "InterfacePeers": []persistence.PeerConfig{}, + "PagedInterfacePeers": []persistence.PeerConfig{}, + "InterfaceNames": map[string]string{"wgX": "wgX descr"}, + "TotalPeers": 12, }) } } diff --git a/cmd/wg-portal/ui/pages_admin_user.go b/cmd/wg-portal/ui/pages_admin_user.go index 7e3560c..7b5e2a5 100644 --- a/cmd/wg-portal/ui/pages_admin_user.go +++ b/cmd/wg-portal/ui/pages_admin_user.go @@ -10,7 +10,7 @@ return func(c *gin.Context) { currentSession := h.session.GetData(c) - c.HTML(http.StatusOK, "admin_user_index.html", gin.H{ + c.HTML(http.StatusOK, "admin_user_index.gohtml", gin.H{ "Route": c.Request.URL.Path, "Alerts": h.session.GetFlashes(c), "Session": currentSession, diff --git a/cmd/wg-portal/ui/pages_core.go b/cmd/wg-portal/ui/pages_core.go index 66bdc1b..4733c90 100644 --- a/cmd/wg-portal/ui/pages_core.go +++ b/cmd/wg-portal/ui/pages_core.go @@ -33,7 +33,7 @@ return func(c *gin.Context) { currentSession := h.session.GetData(c) - c.HTML(http.StatusOK, "index.html", gin.H{ + c.HTML(http.StatusOK, "index.gohtml", gin.H{ "Route": c.Request.URL.Path, "Alerts": h.session.GetFlashes(c), "Session": currentSession, @@ -94,7 +94,7 @@ }) } - c.HTML(http.StatusOK, "login.html", gin.H{ + c.HTML(http.StatusOK, "login.gohtml", gin.H{ "Alerts": h.session.GetFlashes(c), "Static": h.getStaticData(), "Csrf": csrf.GetToken(c), diff --git a/cmd/wg-portal/ui/session.go b/cmd/wg-portal/ui/session.go index a157621..a2be92c 100644 --- a/cmd/wg-portal/ui/session.go +++ b/cmd/wg-portal/ui/session.go @@ -30,10 +30,11 @@ // currently selected interface InterfaceIdentifier persistence.InterfaceIdentifier - // current table sorting + // table sorting and paging SortedBy map[string]string SortDirection map[string]string Search map[string]string + CurrentPage map[string]int // alert that is printed on top of the page AlertData string diff --git a/internal/persistence/models.go b/internal/persistence/models.go index c892b3f..e645295 100644 --- a/internal/persistence/models.go +++ b/internal/persistence/models.go @@ -82,6 +82,10 @@ PeerDefPostDown string // default action that is executed after the device is down } +func (i *InterfaceConfig) IsValid() bool { + return true // TODO: implement check +} + type PeerInterfaceConfig struct { Identifier InterfaceIdentifier `gorm:"index;column:iface_identifier"` // the interface identifier Type InterfaceType `gorm:"column:iface_type"` // the interface type