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

Apply the obfuscation port to the entry configuration only #7199

Merged

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Nov 19, 2024

Currently, the obfuscation port is applied to the exit configuration at all times. Instead, it should be applied to the entry configuration when using multihop.


This change is Reviewable

@rablador rablador added bug iOS Issues related to iOS labels Nov 19, 2024
@rablador rablador self-assigned this Nov 19, 2024
Copy link

linear bot commented Nov 19, 2024

@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from a930993 to 7432679 Compare November 19, 2024 15:50
@rablador rablador marked this pull request as ready for review November 19, 2024 15:51
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

Reviewed 8 of 8 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @rablador)


ios/MullvadREST/Relay/RelayPicking.swift line 25 at r1 (raw file):

        from candidates: [RelayWithLocation<REST.ServerRelay>],
        closeTo location: Location? = nil,
        obfuscate: Bool

I think this conveys the wrong information, and is misleading.
It's effectively saying "use obfuscation" when instead it should be saying "use the obfuscated port if present" since this doesn't decide whether obfuscation is ultimately used or not.

How about we rename it shouldUseObfuscatedPort ?

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Added fixes for issue https://linear.app/mullvad/issue/IOS-948/fix-port-selection-for-shadowsocks as well.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @buggmagnet)


ios/MullvadREST/Relay/RelayPicking.swift line 25 at r1 (raw file):

Previously, buggmagnet wrote…

I think this conveys the wrong information, and is misleading.
It's effectively saying "use obfuscation" when instead it should be saying "use the obfuscated port if present" since this doesn't decide whether obfuscation is ultimately used or not.

How about we rename it shouldUseObfuscatedPort ?

Done.

@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from 7432679 to b9cfdf5 Compare November 22, 2024 14:33
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

Looks good, but Unit Tests are broken now 🫠

Reviewed 4 of 5 files at r2, all commit messages.
Reviewable status: 9 of 10 files reviewed, all discussions resolved

@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from b9cfdf5 to b462d11 Compare November 25, 2024 11:45
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Fixed!

Reviewable status: 9 of 10 files reviewed, all discussions resolved (waiting on @buggmagnet)

@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from b462d11 to 3017226 Compare November 25, 2024 11:46
buggmagnet
buggmagnet previously approved these changes Nov 25, 2024
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 5 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

acb-mv
acb-mv previously approved these changes Nov 26, 2024
Copy link
Contributor

@acb-mv acb-mv left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @rablador)


ios/MullvadREST/Relay/RelayPicking.swift line 14 at r2 (raw file):

protocol RelayPicking {
    var obfuscation: ObfuscatorPortSelection { get }

nit : that wouldn't be better to integrate all properties in another structure. since the it's growing up.


ios/MullvadREST/Relay/RelayPicking.swift line 15 at r2 (raw file):

protocol RelayPicking {
    var obfuscation: ObfuscatorPortSelection { get }
    var relays: REST.ServerRelaysResponse { get }

there no need to make it an exposed computed property out of the object. instead of using that property I suggest to use obfuscation.relays directly


ios/MullvadREST/Relay/RelayPicking.swift line 54 at r2 (raw file):

        var endpoint = match.endpoint

        if !portIsWithinRange {

I suggest to add some comment here about the process we are doing when the port is out of the range.


ios/MullvadREST/Relay/RelayPicking.swift line 89 at r2 (raw file):

            )

            let match = try findBestMatch(from: exitCandidates, useObfuscatedPort: true)

what is the reason behind setting that true in single hop?

Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @mojganii)


ios/MullvadREST/Relay/RelayPicking.swift line 14 at r2 (raw file):

Previously, mojganii wrote…

nit : that wouldn't be better to integrate all properties in another structure. since the it's growing up.

I think it's fine at this point, but maybe in the future. Adding a wrapper adds an extra layer that might make things harder to follow.


ios/MullvadREST/Relay/RelayPicking.swift line 15 at r2 (raw file):

Previously, mojganii wrote…

there no need to make it an exposed computed property out of the object. instead of using that property I suggest to use obfuscation.relays directly

I thought it would be clearer to specify a generic relays variable. It might not be obvious for a reader that the filtered relays from the obfuscation result is the thing you want.


ios/MullvadREST/Relay/RelayPicking.swift line 54 at r2 (raw file):

Previously, mojganii wrote…

I suggest to add some comment here about the process we are doing when the port is out of the range.

Done.


ios/MullvadREST/Relay/RelayPicking.swift line 89 at r2 (raw file):

Previously, mojganii wrote…

what is the reason behind setting that true in single hop?

It's not very obvious here, I agree, but useObfuscatedPort means that we should use the obfuscated port if there's one available. In singlehop there's only one (exit) relay, so obfuscation should always be applied in that case. In multihop we only set useObfuscatedPort to true if it's the entry relay.

@rablador rablador dismissed stale reviews from acb-mv and buggmagnet via 0be972c November 26, 2024 10:13
@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch 2 times, most recently from 0be972c to 5e02d88 Compare November 26, 2024 10:35
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @mojganii)

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from 5e02d88 to e3f0540 Compare November 27, 2024 15:44
@rablador rablador force-pushed the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch from e3f0540 to ddfa220 Compare November 28, 2024 07:40
@buggmagnet buggmagnet merged commit 512ba7c into main Nov 28, 2024
10 of 11 checks passed
@buggmagnet buggmagnet deleted the apply-the-shadowsocks-port-to-the-entry-configuration-ios-936 branch November 28, 2024 08:50
Copy link

🚨 End to end tests failed. Please check the failed workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants