mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
Update routes.go
This commit is contained in:
parent
5259b98cdf
commit
25e893b613
1 changed files with 11 additions and 0 deletions
|
@ -607,6 +607,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 +656,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 += "</br>"
|
||||
}
|
||||
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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue