From cc285c5c204cf3ff70f19f529d38ba8f2f315360 Mon Sep 17 00:00:00 2001 From: Arminas Date: Thu, 16 Feb 2023 18:10:11 +0200 Subject: [PATCH] Status show IP's (#291) --- handler/routes.go | 11 +++++++++++ templates/status.html | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/handler/routes.go b/handler/routes.go index 18a7d17..cc66a66 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -617,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 { @@ -664,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. diff --git a/templates/status.html b/templates/status.html index b161646..a9b770b 100644 --- a/templates/status.html +++ b/templates/status.html @@ -41,6 +41,8 @@ Connected Peers # Name Email + Allocated IPs + Endpoint Public Key Received Transmitted @@ -54,6 +56,8 @@ Connected Peers {{ $idx }} {{ $peer.Name }} {{ $peer.Email }} + {{ $peer.AllocatedIP }} + {{ $peer.Endpoint }} {{ $peer.PublicKey }} @@ -68,4 +72,4 @@ Connected Peers {{end}} {{define "bottom_js"}} -{{end}} \ No newline at end of file +{{end}}