fix(custom): set server name if names filter is not empty

- fix PIA port forwarding code usage
- refers to #2147
This commit is contained in:
Quentin McGaw
2024-04-29 19:23:34 +00:00
parent bdc594c297
commit 72e2e4b82c

View File

@@ -40,16 +40,29 @@ func getOpenVPNConnection(extractor Extractor,
connection.Port = customPort connection.Port = customPort
} }
if len(selection.Names) > 0 {
// Set the server name for PIA port forwarding code used
// together with the custom provider.
connection.ServerName = selection.Names[0]
}
return connection, nil return connection, nil
} }
func getWireguardConnection(selection settings.ServerSelection) ( func getWireguardConnection(selection settings.ServerSelection) (
connection models.Connection) { connection models.Connection) {
return models.Connection{ connection = models.Connection{
Type: vpn.Wireguard, Type: vpn.Wireguard,
IP: selection.Wireguard.EndpointIP, IP: selection.Wireguard.EndpointIP,
Port: *selection.Wireguard.EndpointPort, Port: *selection.Wireguard.EndpointPort,
Protocol: constants.UDP, Protocol: constants.UDP,
PubKey: selection.Wireguard.PublicKey, PubKey: selection.Wireguard.PublicKey,
ServerName: selection.Names[0],
} }
if len(selection.Names) > 0 {
// Set the server name for PIA port forwarding code used
// together with the custom provider.
connection.ServerName = selection.Names[0]
}
return connection
} }