Commit Graph

529 Commits

Author SHA1 Message Date
Eric Kuck
42aeb8636c More formatting nits and cyclomatic complexity fixes 2018-12-12 21:09:52 -06:00
Eric Kuck
965f66e5e2 More linter warnings fixed, enabled more swiftlint rules, project cleanup 2018-12-12 15:33:14 -06:00
Eric Kuck
ea29a0c7d1 Tons more swiftlint warnings fixed. Still a few remaining. 2018-12-12 12:28:27 -06:00
Eric Kuck
fa558a4019 Added swiftlint and fixed all errors (and a bunch, but not all, warnings) 2018-12-12 11:40:57 -06:00
Roopesh Chander
a57bb02482 Zip importing: importFromFile should take a completionHandler
Deletion of the being-imported file should be done in the
completionHandler.
2018-12-12 19:24:18 +05:30
Roopesh Chander
60faeea341 ErrorPresenter: Support onPresented for showErrorAlert(title:,message:) 2018-12-12 19:17:06 +05:30
Roopesh Chander
964dd8f723 Zip importing: Handle spaces in filenames correctly
Previously, if a filename of a .conf file inside the zip file
contained spaces, it was not imported.
2018-12-12 16:57:17 +05:30
Jason A. Donenfeld
440073ad9a Supply missing pieces of path change 2018-12-12 01:11:43 +01:00
Eric Kuck
14091de6b6 Fixed a potential race condition, better naming on PacketTunnelSettingsGenerator methods 2018-12-11 16:59:15 -06:00
Eric Kuck
7d387da741 Added an (unfinished) NWPathMonitor implementation for reconnecting on network changes 2018-12-11 16:12:04 -06:00
Roopesh Chander
4e70455800 State restoration: Don't create duplicate mainVC and tunnelsListVC
This creates a duplicate tunnels manager, leading to problems tracking
tunnel statuses.

To reproduce the bug that this commit fixes, you can do the following:
 1. Remove all tunnels
 2. Run in Xcode
 3. Import zip with ~10 tunnels
 4. Stop app in Xcode
 5. Run in Xcode
 6. Turn on 1st tunnel, after it's on, turn off
    Turn on 2nd tunnel, after it's on, turn off
    ...
    After 6-8 tunnels, the spinner doesn't show up, indicating that the
    status is not being tracked.
