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

Refactor PacketTunnelActor State, decoupling state from ancilliary data #6042

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

acb-mv
Copy link
Contributor

@acb-mv acb-mv commented Mar 28, 2024

This involves:

  • defining a protocol, StateAssociatedData, which encompasses common fields of the connection data for connected states and blockage data for error states
  • implementing a method, mutateAssociatedData, which applies a mutating function to the data, if present, and replacing a lot of case statements with this
  • renaming ConnectionState and BlockedState to State.ConnectionData and State.BlockingData, for clarity and namespace hygiene
  • making State Èquatable (within reason), and using equality testing in lieu of keeping track of whether a change was made

The result: a lot of business logic that acts on/modifies connection/blockage data is now considerably shorter, as it no longer needs to know about what the state is or which states may exist.

This was made in the course of the post-quantum functionality, and merged into that feature branch. This pull request is a backport of this to main.


This change is Reviewable

Copy link
Contributor

@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.

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

Copy link
Collaborator

@pinkisemils pinkisemils left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 7 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)


ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift line 26 at r1 (raw file):

     */
    func cacheActiveKey(lastKeyRotation: Date?) {
        // There should be a way to rationalise these two identical functions into one.

Is this comment still valid?

Copy link
Collaborator

@pinkisemils pinkisemils 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 4 of 7 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acb-mv)

@acb-mv
Copy link
Contributor Author

acb-mv commented Apr 2, 2024

ios/PacketTunnelCore/Actor/PacketTunnelActor+KeyPolicy.swift line 26 at r1 (raw file):

Previously, pinkisemils (Emīls Piņķis) wrote…

Is this comment still valid?

Good catch. It's not.

Copy link
Collaborator

@pinkisemils pinkisemils left a comment

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@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.

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

Copy link
Contributor

@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.

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

@buggmagnet buggmagnet added the iOS Issues related to iOS label Apr 3, 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 7 of 7 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@buggmagnet buggmagnet force-pushed the packettunnel-state-refactor-port branch from c32aa0c to 8e8910d Compare April 3, 2024 14:33
@buggmagnet buggmagnet merged commit 3686aae into main Apr 3, 2024
7 checks passed
@buggmagnet buggmagnet deleted the packettunnel-state-refactor-port branch April 3, 2024 14:34
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.

4 participants