Compare commits
3 Commits
dependabot
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2afa988174 | ||
|
|
a35c994bc8 | ||
|
|
0fad44fb68 |
2
go.mod
2
go.mod
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/klauspost/compress v1.18.1
|
github.com/klauspost/compress v1.18.1
|
||||||
github.com/klauspost/pgzip v1.2.6
|
github.com/klauspost/pgzip v1.2.6
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4
|
github.com/pelletier/go-toml/v2 v2.2.4
|
||||||
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251114155417-248acd28339f
|
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251123213823-54e987293e88
|
||||||
github.com/qdm12/gosettings v0.4.4
|
github.com/qdm12/gosettings v0.4.4
|
||||||
github.com/qdm12/goshutdown v0.3.0
|
github.com/qdm12/goshutdown v0.3.0
|
||||||
github.com/qdm12/gosplash v0.2.0
|
github.com/qdm12/gosplash v0.2.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -69,8 +69,8 @@ github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPA
|
|||||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251114155417-248acd28339f h1:6wN5D9wACfmXDsQ366egVt0jXY4nqL/QnIwg4nWhXco=
|
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251123213823-54e987293e88 h1:GJ5FALvJ3UmHjVaNYebrfV5zF5You4dq8HfRWZy2loM=
|
||||||
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251114155417-248acd28339f/go.mod h1:98foWgXJZ+g8gJIuO+fdO+oWpFei5WShMFTeN4Im2lE=
|
github.com/qdm12/dns/v2 v2.0.0-rc9.0.20251123213823-54e987293e88/go.mod h1:98foWgXJZ+g8gJIuO+fdO+oWpFei5WShMFTeN4Im2lE=
|
||||||
github.com/qdm12/goservices v0.1.1-0.20251104135713-6bee97bd4978 h1:TRGpCU1l0lNwtogEUSs5U+RFceYxkAJUmrGabno7J5c=
|
github.com/qdm12/goservices v0.1.1-0.20251104135713-6bee97bd4978 h1:TRGpCU1l0lNwtogEUSs5U+RFceYxkAJUmrGabno7J5c=
|
||||||
github.com/qdm12/goservices v0.1.1-0.20251104135713-6bee97bd4978/go.mod h1:D1Po4CRQLYjccnAR2JsVlN1sBMgQrcNLONbvyuzcdTg=
|
github.com/qdm12/goservices v0.1.1-0.20251104135713-6bee97bd4978/go.mod h1:D1Po4CRQLYjccnAR2JsVlN1sBMgQrcNLONbvyuzcdTg=
|
||||||
github.com/qdm12/gosettings v0.4.4 h1:SM6tOZDf6k8qbjWU8KWyBF4mWIixfsKCfh9DGRLHlj4=
|
github.com/qdm12/gosettings v0.4.4 h1:SM6tOZDf6k8qbjWU8KWyBF4mWIixfsKCfh9DGRLHlj4=
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func runCommand(ctx context.Context, cmder Cmder, logger Logger,
|
func runCommand(ctx context.Context, cmder Cmder, logger Logger,
|
||||||
commandTemplate string, ports []uint16,
|
commandTemplate string, ports []uint16, vpnInterface string,
|
||||||
) (err error) {
|
) (err error) {
|
||||||
portStrings := make([]string, len(ports))
|
portStrings := make([]string, len(ports))
|
||||||
for i, port := range ports {
|
for i, port := range ports {
|
||||||
@@ -19,6 +19,7 @@ func runCommand(ctx context.Context, cmder Cmder, logger Logger,
|
|||||||
portsString := strings.Join(portStrings, ",")
|
portsString := strings.Join(portStrings, ",")
|
||||||
commandString := strings.ReplaceAll(commandTemplate, "{{PORTS}}", portsString)
|
commandString := strings.ReplaceAll(commandTemplate, "{{PORTS}}", portsString)
|
||||||
commandString = strings.ReplaceAll(commandString, "{{PORT}}", portStrings[0])
|
commandString = strings.ReplaceAll(commandString, "{{PORT}}", portStrings[0])
|
||||||
|
commandString = strings.ReplaceAll(commandString, "{{VPN_INTERFACE}}", vpnInterface)
|
||||||
args, err := command.Split(commandString)
|
args, err := command.Split(commandString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("parsing command: %w", err)
|
return fmt.Errorf("parsing command: %w", err)
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ func Test_Service_runCommand(t *testing.T) {
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
cmder := command.New()
|
cmder := command.New()
|
||||||
const commandTemplate = `/bin/sh -c "echo {{PORTS}}"`
|
const commandTemplate = `/bin/sh -c "echo {{PORTS}}-{{PORT}}-{{VPN_INTERFACE}}"`
|
||||||
ports := []uint16{1234, 5678}
|
ports := []uint16{1234, 5678}
|
||||||
|
const vpnInterface = "tun0"
|
||||||
logger := NewMockLogger(ctrl)
|
logger := NewMockLogger(ctrl)
|
||||||
logger.EXPECT().Info("1234,5678")
|
logger.EXPECT().Info("1234,5678-1234-tun0")
|
||||||
|
|
||||||
err := runCommand(ctx, cmder, logger, commandTemplate, ports)
|
err := runCommand(ctx, cmder, logger, commandTemplate, ports, vpnInterface)
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func (s *Service) Start(ctx context.Context) (runError <-chan error, err error)
|
|||||||
s.portMutex.Unlock()
|
s.portMutex.Unlock()
|
||||||
|
|
||||||
if s.settings.UpCommand != "" {
|
if s.settings.UpCommand != "" {
|
||||||
err = runCommand(ctx, s.cmder, s.logger, s.settings.UpCommand, ports)
|
err = runCommand(ctx, s.cmder, s.logger, s.settings.UpCommand, ports, s.settings.Interface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("running up command: %w", err)
|
err = fmt.Errorf("running up command: %w", err)
|
||||||
s.logger.Error(err.Error())
|
s.logger.Error(err.Error())
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func (s *Service) cleanup() (err error) {
|
|||||||
const downTimeout = 60 * time.Second
|
const downTimeout = 60 * time.Second
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), downTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), downTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
err = runCommand(ctx, s.cmder, s.logger, s.settings.DownCommand, s.ports)
|
err = runCommand(ctx, s.cmder, s.logger, s.settings.DownCommand, s.ports, s.settings.Interface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("running down command: %w", err)
|
err = fmt.Errorf("running down command: %w", err)
|
||||||
s.logger.Error(err.Error())
|
s.logger.Error(err.Error())
|
||||||
|
|||||||
@@ -41,11 +41,15 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
|
|||||||
healthErrCh, err := l.healthChecker.Start(ctx)
|
healthErrCh, err := l.healthChecker.Start(ctx)
|
||||||
l.healthServer.SetError(err)
|
l.healthServer.SetError(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if *l.healthSettings.RestartVPN {
|
||||||
// Note this restart call must be done in a separate goroutine
|
// Note this restart call must be done in a separate goroutine
|
||||||
// from the VPN loop goroutine.
|
// from the VPN loop goroutine.
|
||||||
l.restartVPN(loopCtx, err)
|
l.restartVPN(loopCtx, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
l.logger.Warnf("(ignored) healthchecker start failed: %s", err)
|
||||||
|
l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md")
|
||||||
|
}
|
||||||
|
|
||||||
if *l.dnsLooper.GetSettings().ServerEnabled {
|
if *l.dnsLooper.GetSettings().ServerEnabled {
|
||||||
_, _ = l.dnsLooper.ApplyStatus(ctx, constants.Running)
|
_, _ = l.dnsLooper.ApplyStatus(ctx, constants.Running)
|
||||||
@@ -96,7 +100,7 @@ func (l *Loop) collectHealthErrors(ctx, loopCtx context.Context, healthErrCh <-c
|
|||||||
l.restartVPN(loopCtx, healthErr)
|
l.restartVPN(loopCtx, healthErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.logger.Warnf("healthcheck failed: %s", healthErr)
|
l.logger.Warnf("(ignored) healthcheck failed: %s", healthErr)
|
||||||
l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md")
|
l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md")
|
||||||
} else if previousHealthErr != nil {
|
} else if previousHealthErr != nil {
|
||||||
l.logger.Info("healthcheck passed successfully after previous failure(s)")
|
l.logger.Info("healthcheck passed successfully after previous failure(s)")
|
||||||
|
|||||||
Reference in New Issue
Block a user