mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
feat(protonvpn): support up to 5 forwarded ports (#3208)
This commit is contained in:
@@ -22,7 +22,7 @@ var ErrPortForwardedNotFound = errors.New("port forwarded not found")
|
||||
// PortForward obtains a VPN server side port forwarded from the PrivateVPN API.
|
||||
// It returns 0 if all ports are to forwarded on a dedicated server IP.
|
||||
func (p *Provider) PortForward(ctx context.Context, objects utils.PortForwardObjects) (
|
||||
ports []uint16, err error,
|
||||
internalToExternalPorts map[uint16]uint16, err error,
|
||||
) {
|
||||
// Define a timeout since the default client has a large timeout and we don't
|
||||
// want to wait too long.
|
||||
@@ -75,7 +75,8 @@ func (p *Provider) PortForward(ctx context.Context, objects utils.PortForwardObj
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parsing port: %w", err)
|
||||
}
|
||||
return []uint16{uint16(portUint64)}, nil
|
||||
port := uint16(portUint64)
|
||||
return map[uint16]uint16{port: port}, nil
|
||||
}
|
||||
|
||||
func (p *Provider) KeepPortForward(ctx context.Context,
|
||||
|
||||
@@ -28,10 +28,10 @@ func Test_Provider_PortForward(t *testing.T) {
|
||||
cancel()
|
||||
|
||||
testCases := map[string]struct {
|
||||
ctx context.Context
|
||||
objects utils.PortForwardObjects
|
||||
ports []uint16
|
||||
errMessage string
|
||||
ctx context.Context
|
||||
objects utils.PortForwardObjects
|
||||
internalToExternalPorts map[uint16]uint16
|
||||
errMessage string
|
||||
}{
|
||||
"canceled context": {
|
||||
ctx: canceledCtx,
|
||||
@@ -192,7 +192,7 @@ func Test_Provider_PortForward(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
},
|
||||
ports: []uint16{61527},
|
||||
internalToExternalPorts: map[uint16]uint16{61527: 61527},
|
||||
},
|
||||
}
|
||||
for name, testCase := range testCases {
|
||||
@@ -203,7 +203,7 @@ func Test_Provider_PortForward(t *testing.T) {
|
||||
ports, err := provider.PortForward(testCase.ctx,
|
||||
testCase.objects)
|
||||
|
||||
assert.Equal(t, testCase.ports, ports)
|
||||
assert.Equal(t, testCase.internalToExternalPorts, ports)
|
||||
if testCase.errMessage != "" {
|
||||
assert.EqualError(t, err, testCase.errMessage)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user