2018-12-11 17:52:54 +05:30
Roopesh Chander
4d6a21f14e TunnelsManager: Error out only on no-internet scenario
The other scenario happens even during reloading of a tunnel for activation.
2018-12-11 03:48:28 +05:30
Roopesh Chander
0c913d0dbc Remove the feature of waiting for another tunnel to deactivate 2018-12-11 03:47:23 +05:30
Roopesh Chander
39ac53d853 TunnelsManager: Deactivate only when the status becomes 'connected' 2018-12-11 02:42:21 +05:30
Roopesh Chander
56730ef048 Allow turning off the status switch of a waiting tunnel
It just means the waiting should be cancelled
2018-12-11 02:01:54 +05:30
Roopesh Chander
9906689122 TunnelsManager: Handle status change in TunnelsManager
Rather than in TunnelContainer.
2018-12-11 02:01:49 +05:30
Roopesh Chander
305264d064 Error handling: alertText() can be nil
Indicating that no alert is to be shown for that error.
2018-12-11 00:34:22 +05:30
Roopesh Chander
d3ba76def3 TunnelsManager: Don't act on status change on tunnelProviders we don't have
That causes errors we don't want, and duplicate notifications.
2018-12-10 17:03:23 +05:30
Roopesh Chander
94b81fc577 TunnelsManager: Always call the completion handler before returning 2018-12-10 17:01:53 +05:30
Roopesh Chander
0472527617 TunnelsManager: Debugging helpers for tunnel status 2018-12-10 16:31:36 +05:30
Roopesh Chander
66bb9c94d4 TunnelsManager: Handle deactivation of a waiting tunnel 2018-12-10 16:28:41 +05:30
Roopesh Chander
42729a0fe7 Tunnels list: Fix AutoLayout error during deletion of a tunnel 2018-12-10 12:59:31 +05:30
Roopesh Chander
c375d01199 Settings: Dynamic Type support 2018-12-10 01:45:34 +05:30
Roopesh Chander
9bdfabee6a Tunnel edit: Dynamic Type support 2018-12-10 01:45:34 +05:30
Roopesh Chander
3e27a9ddb0 Tunnel detail: Dynamic Type support 2018-12-10 01:45:34 +05:30
Roopesh Chander
527c1fcb37 Tunnels list: Dynamic Type support for the add button at the center 2018-12-09 18:13:37 +05:30
Roopesh Chander
3a7dbc6e37 Tunnels list: Dynamic Type support for the table view 2018-12-09 18:13:04 +05:30
Roopesh Chander
af018988b4 Model: Declare keyLength constant and use that wherever applicable 2018-12-09 14:07:03 +05:30
Roopesh Chander
34a21098fc TunnelsManager: Observe status for all tunnels in one block 2018-12-08 18:43:24 +05:30
Roopesh Chander
d7762f5055 TunnelsManager: Remove unused variables 2018-12-08 15:00:26 +05:30
Roopesh Chander
ada1b659a8 Zip: Fix comment 2018-12-08 13:43:00 +05:30
Jason A. Donenfeld
01ec87ddee Version bump 2018-12-07 23:58:53 +01:00
Jason A. Donenfeld
9992322186 PacketTunnelProvider: Show log timestamp 2018-12-07 23:56:26 +01:00
Roopesh Chander
2e5d467bc7 Zip: Increase size of buffer used to read data from the archive 2018-12-08 02:17:55 +05:30
Roopesh Chander
aa915fc54c Settings: Export log: Perform file operations in a background thread 2018-12-08 02:17:55 +05:30
Roopesh Chander
3af543a352 On-Demand: TunnelViewModel: Make activate-on-demand methods static 2018-12-08 02:17:23 +05:30
Roopesh Chander
4f98330bc0 On-Demand: Move detail text to TunnelViewModel 2018-12-08 02:17:15 +05:30
Jason A. Donenfeld
8227e77111 Plist: Handle crypto export 2018-12-07 18:52:14 +01:00
Jason A. Donenfeld
f8f922eda9 Make strings consistent 2018-12-07 18:52:14 +01:00
Roopesh Chander
880ea9237e State restoration: Restore tunnel detail view 2018-12-07 19:05:08 +05:30
Roopesh Chander
059fc77c61 Main VC: No need to refresh statuses if the tunnelsManager isn't initialized yet 2018-12-07 15:52:47 +05:30
Roopesh Chander
800cb8559e Tunnels list: Deselect rows correctly
Do it like UITableViewController.clearsSelectionOnViewWillAppear would.
2018-12-07 12:36:23 +05:30
Roopesh Chander
c3a3effd82 Settings: Exporting configs as zip should open document picker
Because:
 - Exporting UI should be consistent with importing UI
 - UIActivityVC takes a long time to open
