-
Notifications
You must be signed in to change notification settings - Fork 381
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
Put app in blocked state on tunnel start if relay constraints cannot be satisfied #5300
Conversation
IOS-351 Removing Relay filters does not exit blocked state
See the attached slack discussion for the repro steps |
6f239a4
to
eb69f11
Compare
5594fc0
to
38931c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @rablador)
ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
line 69 at r1 (raw file):
self.dispatchQueue.async { do { try self.startTunnel(tunnel: try result.get())
Nit: AFAIK one try
in front is enough as it implies try result.get()
too.
ios/PacketTunnelCore/IPC/PacketTunnelOptions.swift
line 43 at r1 (raw file):
} public mutating func setSelectedRelay(_ value: SelectedRelay?) throws {
getSelectedRelay()
will probably break because it decodes SelectedRelay.self
. Instead you could omit encoding nil
values altogether. Do not pass nil
to indicate absence of value, instead avoid passing nil
altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 3 unresolved discussions (waiting on @rablador)
ios/MullvadVPN/TunnelManager/TunnelManager.swift
line 213 at r1 (raw file):
dispatchQueue: internalQueue, interactor: TunnelInteractorProxy(self), selectedRelay: try? selectRelay(),
Prefer to keep the actual work inside of operation body (main
) and not outside to avoid working with stale data. For example relay constraints could be changed before StartTunnelOperation
begins execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @rablador)
There was a problem hiding this 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, 2 unresolved discussions (waiting on @pronebird)
ios/MullvadVPN/TunnelManager/TunnelManager.swift
line 213 at r1 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
Prefer to keep the actual work inside of operation body (
main
) and not outside to avoid working with stale data. For example relay constraints could be changed beforeStartTunnelOperation
begins execution.
Sounds right, on it.
ios/PacketTunnelCore/IPC/PacketTunnelOptions.swift
line 43 at r1 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
getSelectedRelay()
will probably break because it decodesSelectedRelay.self
. Instead you could omit encodingnil
values altogether. Do not passnil
to indicate absence of value, instead avoid passingnil
altogether.
Ah, yes, my bad. However, we do want to remove the value if there's no selected relay, right?
38931c5
to
5026c3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @pronebird)
ios/PacketTunnelCore/IPC/PacketTunnelOptions.swift
line 43 at r1 (raw file):
Previously, rablador (Jon Petersson) wrote…
Ah, yes, my bad. However, we do want to remove the value if there's no selected relay, right?
My bad again. I just realised we creatre new PacketTunnelOptions before this call, so simply setting nothing is the way to go.
5026c3c
to
00ae7c2
Compare
There was a problem hiding this 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 3 files reviewed, 3 unresolved discussions (waiting on @pronebird and @rablador)
ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
line 76 at r2 (raw file):
private func startTunnel(tunnel: Tunnel) throws { let selectedRelay = try? interactor.selectRelay()
Was there any reason to not use a more straightforward approach ?
private func startTunnel(tunnel: Tunnel) throws {
let selectedRelay = try interactor.selectRelay()
var tunnelOptions = PacketTunnelOptions()
try tunnelOptions.setSelectedRelay(selectedRelay)
interactor.setTunnel(tunnel, shouldRefreshTunnelState: false)
interactor.updateTunnelStatus { tunnelStatus in
tunnelStatus = TunnelStatus()
tunnelStatus.packetTunnelStatus.tunnelRelay = selectedRelay.packetTunnelRelay
tunnelStatus.state = .connecting(selectedRelay.packetTunnelRelay)
}
try tunnel.start(options: tunnelOptions.rawOptions())
}
There was a problem hiding this 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 3 files reviewed, 2 unresolved discussions (waiting on @pronebird)
ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
line 76 at r2 (raw file):
Previously, buggmagnet wrote…
Was there any reason to not use a more straightforward approach ?
private func startTunnel(tunnel: Tunnel) throws { let selectedRelay = try interactor.selectRelay() var tunnelOptions = PacketTunnelOptions() try tunnelOptions.setSelectedRelay(selectedRelay) interactor.setTunnel(tunnel, shouldRefreshTunnelState: false) interactor.updateTunnelStatus { tunnelStatus in tunnelStatus = TunnelStatus() tunnelStatus.packetTunnelStatus.tunnelRelay = selectedRelay.packetTunnelRelay tunnelStatus.state = .connecting(selectedRelay.packetTunnelRelay) } try tunnel.start(options: tunnelOptions.rawOptions()) }
As far as I understand, if interactor.selectRelay()
throws we won't set up a tunnel and start it, which means we cannot enter a blocked state.
There was a problem hiding this 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 3 files reviewed, 2 unresolved discussions (waiting on @pronebird)
ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
line 76 at r2 (raw file):
Previously, rablador (Jon Petersson) wrote…
As far as I understand, if
interactor.selectRelay()
throws we won't set up a tunnel and start it, which means we cannot enter a blocked state.
Yeah I quickly realized what I wrote wouldn't work, so I deleted the comment... Too late !
There was a problem hiding this 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 3 files reviewed, 2 unresolved discussions (waiting on @pronebird)
ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
line 76 at r2 (raw file):
Previously, buggmagnet wrote…
Yeah I quickly realized what I wrote wouldn't work, so I deleted the comment... Too late !
It can never be unseen!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @pronebird)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
ios/PacketTunnelCore/IPC/PacketTunnelOptions.swift
line 43 at r1 (raw file):
Previously, rablador (Jon Petersson) wrote…
My bad again. I just realised we creatre new PacketTunnelOptions before this call, so simply setting nothing is the way to go.
Correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
00ae7c2
into
update-relay-list-view-to-allow-filtering-by-provider-ios-180
On tunnel start, if no valid relay can be selected app-side we let the packet tunnel take care of it instead. This will put the app in blocked state.
This PR takes care of issue the following issue as well:
https://linear.app/mullvad/issue/IOS-351/removing-relay-filters-does-not-exit-blocked-state
This change is