From 20b71b4e1fcd8a67d792bb030e74dd23c6330c84 Mon Sep 17 00:00:00 2001 From: Philipp Harms Date: Wed, 22 Feb 2023 03:43:13 +0100 Subject: [PATCH] Add Interface column in user profile and fix sorting --- assets/tpl/user_index.html | 2 ++ internal/server/handlers_common.go | 4 ++-- internal/wireguard/peermanager.go | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/tpl/user_index.html b/assets/tpl/user_index.html index 4da4fae..1968aba 100644 --- a/assets/tpl/user_index.html +++ b/assets/tpl/user_index.html @@ -34,6 +34,7 @@ Public Key E-Mail IP's + Interface Handshake {{if eq $.UserManagePeers true}} @@ -53,6 +54,7 @@ {{$p.PublicKey}} {{$p.Email}} {{$p.IPsStr}} + {{$p.DeviceName}} {{$p.LastHandshake}} {{if eq $.UserManagePeers true}} diff --git a/internal/server/handlers_common.go b/internal/server/handlers_common.go index 8ccb8a7..c315dcf 100644 --- a/internal/server/handlers_common.go +++ b/internal/server/handlers_common.go @@ -128,8 +128,8 @@ func (s *Server) GetUserIndex(c *gin.Context) { s.GetHandleError(c, http.StatusInternalServerError, "sort error", "failed to save session") return } - c.Redirect(http.StatusSeeOther, "/admin") - return + /*c.Redirect(http.StatusSeeOther, "/admin") + return*/ } peers := s.peers.GetSortedPeersForEmail(currentSession.SortedBy["userpeers"], currentSession.SortDirection["userpeers"], currentSession.Email) diff --git a/internal/wireguard/peermanager.go b/internal/wireguard/peermanager.go index badf317..d406344 100644 --- a/internal/wireguard/peermanager.go +++ b/internal/wireguard/peermanager.go @@ -731,6 +731,9 @@ func sortPeers(sortKey string, sortDirection string, peers []Peer) { case "endpoint": sortValueLeft = peers[i].Endpoint sortValueRight = peers[j].Endpoint + case "device": + sortValueLeft = peers[i].DeviceName + sortValueRight = peers[j].DeviceName case "handshake": if peers[i].Peer == nil { return true