Maint: rename wireguard CustomPort
This commit is contained in:
@@ -60,7 +60,7 @@ func (settings *OpenVPNSelection) readIVPN(env params.Interface) (err error) {
|
||||
}
|
||||
|
||||
func (settings *WireguardSelection) readIVPN(env params.Interface) (err error) {
|
||||
settings.CustomPort, err = readWireguardCustomPort(env,
|
||||
settings.EndpointPort, err = readWireguardCustomPort(env,
|
||||
[]uint16{2049, 2050, 53, 30587, 41893, 48574, 58237})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -165,7 +165,7 @@ func Test_Provider_readIvpn(t *testing.T) { //nolint:gocognit
|
||||
CustomPort: 443,
|
||||
},
|
||||
Wireguard: WireguardSelection{
|
||||
CustomPort: 2049,
|
||||
EndpointPort: 2049,
|
||||
},
|
||||
TargetIP: net.IPv4(1, 2, 3, 4),
|
||||
Countries: []string{"A", "B"},
|
||||
|
||||
@@ -65,7 +65,7 @@ func (settings *OpenVPNSelection) readMullvad(env params.Interface) (err error)
|
||||
}
|
||||
|
||||
func (settings *WireguardSelection) readMullvad(env params.Interface) (err error) {
|
||||
settings.CustomPort, err = readWireguardCustomPort(env, nil)
|
||||
settings.EndpointPort, err = readWireguardCustomPort(env, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -147,14 +147,17 @@ func (settings *OpenVPNSelection) readProtocolAndPort(env params.Interface) (err
|
||||
}
|
||||
|
||||
type WireguardSelection struct {
|
||||
CustomPort uint16 `json:"custom_port"` // Mullvad
|
||||
// EndpointPort is a the server port to use for the VPN server.
|
||||
// It is optional for Wireguard VPN providers IVPN, Mullvad
|
||||
// and Windscribe, and compulsory for the others
|
||||
EndpointPort uint16 `json:"port,omitempty"`
|
||||
}
|
||||
|
||||
func (settings *WireguardSelection) lines() (lines []string) {
|
||||
lines = append(lines, lastIndent+"Wireguard selection:")
|
||||
|
||||
if settings.CustomPort != 0 {
|
||||
lines = append(lines, indent+lastIndent+"Custom port: "+fmt.Sprint(settings.CustomPort))
|
||||
if settings.EndpointPort != 0 {
|
||||
lines = append(lines, indent+lastIndent+"Custom port: "+fmt.Sprint(settings.EndpointPort))
|
||||
}
|
||||
|
||||
return lines
|
||||
|
||||
@@ -57,7 +57,7 @@ func (settings *OpenVPNSelection) readWindscribe(env params.Interface) (err erro
|
||||
}
|
||||
|
||||
func (settings *WireguardSelection) readWindscribe(env params.Interface) (err error) {
|
||||
settings.CustomPort, err = readWireguardCustomPort(env,
|
||||
settings.EndpointPort, err = readWireguardCustomPort(env,
|
||||
[]uint16{53, 80, 123, 443, 1194, 65142})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -9,7 +9,7 @@ func GetPort(selection configuration.ServerSelection,
|
||||
defaultOpenVPNTCP, defaultOpenVPNUDP, defaultWireguard uint16) (port uint16) {
|
||||
switch selection.VPN {
|
||||
case constants.Wireguard:
|
||||
customPort := selection.Wireguard.CustomPort
|
||||
customPort := selection.Wireguard.EndpointPort
|
||||
if customPort > 0 {
|
||||
return customPort
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func Test_GetPort(t *testing.T) {
|
||||
selection: configuration.ServerSelection{
|
||||
VPN: constants.Wireguard,
|
||||
Wireguard: configuration.WireguardSelection{
|
||||
CustomPort: 1234,
|
||||
EndpointPort: 1234,
|
||||
},
|
||||
},
|
||||
port: 1234,
|
||||
|
||||
Reference in New Issue
Block a user