Commit Graph

648 Commits

Author SHA1 Message Date
Roopesh Chander 33af8845b6 TunnelsManager: Remove assert
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 23:43:15 +05:30
Jason A. Donenfeld 154774ada2 Simplify C strings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-13 19:08:38 +01:00
Roopesh Chander 3bddab8a9e TunnelsManager: Fix race between multiple startActivation() calls
After startActivate() is called on a waiting tunnel, user might turn
on a different tunnel before the waiting tunnel's status gets updated.
This fix prevents that from happening.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 23:34:00 +05:30
Roopesh Chander f9239dae75 TunnelsManager: Reintroduce waiting for another tunnel to deactivate
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 23:21:49 +05:30
Jason A. Donenfeld 642b627d27 Rewrite Logger
This reverts all of Roop's changes to the C code, and then rewrites the
logger logic to be cleaner.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-13 18:06:37 +01:00
Eric Kuck 38accad27d More reliable logo sizing
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-13 09:30:13 -06:00
Roopesh Chander bf58159d99 TunnelsManager: Report activation errors through the activationDelegate
Don't report activation errors through completion handlers

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 18:56:07 +05:30
Roopesh Chander efd4b28a0d Logging: Write versions from both app and extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 18:09:38 +05:30
Roopesh Chander ae565db371 Logging: file_log doesn't need the message type
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 18:06:57 +05:30
Roopesh Chander e199ed0d6c Logging: Tag the entries in the merged log
So we know which entry is from the app and which is from the network
extension.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 18:00:32 +05:30
Roopesh Chander ba1d0c05be Logging: Use ringlogger for logging from the app
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 17:37:20 +05:30
Roopesh Chander 12503ae51d Logging: ringlogger.c: Trim trailing newlines
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 17:37:14 +05:30
Roopesh Chander ae7fb7323f Logging: Use ringlogger for logging from the extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 17:37:14 +05:30
Roopesh Chander 5ae9eec555 Avoid using 'VPN' in code where possible
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 12:20:10 +05:30
Roopesh Chander 6528a581de mv WireGuard/WireGuard/VPN/ WireGuard/WireGuard/Tunnel/
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-13 12:14:21 +05:30
Jason A. Donenfeld e11224f394 Commit untested ringlogger code
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-13 06:14:24 +01:00
Jason A. Donenfeld 5971c197bd Remove useless whitespace
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-13 05:26:04 +01:00
Jason A. Donenfeld ecbab37e0e Settings: better padding calculation
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-13 05:22:13 +01:00
Eric Kuck 4eec53d6d3 Fixed hacky logo display for settings
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-12 21:16:28 -06:00
Eric Kuck 8a916beb38 More formatting nits and cyclomatic complexity fixes
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-12 21:09:52 -06:00
Eric Kuck e4ac48bc75 More linter warnings fixed, enabled more swiftlint rules, project cleanup
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-12 15:33:14 -06:00
Eric Kuck d06cff2a36 Tons more swiftlint warnings fixed. Still a few remaining.
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-12 12:28:27 -06:00
Eric Kuck de14b76b4d Added swiftlint and fixed all errors (and a bunch, but not all, warnings)
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-12 11:40:57 -06:00
Roopesh Chander af78fa9a1c Zip importing: importFromFile should take a completionHandler
Deletion of the being-imported file should be done in the
completionHandler.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-12 19:24:18 +05:30
Roopesh Chander 7ef12d93a7 ErrorPresenter: Support onPresented for showErrorAlert(title:,message:)
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-12 19:17:06 +05:30
Roopesh Chander 8259145f85 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.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-12 16:57:17 +05:30
Jason A. Donenfeld 034a1a12f7 Supply missing pieces of path change
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-12 01:11:43 +01:00
Eric Kuck 9bc7e58487 Fixed a potential race condition, better naming on PacketTunnelSettingsGenerator methods
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-11 16:59:15 -06:00
Eric Kuck 27265fc222 Added an (unfinished) NWPathMonitor implementation for reconnecting on network changes
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-12-11 16:12:04 -06:00
Roopesh Chander bde984625c 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.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 17:52:54 +05:30
Roopesh Chander 1ded24f0e0 TunnelsManager: Error out only on no-internet scenario
The other scenario happens even during reloading of a tunnel for activation.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 03:48:28 +05:30
Roopesh Chander 1fd0c56f08 Remove the feature of waiting for another tunnel to deactivate
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 03:47:23 +05:30
Roopesh Chander e59dbe6364 TunnelsManager: Deactivate only when the status becomes 'connected'
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 02:42:21 +05:30
Roopesh Chander 4d63a3e9bd Allow turning off the status switch of a waiting tunnel
It just means the waiting should be cancelled

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 02:01:54 +05:30
Roopesh Chander 9946d8f989 TunnelsManager: Handle status change in TunnelsManager
Rather than in TunnelContainer.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 02:01:49 +05:30
Roopesh Chander 15b6cf5412 Error handling: alertText() can be nil
Indicating that no alert is to be shown for that error.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-11 00:34:22 +05:30
Roopesh Chander 851bd8102d TunnelsManager: Don't act on status change on tunnelProviders we don't have
That causes errors we don't want, and duplicate notifications.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 17:03:23 +05:30
Roopesh Chander 0d7a585bf7 TunnelsManager: Always call the completion handler before returning
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 17:01:53 +05:30
Roopesh Chander 663bb02c68 TunnelsManager: Debugging helpers for tunnel status
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 16:31:36 +05:30
Roopesh Chander b491b9c371 TunnelsManager: Handle deactivation of a waiting tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 16:28:41 +05:30
Roopesh Chander 707f292e4e Tunnels list: Fix AutoLayout error during deletion of a tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 12:59:31 +05:30
Roopesh Chander aa41bd7d6c Settings: Dynamic Type support
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 01:45:34 +05:30
Roopesh Chander ec5be76d06 Tunnel edit: Dynamic Type support
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 01:45:34 +05:30
Roopesh Chander 692b0c6519 Tunnel detail: Dynamic Type support
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-10 01:45:34 +05:30
Roopesh Chander bb836b8fdc Tunnels list: Dynamic Type support for the add button at the center
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-09 18:13:37 +05:30
Roopesh Chander 8eda4641ca Tunnels list: Dynamic Type support for the table view
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-09 18:13:04 +05:30
Roopesh Chander 60e13ddbf6 Model: Declare keyLength constant and use that wherever applicable
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-09 14:07:03 +05:30
Roopesh Chander 0dcb285b67 TunnelsManager: Observe status for all tunnels in one block
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 18:43:24 +05:30
Roopesh Chander 6838dc3a74 TunnelsManager: Remove unused variables
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 15:00:26 +05:30
Roopesh Chander 46f4be6087 Zip: Fix comment
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 13:43:00 +05:30
Jason A. Donenfeld 2fa2f58aad Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-07 23:58:53 +01:00
Jason A. Donenfeld 1eddb2c86d PacketTunnelProvider: Show log timestamp
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-07 23:56:26 +01:00
Roopesh Chander aa0b288436 Zip: Increase size of buffer used to read data from the archive
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 02:17:55 +05:30
Roopesh Chander 71568d1899 Settings: Export log: Perform file operations in a background thread
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 02:17:55 +05:30
Roopesh Chander 06a783f50a On-Demand: TunnelViewModel: Make activate-on-demand methods static
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 02:17:23 +05:30
Roopesh Chander 465c22f769 On-Demand: Move detail text to TunnelViewModel
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-08 02:17:15 +05:30
Jason A. Donenfeld b7e5638681 Plist: Handle crypto export
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-07 18:52:14 +01:00
Jason A. Donenfeld 66b4aedd08 Make strings consistent
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-12-07 18:52:14 +01:00
Roopesh Chander 105eca7adc State restoration: Restore tunnel detail view
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 19:05:08 +05:30
Roopesh Chander e3801308cb Main VC: No need to refresh statuses if the tunnelsManager isn't initialized yet
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 15:52:47 +05:30
Roopesh Chander 05d0429c50 Tunnels list: Deselect rows correctly
Do it like UITableViewController.clearsSelectionOnViewWillAppear would.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:23 +05:30
Roopesh Chander fa9a4921a8 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

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander c827a00307 Error handling: Use ErrorPresenter.showErrorAlert() instead of per-VC showErrorAlert() methods
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander dcfa9473e9 Error handling: Use WireGuardAppError and WireGuardResult throughout the app
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander 782dd2ea4e Error handling: Introduce a WireGuardResult type to handle errors in callbacks across the app
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander c9267ba634 Error handling: Introduce a WireGuardAppError protocol to manage errors
The alert strings shall be located next to where the errors are declared.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander 8d26a3c536 Error handling: Cleanup Tunnels Manager errors
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander 7631844fbe Error presenter: Always handle the passed error
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander 046b540e53 Tunnel detail: Cell status switch should be toggled only after the alert presentation completes
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander f6faffa4c1 Refactoring: Consolidate file deletion into a separate function
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander 290bd192a0 NE: Logging: Log file should begin with version numbers and tunnel name
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-07 12:36:19 +05:30
Roopesh Chander bf86731879 NE: Logging: Make it clear which calls to wg_log use String and which use StaticString
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-04 15:58:53 +05:30
Roopesh Chander 4e386e85e4 Settings: Add timestamp to exported log
And remove the exported log afterwards.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-04 14:12:53 +05:30
Roopesh Chander 046d1413ec Refactor out VPN-handling stuff from tunnels list VC to the main VC
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-03 18:51:51 +05:30
Roopesh Chander e1b258353c VPN: Error out when tunnel activation fails because there's no internet
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-03 18:51:42 +05:30
Roopesh Chander cdd132d7d0 Settings: Export log file
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-12-02 13:26:53 +05:30
Roopesh Chander 679d63294d NE: Write log to file
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-30 00:36:33 +05:30
Roopesh Chander d01d46fde8 Info.plist: Add app group id for accessing from both the app and the network extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-29 14:05:27 +05:30
Roopesh Chander a3bc306b6e Xcode: Add app groups capability
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-29 12:01:45 +05:30
Roopesh Chander 3e1772ccd0 It's 'WiFi', not 'Wifi'
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-28 12:41:35 +05:30
Roopesh Chander b946cbc0f3 NE: All DNS queries must first go through the VPN's DNS servers
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-23 13:04:55 +05:30
Roopesh Chander 8590a8804a Tunnel view model: Invalidate the configuration object when updating allowedIPs using the 'Exclude private IPs' switch
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-19 15:22:27 +05:30
Roopesh Chander a117e3ae3e Config file parser: Be case-insensitive to attribute keys in the config file
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-19 12:37:54 +05:30
Roopesh Chander ef2012330f Config file parser: Fix typo
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-17 22:52:37 +05:30
Roopesh Chander 6bb25782c1 Exporting: Export to zip in a background thread
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-15 13:39:56 +05:30
Roopesh Chander 1dac181803 Exporting: Refactor out zip exporting into a separate class
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-15 13:39:56 +05:30
Roopesh Chander d556729705 Exporting: No need to check for duplicate names - we disallow it at creation time itself
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-15 13:39:56 +05:30
Roopesh Chander b1ae13652c Importing: Import from zip in a background thread
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-15 13:39:56 +05:30
Roopesh Chander 203d6b4596 Importing: Refactor out zip importing into a separate class
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-14 18:52:10 +05:30
Roopesh Chander 2676ee0169 Tunnels manager: After saving after activating on-demand, reload tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-14 13:02:53 +05:30
Roopesh Chander c60c29b93c 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.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander bdb2411ebc Tunnel detail: Show VPN-on-demand information
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander 923d039a78 Tunnels manager: Keep track of NETunnelProviderManager's isOnDemandEnabled property
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander abb0312d38 Tunnel edit: Update for VPN-on-demand changes
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander f1b8de7312 Tunnel view model: VPN-on-demand stuff shouldn't be part of the tunnel model
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander cc122d7463 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.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-12 19:24:13 +05:30
Roopesh Chander 39a067cb96 TunnelsManager: Support for on-demand rules
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-11 01:31:38 +05:30
Roopesh Chander c5e8b05e8b Tunnel edit, Tunnel view model: UI for providing On-Demand activation options
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-11 01:18:36 +05:30
Roopesh Chander 4b7094d652 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.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-11 01:17:36 +05:30
Roopesh Chander 0f03ffc920 Model: ActivityType enum to represent VPN-on-demand options
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 19:17:24 +05:30
Roopesh Chander 1502bd42d3 Model: TunnelConfiguration: Add explicit conformance to Decodable
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 19:01:34 +05:30
Roopesh Chander 290f83d5ef Model: Ensure that a TunnelConfiguration always has a valid array of peers
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 17:02:30 +05:30
Roopesh Chander e8d68396ca VPN: When activating while another tunnel is active, deactivate the other tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 16:44:28 +05:30
Roopesh Chander 8e7bfb15ed TunnelsManager: startDeactivation() need not take a completion handler
Because the completion handler pattern doesn't fit in this case.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 16:44:28 +05:30
Roopesh Chander 95456ec956 VPN: There are no DNS errors to handle in the app now
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-10 16:44:28 +05:30
Roopesh Chander 7485474c4c NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-09 22:29:52 +05:30
Roopesh Chander 1d63509b92 VPN: Refresh tunnel statuses when app gets to the foreground
Because the tunnel could've be activated from iOS Settings now

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-09 19:29:34 +05:30
Roopesh Chander f3e32ab737 Remove unused code
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-09 19:20:33 +05:30
Roopesh Chander 59b9a6e5d2 TunnelsManager: Ability to refresh connection statuses
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-09 19:19:32 +05:30
Roopesh Chander 3136fe0e2c NE: When there's an error starting the tunnel, show it to the user using displayMessage()
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-09 17:07:42 +05:30
Roopesh Chander a1070d2b29 Remove unused file PacketTunnelOptionKey.swift
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 18:59:16 +05:30
Roopesh Chander 5ee4d392b5 Move logic to extension: Bring up the tunnel from the stored providerConfiguration
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 18:59:16 +05:30
Roopesh Chander c17e4a27a2 DNSResolver: Simplify
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 17:52:11 +05:30
Roopesh Chander 8409b7e929 DNSResolver: Let's not cache DNS resolution results anymore
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 17:52:11 +05:30
Roopesh Chander 651ffa0c51 DNSResolver: DNS resolution can now happen synchronously
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 17:52:11 +05:30
Roopesh Chander 4404bb2b7d Model: Endpoint.hostname()
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 17:52:11 +05:30
Roopesh Chander e66cf5264a Move logic to extension: NETunnelProviderProtocol extension code should be shared
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 17:52:01 +05:30
Roopesh Chander af58bfcb00 Move logic to extension: Refactor PacketTunnelOptionsGenerator into a PacketTunnelSettingsGenerator
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 15:44:13 +05:30
Roopesh Chander 2f7e437202 Move logic to extension: Move DNSResolver to extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 15:09:45 +05:30
Roopesh Chander 62573e2ad7 Move logic to extension: .resolvingEndpointDomains is not longer a valid status
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 15:08:57 +05:30
Roopesh Chander a5f9dc4821 Move logic to extension: DNS resolution no longer happens in the app
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 15:04:12 +05:30
Roopesh Chander 7827147bc8 Move logic to extension: Include shared model code when building the extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 14:50:05 +05:30
Roopesh Chander a473dfe4f8 Model: Move InterfaceConfiguration.publicKey to Curve25519.swift
The code for public key calculation need not be shared with the extension

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 14:48:25 +05:30
Roopesh Chander fb6a7f6007 Move logic to extension: Move PacketTunnelOptionsGenerator to the extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 14:16:30 +05:30
Roopesh Chander f7b04b0b5d Move logic to extension: Invoke startTunnel() without any options
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 14:15:01 +05:30
Roopesh Chander c88c660b51 Move logic to extension: Move model files to Shared
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 13:56:50 +05:30
Roopesh Chander ec2d67ea00 Tunnel edit: While preparing for reuse, should make onValueBeingEdited nil as well
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-08 12:25:36 +05:30
Jason A. Donenfeld 9840e94c84 Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-07 17:43:50 +01:00
Roopesh Chander 85a19da487 iPad: Ensure we set sourceRect for all cases where we use sourceView
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 17:43:30 +01:00
Roopesh Chander b5447add1e Info.plist: Register for handling public.text files for Open-in
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 17:43:30 +01:00
Roopesh Chander 879e9816aa Importing: Also support importing public.text files in the file picker
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 17:43:30 +01:00
Roopesh Chander 3269bb476a iPad: Set correct sourceRect for the popover anchored on the central 'Add' button
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 18:23:12 +05:30
Roopesh Chander b3515c937e TunnelsManager: Return a manager with no tunnels in the simulator
To be able to run at least parts of the app in the simulator.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 18:15:20 +05:30
Roopesh Chander 7e9ee913c1 iPad: Configuring the split-view controller should happen in init(), not loadView()
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 15:54:30 +05:30
Jason A. Donenfeld d0ec532bd3 Settings: show build id
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-07 05:45:39 +01:00
Jason A. Donenfeld c5c536318f Version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 20:18:11 +01:00
Jason A. Donenfeld 6e36c72f96 Importing: simplify
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 20:16:40 +01:00
Roopesh Chander f9dcfc1b9d Importing: Assume imported files without .conf or .zip extensions to be a config file
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-07 00:35:37 +05:30
Roopesh Chander 33edfd3587 DNSResolver: No need to resolve if the endpoint is already an IP address
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 23:59:48 +05:30
Roopesh Chander aa0b6e0c60 Model: Endpoint.hasHostAsIPAddress()
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 23:59:48 +05:30
Jason A. Donenfeld e992030569 PacketTunnelProvider: modernize header
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 19:04:53 +01:00
Roopesh Chander f6a5dfead4 Global: swiftlint autocorrect --format
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 22:42:53 +05:30
Roopesh Chander 0f4b1c5c1c Global: swiftlint autocorrect
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 22:42:05 +05:30
Roopesh Chander 3496adca86 Importing: Error out on file with unsupported file extension
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 22:32:33 +05:30
Jason A. Donenfeld 0a55a284d5 wireguard-go-bridge: take fd instead of fnptr
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 16:27:25 +01:00
Jason A. Donenfeld 02c31c89f6 Xcode: enable more warnings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-06 16:27:25 +01:00
Roopesh Chander 95a4419b20 Tunnel edit: TunnelEditTableViewKeyValueCell need not support a read-only mode now
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 19:01:13 +05:30
Roopesh Chander 6c9fc8bcb1 Tunnel edit: A new cell class for the public key field, to make the value scrollable
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 17:05:03 +05:30
Roopesh Chander 1a43ad6e39 Tunnel detail: Refactor out the label scrolling into a separate UI class
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 16:49:09 +05:30
Roopesh Chander a62f7fb988 Tunnel view model: Peers in a configuation may not share the same public key
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 08:17:56 +05:30
Roopesh Chander 636aa98b79 Parser: Peers in a configuation may not share the same public key
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-06 08:17:56 +05:30
Jason A. Donenfeld 24575a5cf9 Version bump
We update the build number, not the version number, so that test flight
doesn't need a new review.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-05 21:44:00 +01:00
Roopesh Chander 34a8d70a45 Parser: Address, DNS and AllowedIPs can have mutliple entries
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-05 23:53:00 +05:30
Roopesh Chander 733c29021e QR Code: Dismiss the QR code screen when the name prompt is cancelled
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-05 23:38:41 +05:30
Roopesh Chander f102051e22 Tunnel view model: No need to save if we already have a validated configuration object
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-05 22:55:09 +05:30
Jason A. Donenfeld e228ac9d99 global: convert to Swift 4.2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-05 06:31:25 +01:00
Jason A. Donenfeld 8860abc89e TunnelsManager: account for no or many endpoints
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-05 06:23:26 +01:00
Jason A. Donenfeld a08a9ba4c4 PacketTunnelProvider: clamp v6 addresses to /120
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-05 03:11:11 +01:00
Jason A. Donenfeld 8ec38e1d2b Settings: account for bottom padding on iPhone X
Reported-by: Jeffrey A. Donenfeld <jad@runblue.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-05 02:09:40 +01:00
Jason A. Donenfeld 4bd1ea63c6 XCode: use old network extension ID
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-04 05:42:25 +01:00
Jason A. Donenfeld 6c40479863 XCode: unify version strings
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-04 03:51:50 +01:00
Jason A. Donenfeld 897c873296 Settings: anchor logo to bottom
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-04 03:37:18 +01:00
Roopesh Chander 6d191665a4 Add a correct launch-screen storyboard
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-04 02:31:04 +05:30
Jason A. Donenfeld c4e5bde1d9 Revert "Settings: Swap table view sections"
This reverts commit 1108f82489.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 19:53:04 +01:00
Jason A. Donenfeld e43de890e0 Settings: simplify
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 19:48:10 +01:00
Jason A. Donenfeld 955de09c9e Global: run through swiftlint
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 19:35:25 +01:00
Jason A. Donenfeld 6738ebb356 Settings: limit size of logo
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 19:20:21 +01:00
Jason A. Donenfeld b28a62c114 Settings: use updated wireguard banner logo
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 18:37:51 +01:00
Jason A. Donenfeld 1568ae57e3 TunnelsManager: restore sanity
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 18:20:25 +01:00
Roopesh Chander c80901fbed Change version with 0.0.yyyymmdd versioning scheme
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 19:28:29 +05:30
Roopesh Chander 68f91e2a84 VPN: Make sure actions inside tunnelProvider completion handlers are done in the main queue
They should really already be in the main queue, but we do this just in case.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 19:26:28 +05:30
Roopesh Chander 582092abb1 VPN: Start observing the status only if startTunnel() succeeds
This should fix the status change to .disconnected when we're resolving endpoints

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 19:22:30 +05:30
Roopesh Chander 7c4992894b VPN: We should never get a status change to .disconnected if we're resolving endpoints
But we do, which we'll fix subsequently

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 18:58:27 +05:30
Roopesh Chander 538704e7bd Revert "TunnelsManager: initialize observer on correct thread"
Rather, we'll make sure we always call startObservingTunnelStatus from
the main thread.

