diff --git a/internal/models/connection.go b/internal/models/connection.go index 5e317a7d..654f75ae 100644 --- a/internal/models/connection.go +++ b/internal/models/connection.go @@ -16,6 +16,8 @@ type Connection struct { // Hostname is used for IPVanish, IVPN, Privado // and Windscribe for TLS verification. Hostname string `json:"hostname"` + // ServerName is used for PIA for port forwarding + ServerName string `json:"server_name,omitempty"` // PubKey is the public key of the VPN server, // used only for Wireguard. PubKey string `json:"pubkey"` @@ -24,7 +26,7 @@ type Connection struct { func (c *Connection) Equal(other Connection) bool { return c.IP.Equal(other.IP) && c.Port == other.Port && c.Protocol == other.Protocol && c.Hostname == other.Hostname && - c.PubKey == other.PubKey + c.ServerName == other.ServerName && c.PubKey == other.PubKey } // UpdateEmptyWith updates each field of the connection where the diff --git a/internal/provider/utils/connection.go b/internal/provider/utils/connection.go index a3deb4e1..24887a61 100644 --- a/internal/provider/utils/connection.go +++ b/internal/provider/utils/connection.go @@ -60,12 +60,13 @@ func GetConnection(provider string, } connection := models.Connection{ - Type: selection.VPN, - IP: ip, - Port: port, - Protocol: protocol, - Hostname: hostname, - PubKey: server.WgPubKey, // Wireguard + Type: selection.VPN, + IP: ip, + Port: port, + Protocol: protocol, + Hostname: hostname, + ServerName: server.ServerName, + PubKey: server.WgPubKey, // Wireguard } connections = append(connections, connection) } diff --git a/internal/vpn/openvpn.go b/internal/vpn/openvpn.go index aaf05bbd..d6fd48a5 100644 --- a/internal/vpn/openvpn.go +++ b/internal/vpn/openvpn.go @@ -41,5 +41,5 @@ func setupOpenVPN(ctx context.Context, fw firewall.VPNConnectionSetter, runner = openvpn.NewRunner(settings.OpenVPN, starter, logger) - return runner, connection.Hostname, nil + return runner, connection.ServerName, nil } diff --git a/internal/vpn/wireguard.go b/internal/vpn/wireguard.go index 3ea07ec2..3f9771d6 100644 --- a/internal/vpn/wireguard.go +++ b/internal/vpn/wireguard.go @@ -39,5 +39,5 @@ func setupWireguard(ctx context.Context, netlinker netlink.NetLinker, return nil, "", fmt.Errorf("failed setting firewall: %w", err) } - return wireguarder, connection.Hostname, nil + return wireguarder, connection.ServerName, nil }