From 72e2e4b82c481090d8287f7c8e4dc50d3de6a540 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Mon, 29 Apr 2024 19:23:34 +0000 Subject: [PATCH] fix(custom): set server name if names filter is not empty - fix PIA port forwarding code usage - refers to #2147 --- internal/provider/custom/connection.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/internal/provider/custom/connection.go b/internal/provider/custom/connection.go index 0fd73e5e..6985940f 100644 --- a/internal/provider/custom/connection.go +++ b/internal/provider/custom/connection.go @@ -40,16 +40,29 @@ func getOpenVPNConnection(extractor Extractor, 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 } func getWireguardConnection(selection settings.ServerSelection) ( connection models.Connection) { - return models.Connection{ - Type: vpn.Wireguard, - IP: selection.Wireguard.EndpointIP, - Port: *selection.Wireguard.EndpointPort, - Protocol: constants.UDP, - PubKey: selection.Wireguard.PublicKey, + connection = models.Connection{ + Type: vpn.Wireguard, + IP: selection.Wireguard.EndpointIP, + Port: *selection.Wireguard.EndpointPort, + Protocol: constants.UDP, + 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 }