dsnet/types.go

64 lines
1.3 KiB
Go
Raw Normal View History

2020-02-10 20:58:13 +01:00
package dsnet
import (
"net"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
2020-02-20 20:08:07 +01:00
// keepalive for everything
const KeepaliveSeconds = 21;
const ExpiryDays = 28;
const DefaultListenPort = 51820;
2020-02-10 20:58:13 +01:00
// see https://github.com/WireGuard/wgctrl-go/blob/master/wgtypes/types.go for definitions
2020-02-20 20:08:07 +01:00
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
}
2020-02-10 20:58:13 +01:00
type Peer struct {
2020-02-20 20:08:07 +01:00
// username of person running this host/router
Owner string
// Used to update DNS
Hostname string
// Description of what the host is and/or does
2020-02-10 20:58:13 +01:00
Description string
2020-02-20 20:08:07 +01:00
// whether last heartbeat/rxdata was received (50% margin)
Online bool
// if no data for x days, consider revoking access
Expired bool
2020-02-10 20:58:13 +01:00
PublicKey wgtypes.Key
PresharedKey wgtypes.Key
Endpoint *net.UDPAddr
LastHandshakeTime time.Time
ReceiveBytes int64
TransmitBytes int64
AllowedIPs []net.IPNet
}
2020-02-20 20:08:07 +01:00
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
}