Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protonvpn): Added ProtonVPN feature selection #2182

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kvanzuijlen
Copy link

I know it's not completely done yet (missing tests, missing todo's for moving feature-related stuff to the new Features struct, docs, etc) but I wanted to open a PR to see if you agree with my chosen direction.

Closes #1582, partially #1103

Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice it's looking pretty good, just a few minor comments 😉 👍

internal/configuration/settings/serverselection.go Outdated Show resolved Hide resolved
Comment on lines 126 to 132
err = validateFeatureFilters(*ss, vpnServiceProvider)
if err != nil {
return fmt.Errorf("for VPN service provider %s: %w", vpnServiceProvider, err)
}

if *ss.OwnedOnly &&
vpnServiceProvider != providers.Mullvad {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not incorporate OwnedOnly etc. (below) within validateFeatureFilters?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this was a feature or a "subscription tier" filter. If it is a feature then it makes sense to move it as well!

internal/configuration/settings/serverselection.go Outdated Show resolved Hide resolved
Comment on lines +81 to +83
// IPv6Only is true if VPN servers without IPv6 support should
// be filtered. This is used with ProtonVPN.
IPv6Only *bool `json:"ipv6_only"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this filter do? 🤔
Because AFAIK there are only IPv4 addresses to reach Protonvpn servers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure! It's indeed not a supported feature by any current server, but I just wanted to implement all features listed in protonvpn-nm-lib

.gitignore Outdated Show resolved Hide resolved
internal/models/server.go Outdated Show resolved Hide resolved
internal/provider/protonvpn/updater/api.go Outdated Show resolved Hide resolved
@@ -10,7 +10,7 @@ import (
type ipToServer map[string]models.Server

func (its ipToServer) add(country, region, city, name, hostname string,
free bool, entryIP netip.Addr) {
free bool, entryIP netip.Addr, features *models.Features) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit just return the whole bunch of features after free bool, or define an unexported features struct in this package, up to you 😉 (and then add the free bool to it too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will wait with this to see what you decide about the features struct in models/server.go

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The features are defined at logical server level, "free" at physical server level, didn't feel right to put it both in the same struct, but will do if you prefer it.

internal/provider/utils/filtering.go Outdated Show resolved Hide resolved
internal/storage/filter.go Outdated Show resolved Hide resolved
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
@kvanzuijlen kvanzuijlen changed the title feat: Added ProtonVPN feature selection feat(protonvpn): Added ProtonVPN feature selection Mar 26, 2024
@kvanzuijlen
Copy link
Author

Hi,

I applied (most of) your suggestions from the code review. I also added minimal unit tests (basically added to all the _test files) for all files changed in this PR. I also built my own image and started using it already. It seems to work, as far as I can tell.

@kvanzuijlen
Copy link
Author

@qdm12 I've been running this code for a couple of days now myself (https://github.com/users/kvanzuijlen/packages/container/package/gluetun) and as far as I can tell it now fully works :).

@kvanzuijlen kvanzuijlen requested a review from qdm12 April 1, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Protonvpn filtering by features
2 participants