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, Owner: owner,
Hostname: hostname, Hostname: hostname,
Description: description, Description: description,
Added: time.Now(),
PublicKey: publicKey, PublicKey: publicKey,
PrivateKey: privateKey, // omitted from server config JSON! PrivateKey: privateKey, // omitted from server config JSON!
PresharedKey: GenerateJSONKey(), PresharedKey: GenerateJSONKey(),

View File

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

View File

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