2018-12-07 12:36:19 +05:30
Roopesh Chander
24de510ea6 Error handling: Use ErrorPresenter.showErrorAlert() instead of per-VC showErrorAlert() methods 2018-12-07 12:36:19 +05:30
Roopesh Chander
cc39342e6e Error handling: Use WireGuardAppError and WireGuardResult throughout the app 2018-12-07 12:36:19 +05:30
Roopesh Chander
8d58a79272 Error handling: Introduce a WireGuardResult type to handle errors in callbacks across the app 2018-12-07 12:36:19 +05:30
Roopesh Chander
5aee6f5753 Error handling: Introduce a WireGuardAppError protocol to manage errors
The alert strings shall be located next to where the errors are declared.
2018-12-07 12:36:19 +05:30
Roopesh Chander
80dcd2bd77 Error handling: Cleanup Tunnels Manager errors 2018-12-07 12:36:19 +05:30
Roopesh Chander
5ed47c5898 Error presenter: Always handle the passed error 2018-12-07 12:36:19 +05:30
Roopesh Chander
6cb5719d4e Tunnel detail: Cell status switch should be toggled only after the alert presentation completes 2018-12-07 12:36:19 +05:30
Roopesh Chander
205585c5d4 Refactoring: Consolidate file deletion into a separate function 2018-12-07 12:36:19 +05:30
Roopesh Chander
5764fa4930 NE: Logging: Log file should begin with version numbers and tunnel name 2018-12-07 12:36:19 +05:30
Roopesh Chander
07fbb7c4ad NE: Logging: Make it clear which calls to wg_log use String and which use StaticString 2018-12-04 15:58:53 +05:30
Roopesh Chander
fe3722fada Settings: Add timestamp to exported log
And remove the exported log afterwards.
2018-12-04 14:12:53 +05:30
Roopesh Chander
400288b02a Refactor out VPN-handling stuff from tunnels list VC to the main VC 2018-12-03 18:51:51 +05:30
Roopesh Chander
981b86d357 VPN: Error out when tunnel activation fails because there's no internet 2018-12-03 18:51:42 +05:30
Roopesh Chander
a1aa13d553 Settings: Export log file 2018-12-02 13:26:53 +05:30
Roopesh Chander
67268a0ce5 NE: Write log to file 2018-11-30 00:36:33 +05:30
Roopesh Chander
64175071fa Info.plist: Add app group id for accessing from both the app and the network extension 2018-11-29 14:05:27 +05:30
Roopesh Chander
41aca352a7 Xcode: Add app groups capability 2018-11-29 12:01:45 +05:30
Roopesh Chander
5f6cd9d8b6 It's 'WiFi', not 'Wifi' 2018-11-28 12:41:35 +05:30
Roopesh Chander
ff64ef79f1 NE: All DNS queries must first go through the VPN's DNS servers 2018-11-23 13:04:55 +05:30
Roopesh Chander
af49397caa Tunnel view model: Invalidate the configuration object when updating allowedIPs using the 'Exclude private IPs' switch 2018-11-19 15:22:27 +05:30
Roopesh Chander
643e988f74 Config file parser: Be case-insensitive to attribute keys in the config file 2018-11-19 12:37:54 +05:30
Roopesh Chander
ccd8e784f3 Config file parser: Fix typo 2018-11-17 22:52:37 +05:30
Roopesh Chander
b5689edf71 Exporting: Export to zip in a background thread 2018-11-15 13:39:56 +05:30
Roopesh Chander
6857a579b3 Exporting: Refactor out zip exporting into a separate class 2018-11-15 13:39:56 +05:30
Roopesh Chander
7f2772473e Exporting: No need to check for duplicate names - we disallow it at creation time itself 2018-11-15 13:39:56 +05:30
Roopesh Chander
1a419526e7 Importing: Import from zip in a background thread 2018-11-15 13:39:56 +05:30
Roopesh Chander
b2b2818e2e Importing: Refactor out zip importing into a separate class 2018-11-14 18:52:10 +05:30
Roopesh Chander
ed1bae8ad0 Tunnels manager: After saving after activating on-demand, reload tunnel 2018-11-14 13:02:53 +05:30
Roopesh Chander
6da2b4d0be Tunnels manager: Need to keep VPN-on-demand tunnels's status under observation
Because they can turn on automatically, even while the app is in the foreground.
2018-11-12 19:24:13 +05:30
Roopesh Chander
8385e8d19e Tunnel detail: Show VPN-on-demand information 2018-11-12 19:24:13 +05:30
Roopesh Chander
dc19529f10 Tunnels manager: Keep track of NETunnelProviderManager's isOnDemandEnabled property 2018-11-12 19:24:13 +05:30
Roopesh Chander
e708e26a00 Tunnel edit: Update for VPN-on-demand changes 2018-11-12 19:24:13 +05:30
Roopesh Chander
1caa186ebc Tunnel view model: VPN-on-demand stuff shouldn't be part of the tunnel model 2018-11-12 19:24:13 +05:30
Roopesh Chander
c0eb34c755 Model, Tunnels manager: Rewrite the model for VPN-on-demand
The VPN-on-demand settings should not be part of the tunnel
configuration. Rather, the onDemandRules stored in the
tunnel provider configuration serve as the one place
where the VPN-on-demand settings are stored.
2018-11-12 19:24:13 +05:30
Roopesh Chander
b09f3e3992 TunnelsManager: Support for on-demand rules 2018-11-11 01:31:38 +05:30
Roopesh Chander
151ad9de84 Tunnel edit, Tunnel view model: UI for providing On-Demand activation options 2018-11-11 01:18:36 +05:30
Roopesh Chander
049e9f0b05 Model: Add activationType to tunnel configuration
We make sure existing tunnel serializations can be deserialized correctly.

