mirror of
https://github.com/qdm12/gluetun.git
synced 2026-07-26 04:16:23 +02:00
Compare commits
2 Commits
7f9cd0fd0c
...
a1ef736b0f
| Author | SHA1 | Date | |
|---|---|---|---|
| a1ef736b0f | |||
| 46edfe49e3 |
@@ -15,7 +15,11 @@ 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])
|
var firstPort string
|
||||||
|
if len(portStrings) > 0 {
|
||||||
|
firstPort = portStrings[0]
|
||||||
|
}
|
||||||
|
commandString = strings.ReplaceAll(commandString, "{{PORT}}", firstPort)
|
||||||
commandString = strings.ReplaceAll(commandString, "{{VPN_INTERFACE}}", vpnInterface)
|
commandString = strings.ReplaceAll(commandString, "{{VPN_INTERFACE}}", vpnInterface)
|
||||||
return cmder.RunAndLog(ctx, commandString, logger)
|
return cmder.RunAndLog(ctx, commandString, logger)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -59,6 +60,10 @@ func (s *Service) SetPortsForwarded(ctx context.Context, ports []uint16) (err er
|
|||||||
s.portMutex.Lock()
|
s.portMutex.Lock()
|
||||||
defer s.portMutex.Unlock()
|
defer s.portMutex.Unlock()
|
||||||
|
|
||||||
|
if s.settings.PortForwarder != nil {
|
||||||
|
return errors.New("setting port forwarded at runtime is not supported with internally running port forwarding code")
|
||||||
|
}
|
||||||
|
|
||||||
slices.Sort(ports)
|
slices.Sort(ports)
|
||||||
if slices.Equal(s.ports, ports) {
|
if slices.Equal(s.ports, ports) {
|
||||||
return nil
|
return nil
|
||||||
@@ -78,7 +83,5 @@ func (s *Service) SetPortsForwarded(ctx context.Context, ports []uint16) (err er
|
|||||||
return fmt.Errorf("handling new ports: %w", err)
|
return fmt.Errorf("handling new ports: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.logger.Info("updated: " + portsToString(s.ports))
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user