Maint: remove startPFCh from Openvpn loop
This commit is contained in:
@@ -2,6 +2,8 @@ package openvpn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
@@ -9,20 +11,24 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
)
|
||||
|
||||
func (l *Loop) startPortForwarding(ctx context.Context,
|
||||
enabled bool, portForwarder provider.PortForwarder,
|
||||
serverName string) {
|
||||
var (
|
||||
errObtainVPNLocalGateway = errors.New("cannot obtain VPN local gateway IP")
|
||||
errStartPortForwarding = errors.New("cannot start port forwarding")
|
||||
)
|
||||
|
||||
func (l *Loop) startPortForwarding(ctx context.Context, enabled bool,
|
||||
portForwarder provider.PortForwarder, serverName string) (err error) {
|
||||
if !enabled {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
// only used for PIA for now
|
||||
gateway, err := l.routing.VPNLocalGatewayIP()
|
||||
if err != nil {
|
||||
l.logger.Error("cannot obtain VPN local gateway IP: " + err.Error())
|
||||
return
|
||||
return fmt.Errorf("%w: %s", errObtainVPNLocalGateway, err)
|
||||
}
|
||||
l.logger.Info("VPN gateway IP address: " + gateway.String())
|
||||
|
||||
pfData := portforward.StartData{
|
||||
PortForwarder: portForwarder,
|
||||
Gateway: gateway,
|
||||
@@ -31,8 +37,10 @@ func (l *Loop) startPortForwarding(ctx context.Context,
|
||||
}
|
||||
_, err = l.portForward.Start(ctx, pfData)
|
||||
if err != nil {
|
||||
l.logger.Error("cannot start port forwarding: " + err.Error())
|
||||
return fmt.Errorf("%w: %s", errStartPortForwarding, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *Loop) stopPortForwarding(ctx context.Context, enabled bool,
|
||||
|
||||
Reference in New Issue
Block a user