We also bump up the tunnelConfigurationVersion, because the tunnel
configuration contents have changed.
2018-11-11 01:17:36 +05:30
Roopesh Chander
75474acb59 Model: ActivityType enum to represent VPN-on-demand options 2018-11-10 19:17:24 +05:30
Roopesh Chander
ae627c5e5d Model: TunnelConfiguration: Add explicit conformance to Decodable 2018-11-10 19:01:34 +05:30
Roopesh Chander
0db19f187b Model: Ensure that a TunnelConfiguration always has a valid array of peers 2018-11-10 17:02:30 +05:30
Roopesh Chander
e974b7df23 VPN: When activating while another tunnel is active, deactivate the other tunnel 2018-11-10 16:44:28 +05:30
Roopesh Chander
e6917a6075 TunnelsManager: startDeactivation() need not take a completion handler
Because the completion handler pattern doesn't fit in this case.
2018-11-10 16:44:28 +05:30
Roopesh Chander
97d8570d99 VPN: There are no DNS errors to handle in the app now 2018-11-10 16:44:28 +05:30
Roopesh Chander
6d28240531 NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration 2018-11-09 22:29:52 +05:30
Roopesh Chander
9568c7f980 VPN: Refresh tunnel statuses when app gets to the foreground
Because the tunnel could've be activated from iOS Settings now
2018-11-09 19:29:34 +05:30
Roopesh Chander
fc93ca65a5 Remove unused code 2018-11-09 19:20:33 +05:30
Roopesh Chander
fefa39de46 TunnelsManager: Ability to refresh connection statuses 2018-11-09 19:19:32 +05:30
Roopesh Chander
c9c58f3755 NE: When there's an error starting the tunnel, show it to the user using displayMessage() 2018-11-09 17:07:42 +05:30
Roopesh Chander
fffaba451a Remove unused file PacketTunnelOptionKey.swift 2018-11-08 18:59:16 +05:30
Roopesh Chander
c0f9c01fb9 Move logic to extension: Bring up the tunnel from the stored providerConfiguration 2018-11-08 18:59:16 +05:30
Roopesh Chander
df7197473e DNSResolver: Simplify 2018-11-08 17:52:11 +05:30
Roopesh Chander
40ce2604ea DNSResolver: Let's not cache DNS resolution results anymore 2018-11-08 17:52:11 +05:30
Roopesh Chander
7bde4a6300 DNSResolver: DNS resolution can now happen synchronously 2018-11-08 17:52:11 +05:30
Roopesh Chander
8f35d70482 Model: Endpoint.hostname() 2018-11-08 17:52:11 +05:30
Roopesh Chander
e83af4bce5 Move logic to extension: NETunnelProviderProtocol extension code should be shared 2018-11-08 17:52:01 +05:30
Roopesh Chander
80e563406b Move logic to extension: Refactor PacketTunnelOptionsGenerator into a PacketTunnelSettingsGenerator 2018-11-08 15:44:13 +05:30
Roopesh Chander
13eebb2e64 Move logic to extension: Move DNSResolver to extension 2018-11-08 15:09:45 +05:30