This commit is contained in:
Callan Bryant 2020-03-01 23:08:10 +00:00
parent 87317e374a
commit a99449e960
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA
4 changed files with 49 additions and 53 deletions

View File

@ -30,7 +30,7 @@ func main() {
case "down":
default:
help();
help()
}
}

View File

@ -7,13 +7,11 @@ const (
// these end up in the config file
DEFAULT_INTERFACE_NAME = "dsnet"
DEFAULT_REPORT_FILE = "/var/lib/dsnet-report.json"
DEFAULT_LISTEN_PORT = 51820;
DEFAULT_LISTEN_PORT = 51820
// keepalive always configured for everything
KEEPALIVE_SECONDS = 21;
KEEPALIVE_SECONDS = 21
// when is a peer considered gone forever? (could remove)
EXPIRY_DAYS = 28;
EXPIRY_DAYS = 28
)

10
init.go
View File

@ -1,12 +1,11 @@
package dsnet
import (
"net"
"math/rand"
"fmt"
"time"
"encoding/json"
"fmt"
"math/rand"
"net"
"time"
//"github.com/mikioh/ipaddr"
)
@ -32,7 +31,6 @@ func Init() {
}
// get a random /22 subnet on 10.0.0.0 (1023 hosts) (or /24?)
// TODO also the 20 bit block and 16 bit block?
func getRandomNetwork() JSONIPNet {
rbs := make([]byte, 2)
rand.Seed(time.Now().UTC().UnixNano())

View File

@ -1,9 +1,9 @@
package dsnet
import (
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"net"
"time"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
// see https://github.com/WireGuard/wgctrl-go/blob/master/wgtypes/types.go for definitions
@ -87,7 +87,7 @@ func (k JSONKey) MarshalJSON() ([]byte, error) {
func GenerateJSONPrivateKey() JSONKey {
privateKey, err := wgtypes.GeneratePrivateKey()
if (err != nil) {
if err != nil {
panic(err)
}
@ -99,7 +99,7 @@ func GenerateJSONPrivateKey() JSONKey {
func GenerateJSONKey() JSONKey {
privateKey, err := wgtypes.GenerateKey()
if (err != nil) {
if err != nil {
panic(err)
}