Selaa lähdekoodia

:gear: Allow to disable interface bootstrap

This allows to run in unprivileged mode, thanks to @kondratev for the
fixup.

Fixes #16
Ettore Di Giacinto 3 vuotta sitten
vanhempi
commit
1ee9523dd5
3 muutettua tiedostoa jossa 10 lisäystä ja 3 poistoa
  1. 6 0
      cmd/util.go
  2. 2 2
      pkg/config/config.go
  3. 2 1
      pkg/vpn/interface.go

+ 6 - 0
cmd/util.go

@@ -48,6 +48,11 @@ var CommonFlags []cli.Flag = []cli.Flag{
 		EnvVar: "EDGEVPNMTU",
 		Value:  1200,
 	},
+	&cli.BoolTFlag{
+		Name:   "bootstrap-iface",
+		Usage:  "Setup interface on startup (need privileges)",
+		EnvVar: "EDGEVPNBOOTSTRAPIFACE",
+	},
 	&cli.IntFlag{
 		Name:   "packet-mtu",
 		Usage:  "Specify a mtu",
@@ -327,6 +332,7 @@ func cliToOpts(c *cli.Context) ([]node.Option, []vpn.Option, *logger.Logger) {
 		ChannelBufferSize: c.Int("channel-buffer-size"),
 		InterfaceMTU:      c.Int("mtu"),
 		PacketMTU:         c.Int("packet-mtu"),
+		BootstrapIface:    c.Bool("bootstrap-iface"),
 		Ledger: config.Ledger{
 			StateDir:         c.String("ledger-state"),
 			AnnounceInterval: time.Duration(c.Int("ledger-announce-interval")) * time.Second,

+ 2 - 2
pkg/config/config.go

@@ -46,7 +46,7 @@ type Config struct {
 	Router                                     string
 	Interface                                  string
 	Libp2pLogLevel, LogLevel                   string
-	LowProfile, VPNLowProfile                  bool
+	LowProfile, VPNLowProfile, BootstrapIface  bool
 	Blacklist                                  []string
 	Concurrency                                int
 	FrameTimeout                               string
@@ -178,7 +178,7 @@ func (c Config) ToOpts(l *logger.Logger) ([]node.Option, []vpn.Option, error) {
 		vpn.Logger(llger),
 		vpn.WithTimeout(c.FrameTimeout),
 		vpn.WithInterfaceType(water.TUN),
-		vpn.NetLinkBootstrap(true),
+		vpn.NetLinkBootstrap(c.BootstrapIface),
 		vpn.WithChannelBufferSize(c.ChannelBufferSize),
 		vpn.WithInterfaceMTU(c.InterfaceMTU),
 		vpn.WithPacketMTU(c.PacketMTU),

+ 2 - 1
pkg/vpn/interface.go

@@ -25,7 +25,8 @@ import (
 
 func createInterface(c *Config) (*water.Interface, error) {
 	config := water.Config{
-		DeviceType: c.DeviceType,
+		DeviceType:             c.DeviceType,
+		PlatformSpecificParams: water.PlatformSpecificParams{Persist: !c.NetLinkBootstrap},
 	}
 	config.Name = c.InterfaceName