Skip to content

Commit

Permalink
Added support for the enforce routes remote feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Nov 4, 2024
1 parent 3db14a6 commit e033d3c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Core/ios-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5648,6 +5648,9 @@
},
"userTips": {
"state": "enabled"
},
"enforceRoutes": {
"state": "enabled"
}
},
"exceptions": [],
Expand Down Expand Up @@ -9676,4 +9679,4 @@
}
},
"unprotectedTemporary": []
}
}
6 changes: 3 additions & 3 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1658,12 +1658,12 @@
6FEC0B842C999352006B4F6E /* FavoriteItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteItem.swift; sourceTree = "<group>"; };
6FEC0B872C999961006B4F6E /* FavoritesListInteractingAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesListInteractingAdapter.swift; sourceTree = "<group>"; };
6FF915802B88E0750042AC87 /* AdAttributionFetcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdAttributionFetcherTests.swift; sourceTree = "<group>"; };
7B84C2852CCA68A700401102 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = SOURCE_ROOT; };
7BB7573F2CD8CAF100E0A8D0 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = SOURCE_ROOT; };
7B1604E72CB685B400A44EC6 /* Logger+TipKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+TipKit.swift"; sourceTree = "<group>"; };
7B1604EB2CB68BDA00A44EC6 /* TipKitController+ConvenienceInitializers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TipKitController+ConvenienceInitializers.swift"; sourceTree = "<group>"; };
7B1604ED2CB68D2600A44EC6 /* TipKitDebugOptionsUIActionHandling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipKitDebugOptionsUIActionHandling.swift; sourceTree = "<group>"; };
7B84C2852CCA68A700401102 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = SOURCE_ROOT; };
7B8E0EC52CC81B4800B2B722 /* TipKitController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipKitController.swift; sourceTree = "<group>"; };
7BB7573F2CD8CAF100E0A8D0 /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = SOURCE_ROOT; };
7BC5711F2BDBB877003B0CCE /* VPNActivationDateStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VPNActivationDateStore.swift; sourceTree = "<group>"; };
7BDBAD0D2CBFB3F1000379B7 /* VPN.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = VPN.xcassets; sourceTree = "<group>"; };
7BF78E012CA2CC3E0026A1FC /* TipKitAppEventHandling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipKitAppEventHandling.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10974,7 +10974,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = revision;
revision = cbed087a692a746392b785d8aa437107ab95b2f3;
revision = 66088d0a259a781d2ecd093c10939467b7515a37;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
7 changes: 6 additions & 1 deletion DuckDuckGo/Configuration/ConfigurationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ final class ConfigurationManager: DefaultConfigurationManager {
var tasks = [Configuration: Task<(), Swift.Error>]()
tasks[.trackerDataSet] = Task { try await fetcher.fetch(.trackerDataSet, isDebug: isDebug) }
tasks[.surrogates] = Task { try await fetcher.fetch(.surrogates, isDebug: isDebug) }
tasks[.privacyConfiguration] = Task { try await fetcher.fetch(.privacyConfiguration, isDebug: isDebug) }
tasks[.privacyConfiguration] = Task {
try await fetcher.fetch(.privacyConfiguration, isDebug: isDebug)
}

for (configuration, task) in tasks {
do {
try await task.value
didFetchAnyTrackerBlockingDependencies = true
} catch {
if configuration == .privacyConfiguration {
print("asD")
}
Logger.general.error("Did not apply update to \(configuration.rawValue, privacy: .public): \(error.localizedDescription, privacy: .public)")
}
}
Expand Down
13 changes: 13 additions & 0 deletions DuckDuckGo/NetworkProtectionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class NetworkProtectionDebugViewController: UITableViewController {
enum DebugFeatureRows: Int, CaseIterable {
case toggleAlwaysOn
case enforceRoutes
case resetEnforceRoutesForceEnable
}

enum SimulateFailureRows: Int, CaseIterable {
Expand Down Expand Up @@ -333,6 +334,14 @@ final class NetworkProtectionDebugViewController: UITableViewController {
} else {
cell.accessoryType = .checkmark
}
case .resetEnforceRoutesForceEnable:
cell.textLabel?.text = "Reset force-enable for Enforce Routes"

if AppDependencyProvider.shared.vpnSettings.enforceRoutesForceEnabledOnce {
cell.accessoryType = .checkmark
} else {
cell.accessoryType = .none
}
default:
break
}
Expand All @@ -346,6 +355,10 @@ final class NetworkProtectionDebugViewController: UITableViewController {
case .enforceRoutes:
AppDependencyProvider.shared.vpnSettings.enforceRoutes.toggle()
tableView.reloadRows(at: [indexPath], with: .none)
case .resetEnforceRoutesForceEnable:
AppDependencyProvider.shared.vpnSettings.enforceRoutesForceEnabledOnce = false
ActionMessageView.present(message: "Next time you start the VPN enforce routes will be enabled if the feature flag is enabled for you")
tableView.reloadRows(at: [indexPath], with: .none)
default:
break
}
Expand Down
16 changes: 13 additions & 3 deletions DuckDuckGo/NetworkProtectionTunnelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,19 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
// MARK: - Enforce Routes

private var enforceRoutes: Bool {
//featureFlagger.isFeatureOn(.networkProtectionEnforceRoutes)
//&& settings.enforceRoutes
settings.enforceRoutes
guard featureFlagger.isFeatureOn(.networkProtectionEnforceRoutes) else {
return false
}

/// Even though there's a remote feature flag, we still want to allow internal users to disable enforceRoutes
/// manually in case they have trouble. To achieve this we force the setting to ON once, but otherwise
/// allow the internal user to disable it again.
if !settings.enforceRoutesForceEnabledOnce {
settings.enforceRoutesForceEnabledOnce = true
settings.enforceRoutes = true
}

return settings.enforceRoutes
}

// MARK: - Initializers
Expand Down

0 comments on commit e033d3c

Please sign in to comment.