Feat: specify Openvpn flags with OPENVPN_FLAGS
This commit is contained in:
@@ -18,7 +18,7 @@ const (
|
||||
binOpenvpn25 = "openvpn"
|
||||
)
|
||||
|
||||
func (c *configurator) Start(ctx context.Context, version string) (
|
||||
func (c *configurator) Start(ctx context.Context, version string, flags []string) (
|
||||
stdoutLines, stderrLines chan string, waitError chan error, err error) {
|
||||
var bin string
|
||||
switch version {
|
||||
@@ -32,7 +32,9 @@ func (c *configurator) Start(ctx context.Context, version string) (
|
||||
|
||||
c.logger.Info("starting OpenVPN " + version)
|
||||
|
||||
cmd := exec.CommandContext(ctx, bin, "--config", constants.OpenVPNConf)
|
||||
args := []string{"--config", constants.OpenVPNConf}
|
||||
args = append(args, flags...)
|
||||
cmd := exec.CommandContext(ctx, bin, args...)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
||||
return c.commander.Start(cmd)
|
||||
|
||||
@@ -169,7 +169,8 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
||||
|
||||
openvpnCtx, openvpnCancel := context.WithCancel(context.Background())
|
||||
|
||||
stdoutLines, stderrLines, waitError, err := l.conf.Start(openvpnCtx, settings.Version)
|
||||
stdoutLines, stderrLines, waitError, err := l.conf.Start(
|
||||
openvpnCtx, settings.Version, settings.Flags)
|
||||
if err != nil {
|
||||
openvpnCancel()
|
||||
l.signalOrSetStatus(constants.Crashed)
|
||||
|
||||
@@ -17,7 +17,7 @@ type Configurator interface {
|
||||
WriteAuthFile(user, password string, puid, pgid int) error
|
||||
CheckTUN() error
|
||||
CreateTUN() error
|
||||
Start(ctx context.Context, version string) (
|
||||
Start(ctx context.Context, version string, flags []string) (
|
||||
stdoutLines, stderrLines chan string, waitError chan error, err error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user