Commit Graph

88 Commits

Author SHA1 Message Date
Davide De Rosa 02a9db057f Update TunnelKit
- Set explicit tunnel log path

- OpenSSL 1.1.1o
2022-06-19 13:33:49 +02:00
Davide De Rosa 14b42fbea5 Persist managers state to generic key-value store
Move all persisted state out of AppManager to where it really
belongs. To do that, inject a shared KeyValueStore object into
managers that need to persist part of their state in a strongly
typed manner.

Below are persisted states:

- PersistenceManager
    - persistenceAuthor

- ProfileManager
    - activeProfileId

- UpgradeManager (formerly AppManager)
    - didMigrateToV2 (migrate former value)

- VPNManager
    - tunnelLogFormat
    - masksPrivateData

A similar approach is used for app-specific preferences, by using
a strongly typed enum (AppPreference) together with SwiftUI
@AppStorage property wrapper.

Worth moving logging logic into a specific LogManager.

Finally, drop any former view dependency on AppManager, as states
are now accessed through specific managers.
2022-06-16 13:42:37 +02:00
Davide De Rosa a2d4ed370e Revisit sidebar with per-profile VPN toggles 2022-05-21 19:15:37 +02:00
Davide De Rosa f0c5ecd84f Handle configuration errors out of VPN status
On configuration error, retain information about the profile that
triggered the error. For now, present an alert, but with this
information the UI can be easily changed later.
2022-05-21 19:01:49 +02:00
Davide De Rosa 59b3c320c8 Only activate profile after valid configuration 2022-05-20 11:58:28 +02:00
Davide De Rosa fe4ca51820 Clear lastError in VPNManager.reconnect() 2022-05-19 11:30:22 +02:00
Davide De Rosa 4455f66d10 Detect TestFlight on macOS
Move function to Utils.
2022-05-18 11:16:31 +02:00
Davide De Rosa 6c798c8b19 Bump build 2022-05-17 16:43:14 +02:00
Davide De Rosa 05f3457249 Fix some Mac specific code in Core
- Improve network conditionals in on-demand rules

- Restore native version of DebugLog

- Restore correct code to fetch current SSID
2022-05-17 12:24:28 +02:00
Davide De Rosa 7196aeab0d Trust Ethernet on Mac 2022-05-16 11:19:33 +02:00
Davide De Rosa 35ec73570e Use NEHotspotNetwork to fetch current SSID
Old method did not work on Catalyst.
2022-05-15 22:24:36 +02:00
Davide De Rosa 9984c56084 Drop unnecessary async from migration code
Providers are not fetched at migration time, they only are after
opening a profile (marked non-ready until then).

Still retain Task for migration to be executed asynchronously.
2022-05-05 11:04:12 +02:00
Davide De Rosa 57f7b15aa2 Reuse base fetch request building code
Set .predicate first for consistency.
2022-05-05 10:58:25 +02:00
Davide De Rosa ae6b5c50d9 Fix duplicated infrastructures/servers
Leftover from some refactoring, was not deleting older
infrastructures before adding a new one.
2022-05-05 10:52:32 +02:00
Davide De Rosa cca2dca047 Export providers database in beta 2022-05-05 09:46:12 +02:00
Davide De Rosa 19886c2314 Drop extra comments 2022-05-04 23:57:45 +02:00
Davide De Rosa bafac12be4 Retain in beta profiles created in production
Drop filter, ability to create profiles in the first place implies
eligibility.
2022-05-04 23:15:12 +02:00
Davide De Rosa c2676cbdf6 Attempt beta release 2022-05-04 19:03:22 +02:00
Davide De Rosa 40a3c67b1c Observe updates AFTER setting active profile
App disconnects VPN on launch otherwise, because active
profile is still nil. Where was the regression introduced?

Also .dropFirst() to skip initial values, but keep in mind that
if VPN is connected and active profile was not properly persisted,
the app will show the VPN as disabled.
2022-05-04 10:34:28 +02:00
Davide De Rosa 56540485cf Fix variable in activeProfileId log message 2022-05-04 09:50:32 +02:00
Davide De Rosa 7ec6ccda6c Improve logic of setting duplicate as current
Back currentProfileId with an internal variable that allows for
more control over navigation.

Can drop pendingProfiles hack.
2022-05-04 09:50:32 +02:00
Davide De Rosa b68fb21652 Fix duplicate on iOS 14
Wrong braces in 4cb18965c9.
2022-05-04 09:12:06 +02:00
Davide De Rosa 4cb18965c9 Set duplicate as current inside ProfileManager
When setting duplicate as current, batch save original profile and
duplicate in a single call via profilesToSave. This is to avoid a
double call to willUpdateProfiles() when saving Core Data context.

In order to set current profile to one that has not been persisted
yet (the duplicate), we need to resort to a pendingProfiles map
where to look the duplicate up when setting currentProfileId.

Either way, iOS 14 cannot handle updating a "hot" change in a
presented NavigationLink. Changing currentProfileId binding while
in ProfileView messes up navigation completely (multiple push and
pop events). Avoid.
2022-05-03 18:35:19 +02:00
Davide De Rosa 943bce5515 Bind navigation to ProfileManager directly
- Do the profile loading inside the model

- Allow setting current profile to a transient profile

- Check .placeholder before saving current profile

XXX: avoid loading active profile on iPad portrait.
2022-05-03 18:35:17 +02:00
Davide De Rosa 7036ca5f41 Fix handling of non-ready profiles
- Omit title while isLoading, to not show former profile name

- Animate on isLoading
2022-05-03 15:54:19 +02:00
Davide De Rosa 93abaf538b Simplify redundant parts of ProfileManager
- Drop overthought activeHeader

- Drop willUpdateCurrentProfile, use observable

- Drop willUpdateActiveId, observe value publisher
2022-05-03 14:36:55 +02:00
Davide De Rosa 20be153b1a Only tweak .isLoading if profile is not ready
Result is sync and immediate otherwise.
2022-05-02 11:17:51 +02:00
Davide De Rosa 7eec20c75b Fix VPN status not restored on app launch
Notifications deemed not relevant because currentBundleIdentifier
not set unless connect/reinstate.

Assume initial relevant identifier to be the first notified.

See 7ba41a0e73
2022-05-01 22:50:40 +02:00
Davide De Rosa 87f2ebfd9e Attempt beta release 2022-05-01 20:44:17 +02:00
Davide De Rosa acbc1980f9 Ignore non-existing active profile 2022-05-01 20:40:20 +02:00
Davide De Rosa 171c1e1dd4 Omit wrapping Section on Mac 2022-05-01 19:30:56 +02:00
Davide De Rosa cfc0d4f572 Restore active profile on top
Flashing on activation was caused by VPNManager.disable() in
ProfileView+VPN, because by setting lastError to nil it would
notify a change to ProfileRow (via VPNStateView) during the
profile row activation animation. That caused the flicker.

Instead, disable VPN first, then start the animation.

Anyway, avoid clearing a nil lastError.
2022-05-01 19:19:43 +02:00
Davide De Rosa edc7cdf045 Merge List into OrganizerView
- Restore wrapping Section as it seems to fix multitasking

- Hide profiles section if empty
2022-05-01 19:19:31 +02:00
Davide De Rosa 8003b4a92d Observe currentProfile in ProfileView
ProfileView is not interested in changes in other profiles
notified by ProfileManager. Set isLoading inside
ObservableObject for observable to be self-contained.

Loses observation of profile deletion, but dismiss on removal is
actually handled by OrganizerView, not ProfileView.

Also drop unused presentationMode.
2022-05-01 19:14:34 +02:00
Davide De Rosa 7ba41a0e73 Skip irrelevant notifications for VPN protocol
Based on tunnel bundle identifier in notification.
2022-04-29 15:26:10 +02:00
Davide De Rosa 17198e53eb Fix cannot duplicate same profile more than once 2022-04-29 00:40:56 +02:00
Davide De Rosa 1afd227f02 Do not update current profile on activation 2022-04-28 22:36:31 +02:00
Davide De Rosa 2c2e794b00 Revert async loadCurrentProfile()
Make action sync, but internally async (makeProfileReady). If not
doing so, UI on launch will not be able to show active profile
immediately. WelcomeView would appear for a moment.

Observe isReloadingCurrentProfile.

See 2b1efb8fec
2022-04-28 19:00:36 +02:00
Davide De Rosa 1ef2b8c7a7 Set activeProfileId immediately
Otherwise on app launch, active profile is rendered in 2 steps.
2022-04-28 17:56:28 +02:00
Davide De Rosa 56fa161e92 Save current profile one way
Skip updating currentProfile.value when intentionally saving
current profile.
2022-04-28 17:56:28 +02:00
Davide De Rosa 2b1efb8fec Make load*Profile() async
- Handle Task in consumers

- Drop makeReady, always make loaded profile ready

- Rename misleading loadProfile() to profileEx()
2022-04-27 17:13:03 +02:00
Davide De Rosa 02b2e3194e Add duplicate to profile menu
Contextually switch current profile to duplicate.
2022-04-27 16:59:33 +02:00
Davide De Rosa 49a1f1b55c Address VPN toggle losing sync with internal state
- Update TunnelKit

- Receive TunnelKit notifications on main queue

- Bind VPN toggle to VPNManager directly (implicit animations)

- Update state on VPN didFail

- Set isEnabled = false after uninstalling VPN (not notified)
2022-04-27 15:53:31 +02:00
Davide De Rosa 03fdab4833 Duplicate profile from context menu 2022-04-26 22:39:47 +02:00
Davide De Rosa e10f33717d Test update/delete on merge provider index 2022-04-26 18:56:55 +02:00
Davide De Rosa 259a7e18ca Fix old provider server query parameter
serverId was renamed to apiId.
2022-04-26 18:49:34 +02:00
Davide De Rosa ccde6a30cf Fix issues with VPN toggle
- Move rate limit to UI only

- Keep caption constant to "Enabled"
2022-04-25 23:12:45 +02:00
Davide De Rosa 92b9c4cd9a Skip setting data count if unavailable 2022-04-25 22:59:20 +02:00
Davide De Rosa 10537c5a29 Fix active profile not always cleared on deletion
Was only cleared if deleted profile was current profile.
2022-04-23 10:25:31 +02:00
Davide De Rosa 8f4e4bc7c5 Skip redundant updates of current profile 2022-04-23 10:25:31 +02:00