added fwmark

This commit is contained in:
afeiszli
2021-11-12 08:53:50 -05:00
parent 97acdc5e8b
commit c2948a3671
9 changed files with 62 additions and 47 deletions

View File

@@ -6,7 +6,9 @@ import (
"errors"
"fmt"
"log"
"math/rand"
"os/exec"
"time"
nodepb "github.com/gravitl/netmaker/grpc"
"github.com/gravitl/netmaker/models"
@@ -34,6 +36,13 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
err := errors.New("ALREADY_INSTALLED. Netclient appears to already be installed for " + cfg.Network + ". To re-install, please remove by executing 'sudo netclient leave -n " + cfg.Network + "'. Then re-run the install command.")
return err
}
if cfg.FWMark == 0 {
rand.Seed(time.Now().UnixNano())
var min int32 = 1000
var max int32 = 9999
cfg.FWMark = rand.Int31n(max-min) + min
}
err = config.Write(&cfg, cfg.Network)
if err != nil {
return err