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

VPN Waitlist and Debug Menu code cleanup. #3059

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

diegoreymendez
Copy link
Contributor

Task/Issue URL: https://app.asana.com/0/1206580121312550/1207951744290208/f

Description

Cleanup some remaining VPN waitlist code and clean up the debug menu.

Testing

  1. Make sure the debug menu works as usual and looks good.
  2. Start and stop the VPN make sure it works.

Definition of Done:


Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

@diegoreymendez diegoreymendez self-assigned this Aug 1, 2024
@@ -25,7 +25,6 @@ import SwiftUI

/// Controller for the VPN debug menu.
///
@MainActor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Raising warnings because NSMenu is not marked as @MainActor. I'm removing this because if NSMenu doesn't need this, our class doesn't either.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree, there have been other changes recently to move MainActor off of the class and onto only the functions that need it.

private let shouldIncludeAllNetworksMenuItem = NSMenuItem(title: "includeAllNetworks", action: #selector(NetworkProtectionDebugMenu.toggleIncludeAllNetworks))
private let connectOnLogInMenuItem = NSMenuItem(title: "Connect on Log In", action: #selector(NetworkProtectionDebugMenu.toggleConnectOnLogInAction))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is available in the app settings, not needed in the debug menu.

Comment on lines -320 to -329
@objc func toggleExclusionAction(_ sender: NSMenuItem) {
// Temporarily disabled: https://app.asana.com/0/0/1205766100762904/f
/*
guard let addressRange = sender.representedObject as? String else {
assertionFailure("Unexpected representedObject")
return
}

NetworkProtectionTunnelController().setExcludedRoute(addressRange, enabled: sender.state == .off)*/
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing dead code.

Comment on lines -406 to -425
private func populateExclusionsMenuItems() {
excludedRoutesMenu.removeAllItems()

for item in settings.excludedRoutes {
let menuItem: NSMenuItem
switch item {
case .section(let title):
menuItem = NSMenuItem(title: title, action: nil, target: nil)
menuItem.isEnabled = false

case .range(let range, let description):
menuItem = NSMenuItem(title: "\(range)\(description != nil ? " (\(description!))" : "")",
action: #selector(toggleExclusionAction),
target: self,
representedObject: range.stringRepresentation)
}
excludedRoutesMenu.addItem(menuItem)
}

}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing dead code.

Comment on lines -505 to -529
@objc func resetNetworkProtectionActivationDate(_ sender: Any?) {
overrideNetworkProtectionActivationDate(to: nil)
}

@objc func overrideNetworkProtectionActivationDateToNow(_ sender: Any?) {
overrideNetworkProtectionActivationDate(to: Date())
}

@objc func overrideNetworkProtectionActivationDateTo5DaysAgo(_ sender: Any?) {
overrideNetworkProtectionActivationDate(to: Date.daysAgo(5))
}

@objc func overrideNetworkProtectionActivationDateTo10DaysAgo(_ sender: Any?) {
overrideNetworkProtectionActivationDate(to: Date.daysAgo(10))
}

private func overrideNetworkProtectionActivationDate(to date: Date?) {
let store = DefaultWaitlistActivationDateStore(source: .netP)

if let date {
store.updateActivationDate(date)
} else {
store.removeDates()
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

VPN waitlist is long gone.

Comment on lines -552 to -565
func menuNeedsUpdate(_ menu: NSMenu) {
// Temporarily disabled: https://app.asana.com/0/0/1205766100762904/f
/*
if menu === exclusionsMenu {
let controller = NetworkProtectionTunnelController()
for item in menu.items {
guard let route = item.representedObject as? String else { continue }
item.state = controller.isExcludedRouteEnabled(route) ? .on : .off
// TO BE fixed: see NetworkProtectionTunnelController.excludedRoutes()
item.isEnabled = !(controller.shouldEnforceRoutes && route == "10.0.0.0/8")
}
}
*/
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing dead code.

@diegoreymendez diegoreymendez requested review from samsymons and removed request for quanganhdo August 1, 2024 15:20
Copy link
Collaborator

@samsymons samsymons left a comment

Choose a reason for hiding this comment

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

LGTM overall. I'm tempted to suggest removing the Environment settings as well, since they are permanently greyed out, but I can see the benefit of keeping them for internal users who look there first. I'll leave it up to you.

One thing I noticed during testing is that the Preferred Server menu is never populated with the server list, but that's the case in the main branch too so it's not blocking this.

@diegoreymendez
Copy link
Contributor Author

diegoreymendez commented Aug 2, 2024

I opened a task for the list of servers but will move ahead since, as you mention, that issue was not introduced here.

Thanks for the review @samsymons !

@diegoreymendez diegoreymendez marked this pull request as ready for review August 2, 2024 09:34
@diegoreymendez diegoreymendez merged commit 84ea979 into main Aug 2, 2024
21 checks passed
@diegoreymendez diegoreymendez deleted the diego/vpn-waitlist-and-debug-menu-cleanup branch August 2, 2024 09:34
samsymons added a commit that referenced this pull request Aug 4, 2024
# By Dax the Duck (2) and others
# Via Alexey Martemyanov (2) and GitHub (2)
* main:
  Update autoconsent to v10.13.0 (#3063)
  [DuckPlayer] 1. Move Extension to BSK and add Init Updates (#3055)
  Bump version to 1.100.0 (238)
  Bump version to 1.100.0 (237)
  Improve sorting logic and related test (#3064)
  VPN Waitlist and Debug Menu code cleanup. (#3059)
  restore CrashLogMessageExtractor (#3011)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
samsymons added a commit that referenced this pull request Aug 4, 2024
# By Dax the Duck (8) and others
# Via GitHub (5) and Alexey Martemyanov (2)
* main: (44 commits)
  Add RMF `messageShown` attribute (#3062)
  Update autoconsent to v10.13.0 (#3063)
  [DuckPlayer] 1. Move Extension to BSK and add Init Updates (#3055)
  Bump version to 1.100.0 (238)
  Bump version to 1.100.0 (237)
  Improve sorting logic and related test (#3064)
  VPN Waitlist and Debug Menu code cleanup. (#3059)
  restore CrashLogMessageExtractor (#3011)
  xattr command removed from the restarting script to avoid the macOS notification (#3057)
  Duck Player - Improved Settings + Ship Review feedback (#2981)
  Fix flaky TabContentTests (#3060)
  PIR Database Migrations: Remove Temporary Internal Time-Based Feature Flag (#3054)
  Bump version to 1.100.0 (236)
  Remove unused messaging system (#3047)
  Automatically add Asana task to macOS App Board (#3053)
  Disable password generation for burner windows (#3024)
  PIR: Improve sorting logic and related test (#3049)
  Remove @mainactor from test case class definitions (#3048)
  Fix autoplay FF behavior (#3032)
  Fix ghost InfoPlist.xcstrings (#3044)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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.

2 participants