mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-12 23:32:15 +02:00
feat(vpn): VPN_UP_COMMAND and VPN_DOWN_COMMAND options
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user