feat(vpn): VPN_UP_COMMAND and VPN_DOWN_COMMAND options

This commit is contained in:
Quentin McGaw
2026-03-08 16:06:16 +00:00
parent c0af198155
commit 57c53bc19e
14 changed files with 152 additions and 68 deletions
+10
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/netip"
"strings"
"time"
"github.com/qdm12/gluetun/internal/constants"
@@ -16,6 +17,7 @@ import (
)
type tunnelUpData struct {
upCommand string
// Healthcheck
serverIP netip.Addr
pmtud tunnelUpPMTUDData
@@ -107,6 +109,14 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
}
}
if data.upCommand != "" {
commandString := strings.ReplaceAll(data.upCommand, "{{VPN_INTERFACE}}", data.vpnIntf)
err := l.cmder.RunAndLog(context.Background(), commandString, l.logger)
if err != nil {
l.logger.Error("failed to run VPN up command: " + err.Error())
}
}
err = l.startPortForwarding(data)
if err != nil {
l.logger.Error(err.Error())