hotfix(protonvpn): drop P2P_ONLY in favor of PORT_FORWARD_ONLY

This commit is contained in:
Quentin McGaw
2024-07-31 14:29:31 +00:00
parent 13ffffb157
commit 5191f3558f
8 changed files with 1 additions and 45 deletions

View File

@@ -142,7 +142,6 @@ ENV VPN_SERVICE_PROVIDER=pia \
FREE_ONLY= \
SECURE_CORE_ONLY= \
TOR_ONLY= \
P2P_ONLY= \
# # Surfshark only:
MULTIHOP_ONLY= \
# # VPN Secure only:

View File

@@ -69,9 +69,6 @@ type ServerSelection struct { //nolint:maligned
// TorOnly is true if VPN servers without tor should
// be filtered. This is used with ProtonVPN.
TorOnly *bool `json:"tor_only"`
// P2POnly is true if VPN servers not for p2p should
// be filtered. This is used with ProtonVPN.
P2POnly *bool `json:"p2p_only"`
// OpenVPN contains settings to select OpenVPN servers
// and the final connection.
OpenVPN OpenVPNSelection `json:"openvpn"`
@@ -90,7 +87,6 @@ var (
ErrFreePremiumBothSet = errors.New("free only and premium only filters are both set")
ErrSecureCoreOnlyNotSupported = errors.New("secure core only filter is not supported")
ErrTorOnlyNotSupported = errors.New("tor only filter is not supported")
ErrP2POnlyNotSupported = errors.New("p2p only filter is not supported")
)
func (ss *ServerSelection) validate(vpnServiceProvider string,
@@ -246,8 +242,6 @@ func validateFeatureFilters(settings ServerSelection, vpnServiceProvider string)
return fmt.Errorf("%w", ErrSecureCoreOnlyNotSupported)
case *settings.TorOnly && vpnServiceProvider != providers.Protonvpn:
return fmt.Errorf("%w", ErrTorOnlyNotSupported)
case *settings.P2POnly && vpnServiceProvider != providers.Protonvpn:
return fmt.Errorf("%w", ErrP2POnlyNotSupported)
default:
return nil
}
@@ -271,7 +265,6 @@ func (ss *ServerSelection) copy() (copied ServerSelection) {
StreamOnly: gosettings.CopyPointer(ss.StreamOnly),
SecureCoreOnly: gosettings.CopyPointer(ss.SecureCoreOnly),
TorOnly: gosettings.CopyPointer(ss.TorOnly),
P2POnly: gosettings.CopyPointer(ss.P2POnly),
PortForwardOnly: gosettings.CopyPointer(ss.PortForwardOnly),
MultiHopOnly: gosettings.CopyPointer(ss.MultiHopOnly),
OpenVPN: ss.OpenVPN.copy(),
@@ -296,7 +289,6 @@ func (ss *ServerSelection) overrideWith(other ServerSelection) {
ss.StreamOnly = gosettings.OverrideWithPointer(ss.StreamOnly, other.StreamOnly)
ss.SecureCoreOnly = gosettings.OverrideWithPointer(ss.SecureCoreOnly, other.SecureCoreOnly)
ss.TorOnly = gosettings.OverrideWithPointer(ss.TorOnly, other.TorOnly)
ss.P2POnly = gosettings.OverrideWithPointer(ss.P2POnly, other.P2POnly)
ss.MultiHopOnly = gosettings.OverrideWithPointer(ss.MultiHopOnly, other.MultiHopOnly)
ss.PortForwardOnly = gosettings.OverrideWithPointer(ss.PortForwardOnly, other.PortForwardOnly)
ss.OpenVPN.overrideWith(other.OpenVPN)
@@ -312,7 +304,6 @@ func (ss *ServerSelection) setDefaults(vpnProvider string) {
ss.StreamOnly = gosettings.DefaultPointer(ss.StreamOnly, false)
ss.SecureCoreOnly = gosettings.DefaultPointer(ss.SecureCoreOnly, false)
ss.TorOnly = gosettings.DefaultPointer(ss.TorOnly, false)
ss.P2POnly = gosettings.DefaultPointer(ss.P2POnly, false)
ss.MultiHopOnly = gosettings.DefaultPointer(ss.MultiHopOnly, false)
ss.PortForwardOnly = gosettings.DefaultPointer(ss.PortForwardOnly, false)
ss.OpenVPN.setDefaults(vpnProvider)
@@ -389,10 +380,6 @@ func (ss ServerSelection) toLinesNode() (node *gotree.Node) {
node.Appendf("Tor only servers: yes")
}
if *ss.P2POnly {
node.Appendf("P2P only servers: yes")
}
if *ss.MultiHopOnly {
node.Appendf("Multi-hop only servers: yes")
}
@@ -482,12 +469,6 @@ func (ss *ServerSelection) read(r *reader.Reader,
return err
}
// ProtonVPN only
ss.P2POnly, err = r.BoolPtr("P2P_ONLY")
if err != nil {
return err
}
// PIA only
ss.PortForwardOnly, err = r.BoolPtr("PORT_FORWARD_ONLY")
if err != nil {

View File

@@ -33,7 +33,6 @@ type Server struct {
Stream bool `json:"stream,omitempty"` // TODO v4 create a Features struct
SecureCore bool `json:"secure_core,omitempty"`
Tor bool `json:"tor,omitempty"`
P2P bool `json:"p2p,omitempty"`
PortForward bool `json:"port_forward,omitempty"`
Keep bool `json:"keep,omitempty"`
IPs []netip.Addr `json:"ips,omitempty"`

View File

@@ -62,7 +62,6 @@ func Test_Server_Equal(t *testing.T) {
Stream: true,
SecureCore: true,
Tor: true,
P2P: false,
PortForward: true,
IPs: []netip.Addr{netip.AddrFrom4([4]byte{1, 2, 3, 4})},
Keep: true,
@@ -87,7 +86,6 @@ func Test_Server_Equal(t *testing.T) {
Stream: true,
SecureCore: true,
Tor: true,
P2P: false,
PortForward: true,
IPs: []netip.Addr{netip.AddrFrom4([4]byte{1, 2, 3, 4})},
Keep: true,

View File

@@ -34,7 +34,7 @@ func (its ipToServer) add(country, region, city, name, hostname string,
server.Free = free
server.SecureCore = features.secureCore
server.Tor = features.tor
server.P2P = features.p2p
server.PortForward = features.p2p
server.Stream = features.stream
server.UDP = true
server.TCP = true

View File

@@ -65,10 +65,6 @@ func filterServer(server models.Server,
return true
}
if *selection.P2POnly && !server.P2P {
return true
}
if filterByPossibilities(server.Country, selection.Countries) {
return true
}

View File

@@ -141,19 +141,6 @@ func Test_FilterServers(t *testing.T) {
{Tor: true, VPN: vpn.OpenVPN, UDP: true},
},
},
"filter by P2P only": {
selection: settings.ServerSelection{
P2POnly: boolPtr(true),
}.WithDefaults(providers.Protonvpn),
servers: []models.Server{
{P2P: false, VPN: vpn.OpenVPN, UDP: true},
{P2P: true, VPN: vpn.OpenVPN, UDP: true},
{P2P: false, VPN: vpn.OpenVPN, UDP: true},
},
filtered: []models.Server{
{P2P: true, VPN: vpn.OpenVPN, UDP: true},
},
},
"filter by owned": {
selection: settings.ServerSelection{
OwnedOnly: boolPtr(true),

View File

@@ -87,10 +87,6 @@ func filterServer(server models.Server,
return true
}
if *selection.P2POnly && !server.P2P {
return true
}
if filterByPossibilities(server.Country, selection.Countries) {
return true
}