Mullvad servers do not have a default port

- Refers to #218
- Checks for custom port value depending on protocol
- Remove default port from server constants
- Use 443 and 1194 ports respectively for tcp and udp
This commit is contained in:
Quentin McGaw
2020-08-24 01:53:24 +00:00
parent 7e3e6f166a
commit 6fc2b3dd21
5 changed files with 375 additions and 440 deletions

View File

@@ -1,6 +1,8 @@
package settings
import (
"fmt"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/params"
@@ -67,6 +69,19 @@ func GetMullvadSettings(paramsReader params.Reader) (settings models.ProviderSet
if err != nil {
return settings, err
}
if settings.ServerSelection.Protocol == constants.TCP {
switch settings.ServerSelection.CustomPort {
case 0, 80, 443, 1401:
default:
return settings, fmt.Errorf("port %d is not valid for TCP protocol", settings.ServerSelection.CustomPort)
}
} else {
switch settings.ServerSelection.CustomPort {
case 0, 53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400:
default:
return settings, fmt.Errorf("port %d is not valid for UDP protocol", settings.ServerSelection.CustomPort)
}
}
return settings, nil
}