From da7ea0796a97fe7b8ae14ea85e2bf89c970e2da8 Mon Sep 17 00:00:00 2001 From: Callan Bryant Date: Thu, 20 Feb 2020 19:08:07 +0000 Subject: [PATCH] initial config/actual types --- types.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/types.go b/types.go index 5d32526..17df3dc 100644 --- a/types.go +++ b/types.go @@ -5,10 +5,38 @@ import ( "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) +// keepalive for everything +const KeepaliveSeconds = 21; +const ExpiryDays = 28; +const DefaultListenPort = 51820; + // see https://github.com/WireGuard/wgctrl-go/blob/master/wgtypes/types.go for definitions -type Peer struct { - Name string +type PeerConfig struct { + // username of person running this host/router + Owner string + // Used to update DNS + Hostname string + // Description of what the host is and/or does Description string + + PublicKey wgtypes.Key + PresharedKey wgtypes.Key + Endpoint *net.UDPAddr + AllowedIPs []net.IPNet +} + +type Peer struct { + // username of person running this host/router + Owner string + // Used to update DNS + Hostname string + // Description of what the host is and/or does + Description string + // whether last heartbeat/rxdata was received (50% margin) + Online bool + // if no data for x days, consider revoking access + Expired bool + PublicKey wgtypes.Key PresharedKey wgtypes.Key Endpoint *net.UDPAddr @@ -17,3 +45,19 @@ type Peer struct { TransmitBytes int64 AllowedIPs []net.IPNet } + +type DsnetConfig struct { + PrivateKey *wgtypes.Key + ListenPort *int + FirewallMark *int + Peers []PeerConfig +} + +type Dsnet struct { + Name string + Type DeviceType + PrivateKey Key + PublicKey Key + ListenPort int + Peers []Peer +}