separate config types from report types

This commit is contained in:
Callan Bryant 2020-03-03 22:08:52 +00:00
parent 125f3c4e26
commit 5cc866fe77
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA
2 changed files with 38 additions and 33 deletions

View File

@ -4,9 +4,6 @@ import (
"encoding/json"
"io/ioutil"
"net"
"time"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
// see https://github.com/WireGuard/wgctrl-go/blob/master/wgtypes/types.go for definitions
@ -26,28 +23,6 @@ type PeerConfig struct {
AllowedIPs []JSONIPNet `validate:"dive,required,cidr"`
}
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
// TODO peer endpoint support
//Endpoint *net.UDPAddr
LastHandshakeTime time.Time
ReceiveBytes int64
TransmitBytes int64
AllowedIPs []net.IPNet
}
type DsnetConfig struct {
// domain to append to hostnames. Relies on separate DNS server for
// resolution. Informational only.
@ -142,11 +117,3 @@ func (conf DsnetConfig) MustAllocateIP() net.IP {
return net.IP{}
}
type Dsnet struct {
Name string
PrivateKey wgtypes.Key
PublicKey wgtypes.Key
ListenPort int
Peers []Peer
}

38
reporttypes.go Normal file
View File

@ -0,0 +1,38 @@
package dsnet
import (
"net"
"time"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
type DsnetReport struct {
Name string
PrivateKey wgtypes.Key
PublicKey wgtypes.Key
ListenPort int
Peers []Peer
}
type PeerReport 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
// TODO peer endpoint support
//Endpoint *net.UDPAddr
LastHandshakeTime time.Time
ReceiveBytes int64
TransmitBytes int64
AllowedIPs []net.IPNet
}