record added time

This commit is contained in:
Callan Bryant 2020-03-19 20:12:42 +00:00
parent 3277362e6e
commit 1e046a20a1
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA
3 changed files with 6 additions and 0 deletions

1
add.go
View File

@ -36,6 +36,7 @@ func Add() {
Owner: owner,
Hostname: hostname,
Description: description,
Added: time.Now(),
PublicKey: publicKey,
PrivateKey: privateKey, // omitted from server config JSON!
PresharedKey: GenerateJSONKey(),

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
"net"
"os"
"time"
"github.com/go-playground/validator/v10"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
@ -20,6 +21,7 @@ type PeerConfig struct {
Description string `validate:"required,gte=1,lte=255"`
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
IP net.IP `validate:"required`
Added time.Time `validate:"required"`
// TODO ExternalIP support (Endpoint)
//ExternalIP net.UDPAddr `validate:"required,udp4_addr"`
// TODO support routing additional networks (AllowedIPs)

View File

@ -107,6 +107,7 @@ func GenerateReport(dev *wgtypes.Device, conf *DsnetConfig, oldReport *DsnetRepo
Hostname: peer.Hostname,
Owner: peer.Owner,
Description: peer.Description,
Added: peer.Added,
IP: peer.IP,
ExternalIP: externalIP,
Status: status,
@ -167,6 +168,8 @@ type PeerReport struct {
Owner string
// Description of what the host is and/or does
Description string
// date peer was added to dsnet config
Added time.Time
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
IP net.IP
// Last known external IP