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

Update data structure to support new obfuscation selection #7064

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Oct 24, 2024


This change is Reviewable

@rablador rablador added the iOS Issues related to iOS label Oct 24, 2024
@rablador rablador self-assigned this Oct 24, 2024
Copy link

linear bot commented Oct 24, 2024

@rablador rablador force-pushed the update-data-structure-to-support-new-obfuscation-selection-ios-890 branch 9 times, most recently from e5577b7 to c612322 Compare November 1, 2024 11:01
@rablador rablador marked this pull request as ready for review November 1, 2024 11:02
@rablador rablador force-pushed the update-data-structure-to-support-new-obfuscation-selection-ios-890 branch 2 times, most recently from 8cb92f6 to 067219c Compare November 1, 2024 12:11
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: 0 of 21 files reviewed, 1 unresolved discussion (waiting on @rablador)


ios/MullvadSettings/WireGuardObfuscationSettings.swift line 128 at r3 (raw file):

    public let state: WireGuardObfuscationState
    public let udpOverTcpPort: WireGuardObfuscationUdpOverTcpPort

are we going to keep the previous state when user is changing obfuscation method? in this architecture, if we add another state into WireGuardObfuscationState that has its own custom configuration then we need to add another property for that here, as well. is it the thing we will?

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 all commit messages.
Reviewable status: 0 of 21 files reviewed, 3 unresolved discussions (waiting on @rablador)


ios/MullvadSettings/WireGuardObfuscationSettings.swift line 56 at r3 (raw file):

    case port5001

    public var portValue: UInt16? {

This should not be Optional, we always know the real value of the port.


ios/PacketTunnelCore/Actor/ProtocolObfuscator.swift line 61 at r3 (raw file):

        let obfuscator = Obfuscator(
            remoteAddress: obfuscatedEndpoint.ipv4Relay.ip,
            tcpPort: tcpPort.portValue ?? 0

This is the reason why portValue shouldn't be nullable. 0 is an invalid port number in this case, and it should be impossible
to have this condition here since if the obfuscation is set to automatic it would either be 80 or 5001

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: 0 of 21 files reviewed, 3 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/MullvadSettings/WireGuardObfuscationSettings.swift line 56 at r3 (raw file):

Previously, buggmagnet wrote…

This should not be Optional, we always know the real value of the port.

We don't, since .automatic isn't really equal to eg. 0 we should properly represent that a port has not been explicity set.


ios/MullvadSettings/WireGuardObfuscationSettings.swift line 128 at r3 (raw file):

Previously, mojganii wrote…

are we going to keep the previous state when user is changing obfuscation method? in this architecture, if we add another state into WireGuardObfuscationState that has its own custom configuration then we need to add another property for that here, as well. is it the thing we will?

I think so. Doing it this way we keep each port setting no matter what other settings the user changes, so that's according to spec I think. Unfortunately we could not - in a good way - combine state and port into a single enum. The reason for that being that we set state and port in different places at different times, which makes it really bothersome to keep track of in a viewmodel.


ios/PacketTunnelCore/Actor/ProtocolObfuscator.swift line 61 at r3 (raw file):

Previously, buggmagnet wrote…

This is the reason why portValue shouldn't be nullable. 0 is an invalid port number in this case, and it should be impossible
to have this condition here since if the obfuscation is set to automatic it would either be 80 or 5001

That won't be true for long. This code will change when the relay selector PR goes up, and this part will handle the custom port for shadowsocks as well, which can be anything. I don't think we should be relying on an Int that's implicitly wrong if it happens to be a 0 but correct if it's a 1.

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: 0 of 21 files reviewed, 3 unresolved discussions (waiting on @buggmagnet and @mojganii)


ios/PacketTunnelCore/Actor/ProtocolObfuscator.swift line 61 at r3 (raw file):

Previously, rablador (Jon Petersson) wrote…

That won't be true for long. This code will change when the relay selector PR goes up, and this part will handle the custom port for shadowsocks as well, which can be anything. I don't think we should be relying on an Int that's implicitly wrong if it happens to be a 0 but correct if it's a 1.

Just to clarify, in the new code there won't be any fallbacks like this.

@buggmagnet buggmagnet requested a review from mojganii November 5, 2024 11:38
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.

Reviewable status: 0 of 21 files reviewed, 2 unresolved discussions (waiting on @mojganii and @rablador)


ios/MullvadSettings/WireGuardObfuscationSettings.swift line 56 at r3 (raw file):

Previously, rablador (Jon Petersson) wrote…

We don't, since .automatic isn't really equal to eg. 0 we should properly represent that a port has not been explicity set.

This was discussed offline.


ios/PacketTunnelCore/Actor/ProtocolObfuscator.swift line 61 at r3 (raw file):

Previously, rablador (Jon Petersson) wrote…

Just to clarify, in the new code there won't be any fallbacks like this.

Sounds good then, a temporary solution is fine.

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:

Reviewable status: 0 of 21 files reviewed, 1 unresolved discussion (waiting on @mojganii)

@buggmagnet buggmagnet force-pushed the update-data-structure-to-support-new-obfuscation-selection-ios-890 branch from 067219c to de9f75e Compare November 5, 2024 15:07
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: 0 of 21 files reviewed, all discussions resolved

@buggmagnet buggmagnet merged commit 2d5c810 into main Nov 5, 2024
10 of 11 checks passed
@buggmagnet buggmagnet deleted the update-data-structure-to-support-new-obfuscation-selection-ios-890 branch November 5, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants