Browse Source

Allow to configure NetLinkBootstrap

Ettore Di Giacinto 4 years ago
parent
commit
cf558a80a7
3 changed files with 12 additions and 2 deletions
  1. 1 0
      main.go
  2. 4 2
      pkg/edgevpn/edgevpn.go
  3. 7 0
      pkg/edgevpn/options.go

+ 1 - 0
main.go

@@ -46,6 +46,7 @@ func main() {
 		edgevpn.WithInterfaceAddress(os.Getenv("ADDRESS")),
 		edgevpn.WithInterfaceName(os.Getenv("IFACE")),
 		edgevpn.WithInterfaceType(water.TAP),
+		edgevpn.NetLinkBootstrap(true),
 	}
 
 	opts = append(opts, edgevpn.FromYaml(os.Getenv("EDGEVPNCONFIG")))

+ 4 - 2
pkg/edgevpn/edgevpn.go

@@ -58,8 +58,10 @@ func (e *EdgeVPN) Start() error {
 
 func (e *EdgeVPN) writePackets(ifce *water.Interface) error {
 
-	if err := e.prepareInterface(); err != nil {
-		return err
+	if e.config.NetLinkBootstrap {
+		if err := e.prepareInterface(); err != nil {
+			return err
+		}
 	}
 
 	mw, err := e.MessageWriter()

+ 7 - 0
pkg/edgevpn/options.go

@@ -91,6 +91,13 @@ func ListenAddresses(s string) func(cfg *Config) error {
 	}
 }
 
+func NetLinkBootstrap(b bool) func(cfg *Config) error {
+	return func(cfg *Config) error {
+		cfg.NetLinkBootstrap = b
+		return nil
+	}
+}
+
 func Insecure(b bool) func(cfg *Config) error {
 	return func(cfg *Config) error {
 		cfg.Insecure = b