This reverts commit d16a6a167c.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 18:45:26 +05:30
Roopesh Chander 66389c60b5 Settings: Show the captioned WireGuard logo at the end
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 18:41:54 +05:30
Roopesh Chander 09fbe93bf0 Settings: Swap table view sections
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 17:53:50 +05:30
Roopesh Chander e8802b14b4 Remove empty image
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 17:39:43 +05:30
Jeroen Leenarts 477916f0c4 Add Wireguard logo with caption to project
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 17:39:22 +05:30
Roopesh Chander b9d0b9f096 Tunnels list: Fix status switch look after flipping it off after an error
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 17:28:16 +05:30
Roopesh Chander 2f5e83cf99 ErrorPresenter: showErrorAlert takes an onPresentated handler
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 17:27:07 +05:30
Roopesh Chander a512216d85 Tunnels list: Should deselect the row when handling the selection
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 16:05:02 +05:30
Roopesh Chander 9312821778 Tunnel list: Don't show the detail view after creating a config from scratch
So it's consistent with the other two "Add a configuration" menu items

Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 15:51:29 +05:30
Roopesh Chander 366ca7802a Ensure that all tunnel names are trimmed of whitespaces
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 15:45:29 +05:30
Roopesh Chander ac79c5b1f7 Zip archive: Handle files within folders inside the zip
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 15:37:31 +05:30
Jason A. Donenfeld ec943587fa TunnelsManager: initialize observer on correct thread
Because of the callback recursion, this function needs to always be called from the right thread

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 07:03:23 +01:00
Jason A. Donenfeld 6405b76941 TunnelsManager: do not track currentTunnel
It's error prone and does not give us anything.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 06:22:57 +01:00
Jason A. Donenfeld 9e9898f17d TunnelsManager: do not change back to inactive if we are resolving the endpoint
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 06:09:57 +01:00
Roopesh Chander ae2ae87bbe Tunnels list: Remove separator lines in the table view
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 10:26:15 +05:30
Roopesh Chander 735d542658 Tunnels list: Show an 'Add' button when there are no tunnels
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 10:26:09 +05:30
Roopesh Chander 0c60489819 Tunnels list: Show a busy indicator before the tunnels are loaded
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 10:25:47 +05:30
Roopesh Chander 9df0064eac Tunnels list: The Add and Settings buttons should be no-ops until the tunnels are loaded
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 10:25:47 +05:30
Roopesh Chander f6a29d9f50 Tunnel edit: Use layoutMarginsGuide instead of constants
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-03 10:25:47 +05:30
Jason A. Donenfeld 5845db4568 TunnelsManager: fix use of arrayslice in addMultiple
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 04:37:56 +01:00
Jason A. Donenfeld f57c40c38b TunnelsManager: get rid of name set
Instead, tunnels itself should be a sorted-set. For now it's a list,
which is probably fine though.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 03:53:08 +01:00
Jason A. Donenfeld 007d6d9c58 TunnelsManager: get rid of index management
No need for premature optimization. There aren't that many tunnels most
of the time, and calling sort on a partially sorted array is fast.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 03:43:09 +01:00
Jason A. Donenfeld 9439e00047 Global: no periods at the end of error messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 03:43:09 +01:00
Jason A. Donenfeld 95101dce5c Import: rework addMultiple logic
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-11-03 03:43:09 +01:00
Roopesh Chander dff928fafa Tunnel detail: In the key-value cell, make the value label scrollable horizontally
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-02 23:48:27 +05:30
Roopesh Chander 4c485cdbb2 Tunnel edit: Ensure all key-value fields have a placeholder text
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-02 18:20:32 +05:30
Roopesh Chander f92fb1b9f4 DNSResolver: Bugfix: Always call completion handler
Signed-off-by: Roopesh Chander <roop@roopc.net>
2018-11-02 18:10:51 +05:30