From dd5ab037716813bf62ca5a795a379b49590f9f2b Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Sun, 15 Mar 2020 16:54:48 +0000 Subject: [PATCH] add external IP to peers --- reporttypes.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reporttypes.go b/reporttypes.go index 3e8a912..c0f44ac 100644 --- a/reporttypes.go +++ b/reporttypes.go @@ -98,11 +98,17 @@ func GenerateReport(dev *wgtypes.Device, conf *DsnetConfig, oldReport *DsnetRepo status = StatusOffline } + externalIP := net.IP{} + if wgPeer.Endpoint != nil { + externalIP = wgPeer.Endpoint.IP + } + peerReports[i] = PeerReport{ Hostname: peer.Hostname, Owner: peer.Owner, Description: peer.Description, IP: peer.IP, + ExternalIP: externalIP, Status: status, Networks: peer.Networks, LastHandshakeTime: wgPeer.LastHandshakeTime, @@ -162,8 +168,10 @@ type PeerReport struct { // Description of what the host is and/or does Description string // Internal VPN IP address. Added to AllowedIPs in server config as a /32 - IP net.IP - Status Status + IP net.IP + // Last known external IP + ExternalIP net.IP + Status Status // TODO ExternalIP support (Endpoint) //ExternalIP net.UDPAddr `validate:"required,udp4_addr"` // TODO support routing additional networks (AllowedIPs)