mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-15 07:11:15 +00:00
Mikrotik integration (#467)
Allow MikroTik routes as WireGuard backends
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type PeerStatus struct {
|
||||
PeerId PeerIdentifier `gorm:"primaryKey;column:identifier" json:"PeerId"`
|
||||
@@ -37,3 +39,25 @@ type InterfaceStatus struct {
|
||||
BytesReceived uint64 `gorm:"column:received"`
|
||||
BytesTransmitted uint64 `gorm:"column:transmitted"`
|
||||
}
|
||||
|
||||
type PingerResult struct {
|
||||
PacketsRecv int
|
||||
PacketsSent int
|
||||
Rtts []time.Duration
|
||||
}
|
||||
|
||||
func (r PingerResult) IsPingable() bool {
|
||||
return r.PacketsRecv > 0 && r.PacketsSent > 0 && len(r.Rtts) > 0
|
||||
}
|
||||
|
||||
func (r PingerResult) AverageRtt() time.Duration {
|
||||
if len(r.Rtts) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var total time.Duration
|
||||
for _, rtt := range r.Rtts {
|
||||
total += rtt
|
||||
}
|
||||
return total / time.Duration(len(r.Rtts))
|
||||
}
|
||||
|
Reference in New Issue
Block a user