Skip to content

Commit

Permalink
fix(protonvpn): natpmp assigned ports logs removed
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Sep 20, 2023
1 parent 659da67 commit ea25a0f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions internal/provider/protonvpn/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (p *Provider) PortForward(ctx context.Context, _ *http.Client,
const internalPort, externalPort = 0, 0
const lifetime = 60 * time.Second
for _, networkProtocol := range networkProtocols {
_, assignedInternalPort, assignedExternalPort, assignedLiftetime, err :=
_, _, assignedExternalPort, assignedLiftetime, err :=
client.AddPortMapping(ctx, gateway, networkProtocol,
internalPort, externalPort, lifetime)
if err != nil {
Expand All @@ -49,12 +49,6 @@ func (p *Provider) PortForward(ctx context.Context, _ *http.Client,
assignedLiftetime, lifetime))
}

if assignedInternalPort != internalPort {
logger.Warn(fmt.Sprintf("internal port assigned %d differs"+
" from internal port requested %d",
assignedInternalPort, internalPort))
}

port = assignedExternalPort
}

Expand All @@ -78,7 +72,7 @@ func (p *Provider) KeepPortForward(ctx context.Context, port uint16,
const lifetime = 60 * time.Second

for _, networkProtocol := range networkProtocols {
_, assignedInternalPort, assignedExternalPort, assignedLiftetime, err :=
_, _, assignedExternalPort, assignedLiftetime, err :=
client.AddPortMapping(ctx, gateway, networkProtocol,
internalPort, port, lifetime)
if err != nil {
Expand All @@ -91,10 +85,10 @@ func (p *Provider) KeepPortForward(ctx context.Context, port uint16,
assignedLiftetime, lifetime))
}

if assignedInternalPort != assignedExternalPort {
logger.Warn(fmt.Sprintf("internal port assigned %d differs"+
" from external port assigned %d",
assignedInternalPort, assignedExternalPort))
if port != assignedExternalPort {
logger.Warn(fmt.Sprintf("external port assigned %d changed to %d",
port, assignedExternalPort))
port = assignedExternalPort
}
}

Expand Down

0 comments on commit ea25a0f

Please sign in to comment.