start creation of dsnet config
This commit is contained in:
parent
fac130eea1
commit
d7b0d77cf2
2
const.go
2
const.go
@ -7,6 +7,7 @@ const (
|
|||||||
// these end up in the config file
|
// these end up in the config file
|
||||||
DEFAULT_INTERFACE_NAME = "dsnet"
|
DEFAULT_INTERFACE_NAME = "dsnet"
|
||||||
DEFAULT_REPORT_FILE = "/var/lib/dsnet-report.json"
|
DEFAULT_REPORT_FILE = "/var/lib/dsnet-report.json"
|
||||||
|
DEFAULT_LISTEN_PORT = 51820;
|
||||||
|
|
||||||
// keepalive always configured for everything
|
// keepalive always configured for everything
|
||||||
KEEPALIVE_SECONDS = 21;
|
KEEPALIVE_SECONDS = 21;
|
||||||
@ -14,6 +15,5 @@ const (
|
|||||||
// when is a peer considered gone forever? (could remove)
|
// when is a peer considered gone forever? (could remove)
|
||||||
EXPIRY_DAYS = 28;
|
EXPIRY_DAYS = 28;
|
||||||
|
|
||||||
LISTEN_PORT = 51820;
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
21
init.go
21
init.go
@ -1,10 +1,27 @@
|
|||||||
package dsnet
|
package dsnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
|
//"github.com/mikioh/ipaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
//conf := DsnetConfig {
|
conf := DsnetConfig {
|
||||||
//}
|
PrivateKey = wgtypes.GeneratePrivateKey(),
|
||||||
|
PresharedKey = wgtypes.GenerateKey(),
|
||||||
|
ListenPort = DEFAULT_LISTEN_PORT,
|
||||||
|
Network = getRandomNetwork(),
|
||||||
|
Domain = "dsnet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get a random /22 (1023 hosts) (or /24?)
|
||||||
|
// TODO implement
|
||||||
|
func getRandomNetwork() net.IPNet {
|
||||||
|
return net.IPNet {
|
||||||
|
IP{10,129,123,0},
|
||||||
|
Mask{255,255,255,240},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
types.go
6
types.go
@ -44,14 +44,12 @@ type Peer struct {
|
|||||||
|
|
||||||
type DsnetConfig struct {
|
type DsnetConfig struct {
|
||||||
PrivateKey *wgtypes.Key `validate:"required,len=44"`
|
PrivateKey *wgtypes.Key `validate:"required,len=44"`
|
||||||
|
PresharedKey wgtypes.Key `validate:"required,len=44"`
|
||||||
ListenPort *int `validate:"gte=1024,lte=65535"`
|
ListenPort *int `validate:"gte=1024,lte=65535"`
|
||||||
FirewallMark *int
|
|
||||||
Peers []PeerConfig
|
Peers []PeerConfig
|
||||||
// IP network from which to allocate automatic sequential addresses
|
// IP network from which to allocate automatic sequential addresses
|
||||||
//Network net.IPNet
|
|
||||||
// TODO: use ParseCIDR to parse config
|
|
||||||
// Network is chosen randomly when not specified
|
// Network is chosen randomly when not specified
|
||||||
Network string `validate:"required,cidr"`
|
Network net.IPNet `validate:"required"`
|
||||||
// domain to append to hostnames. Relies on separate DNS server for
|
// domain to append to hostnames. Relies on separate DNS server for
|
||||||
// resolution. Informational only.
|
// resolution. Informational only.
|
||||||
Domain string `validate:"required,gte=1,lte=255"`
|
Domain string `validate:"required,gte=1,lte=255"`
|
||||||
|
Loading…
Reference in New Issue
Block a user