Add settings screen. Move export as zip to settings screen.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -89,16 +89,16 @@
|
||||
<navigationItem key="navigationItem" title="WireGuard" largeTitleDisplayMode="always" id="j0L-5U-jDs">
|
||||
<barButtonItem key="backBarButtonItem" title="Tunnels" id="pxL-gR-QXU"/>
|
||||
<rightBarButtonItems>
|
||||
<barButtonItem title=" ⚙︎" id="DZP-sp-Hsg">
|
||||
<connections>
|
||||
<action selector="showSettings:" destination="kTU-BV-32R" id="UfC-XY-zhW"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem systemItem="add" id="h2H-H8-3Tn">
|
||||
<connections>
|
||||
<action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem systemItem="action" id="zxB-ao-5JR">
|
||||
<connections>
|
||||
<action selector="exportTunnels:" destination="kTU-BV-32R" id="PwM-I1-n6B"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</rightBarButtonItems>
|
||||
</navigationItem>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
@@ -548,27 +548,26 @@
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Tunnel settings" id="PPu-rX-T38">
|
||||
<rightBarButtonItems>
|
||||
<barButtonItem title=" ⚙︎" id="Ph6-EV-NlT">
|
||||
<connections>
|
||||
<action selector="showSettings:" destination="0VM-73-EPX" id="wx3-3w-OhG"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem systemItem="save" id="mft-1l-bWa">
|
||||
<connections>
|
||||
<action selector="saveTunnelConfiguration:" destination="0VM-73-EPX" id="Hni-0w-hFF"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem systemItem="action" id="uim-Mz-omJ">
|
||||
<connections>
|
||||
<action selector="exportTunnel:" destination="0VM-73-EPX" id="oVI-TL-4o9"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</rightBarButtonItems>
|
||||
</navigationItem>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="exportButton" destination="uim-Mz-omJ" id="1Tq-ie-xo7"/>
|
||||
<outlet property="saveButton" destination="mft-1l-bWa" id="Uif-KZ-isx"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="j96-PK-ghN" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="916" y="-263"/>
|
||||
<point key="canvasLocation" x="-671" y="-1262"/>
|
||||
</scene>
|
||||
<!--Tunnel info-->
|
||||
<scene sceneID="jJx-Qm-bKA">
|
||||
@@ -802,11 +801,18 @@
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Tunnel info" id="Eh1-Vi-78e">
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="edit" id="YRj-Ox-eKc">
|
||||
<connections>
|
||||
<action selector="editTunnelConfiguration:" destination="h8W-vj-IcI" id="f1k-Y6-4c3"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<rightBarButtonItems>
|
||||
<barButtonItem title=" ⚙︎" id="OME-id-5vt">
|
||||
<connections>
|
||||
<action selector="showSettings:" destination="h8W-vj-IcI" id="mZN-SL-gZJ"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
<barButtonItem systemItem="edit" id="YRj-Ox-eKc">
|
||||
<connections>
|
||||
<action selector="editTunnelConfiguration:" destination="h8W-vj-IcI" id="f1k-Y6-4c3"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</rightBarButtonItems>
|
||||
</navigationItem>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
@@ -815,7 +821,7 @@
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="cXx-q2-SBO" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="121" y="-263"/>
|
||||
<point key="canvasLocation" x="-671" y="-469"/>
|
||||
</scene>
|
||||
<!--Scan Code-->
|
||||
<scene sceneID="gKN-k2-HoW">
|
||||
@@ -845,7 +851,126 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="TQ2-zp-o40" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="121" y="461"/>
|
||||
<point key="canvasLocation" x="162" y="793"/>
|
||||
</scene>
|
||||
<!--Settings-->
|
||||
<scene sceneID="LLL-0v-1Z9">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="SettingsTableViewController" id="0L2-ND-Twh" customClass="SettingsTableViewController" customModule="WireGuard" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="xce-Ka-TsV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="Version Information" id="zRZ-jm-jpm">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="4T9-BK-cKk">
|
||||
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="4T9-BK-cKk" id="oh2-fj-cpB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WireGuard for iOS" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="9LF-1X-BRX">
|
||||
<rect key="frame" x="16" y="11.5" width="139" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="(x.y.z)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="64F-sz-1fb">
|
||||
<rect key="frame" x="313" y="11.5" width="46" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="9LF-1X-BRX" firstAttribute="centerY" secondItem="oh2-fj-cpB" secondAttribute="centerY" id="0vh-j4-spD"/>
|
||||
<constraint firstItem="64F-sz-1fb" firstAttribute="centerY" secondItem="oh2-fj-cpB" secondAttribute="centerY" id="30t-Be-YBk"/>
|
||||
<constraint firstItem="64F-sz-1fb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="9LF-1X-BRX" secondAttribute="trailing" constant="16" id="Nl3-vZ-7lQ"/>
|
||||
<constraint firstItem="9LF-1X-BRX" firstAttribute="leading" secondItem="oh2-fj-cpB" secondAttribute="leadingMargin" id="atb-WE-sm5"/>
|
||||
<constraint firstItem="64F-sz-1fb" firstAttribute="trailing" secondItem="oh2-fj-cpB" secondAttribute="trailingMargin" id="omW-fc-mV3"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="7To-1u-V41">
|
||||
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="7To-1u-V41" id="R1k-wj-XjQ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Go userspace backend" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="ZrW-kK-iNG">
|
||||
<rect key="frame" x="16" y="11.5" width="175.5" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="(x.y.z)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZLF-fc-FG0">
|
||||
<rect key="frame" x="313" y="11.5" width="46" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="ZLF-fc-FG0" firstAttribute="centerY" secondItem="R1k-wj-XjQ" secondAttribute="centerY" id="COd-8Q-MkD"/>
|
||||
<constraint firstItem="ZLF-fc-FG0" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ZrW-kK-iNG" secondAttribute="trailing" constant="16" id="mZA-b5-OXz"/>
|
||||
<constraint firstItem="ZrW-kK-iNG" firstAttribute="leading" secondItem="R1k-wj-XjQ" secondAttribute="leadingMargin" id="v9L-hc-VeV"/>
|
||||
<constraint firstItem="ZLF-fc-FG0" firstAttribute="trailing" secondItem="R1k-wj-XjQ" secondAttribute="trailingMargin" id="vbt-K7-zSd"/>
|
||||
<constraint firstItem="ZrW-kK-iNG" firstAttribute="centerY" secondItem="R1k-wj-XjQ" secondAttribute="centerY" id="zMO-S4-aZv"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection headerTitle="Export" id="A0i-t0-uNU">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="Xti-BC-KTP" detailTextLabel="qYk-Nl-mLx" style="IBUITableViewCellStyleSubtitle" id="J1T-67-jcC">
|
||||
<rect key="frame" x="0.0" y="199.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="J1T-67-jcC" id="OTJ-zk-hYF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Export tunnels to zip file" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Xti-BC-KTP">
|
||||
<rect key="frame" x="16" y="5" width="185" height="20.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Zip file should be shared with a location for storage." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="qYk-Nl-mLx">
|
||||
<rect key="frame" x="16" y="25.5" width="294.5" height="14.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
</sections>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="0L2-ND-Twh" id="iHC-iG-by3"/>
|
||||
<outlet property="delegate" destination="0L2-ND-Twh" id="nAg-yY-JmZ"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Settings" id="jxD-pO-Xgu"/>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="exportCell" destination="J1T-67-jcC" id="VZX-ue-ZCE"/>
|
||||
<outlet property="goVersionInfoCell" destination="7To-1u-V41" id="CeX-R9-6Qh"/>
|
||||
<outlet property="goVersionInfoLabel" destination="ZLF-fc-FG0" id="5si-K0-QJL"/>
|
||||
<outlet property="versionInfoCell" destination="4T9-BK-cKk" id="QrQ-73-Cpq"/>
|
||||
<outlet property="versionInfoLabel" destination="64F-sz-1fb" id="O1J-1X-GvV"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="DXL-eC-zr0" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="726" y="-469"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
||||
@@ -137,7 +137,7 @@ class AppCoordinator: RootViewCoordinator {
|
||||
}
|
||||
|
||||
// swiftlint:disable next function_body_length
|
||||
func exportConfigs(barButtonItem: UIBarButtonItem) {
|
||||
func exportConfigs(sourceView: UIView) {
|
||||
guard let path = FileManager.default
|
||||
.urls(for: .documentDirectory, in: .userDomainMask).first else {
|
||||
return
|
||||
@@ -196,7 +196,7 @@ class AppCoordinator: RootViewCoordinator {
|
||||
activityItems: [saveFileURL],
|
||||
applicationActivities: nil)
|
||||
if let popoverPresentationController = activityViewController.popoverPresentationController {
|
||||
popoverPresentationController.barButtonItem = barButtonItem
|
||||
popoverPresentationController.sourceView = sourceView
|
||||
}
|
||||
navigationController.present(activityViewController, animated: true) {
|
||||
}
|
||||
@@ -273,6 +273,14 @@ class AppCoordinator: RootViewCoordinator {
|
||||
self.navigationController.pushViewController(tunnelConfigurationViewController, animated: true)
|
||||
}
|
||||
|
||||
func showSettings() {
|
||||
let settingsTableViewController = storyboard.instantiateViewController(type: SettingsTableViewController.self)
|
||||
|
||||
settingsTableViewController.delegate = self
|
||||
|
||||
self.navigationController.pushViewController(settingsTableViewController, animated: true)
|
||||
}
|
||||
|
||||
public func showError(_ error: Error) {
|
||||
showAlert(title: NSLocalizedString("Error", comment: "Error alert title"), message: error.localizedDescription)
|
||||
}
|
||||
@@ -316,10 +324,6 @@ extension AppCoordinator: TunnelInfoTableViewControllerDelegate {
|
||||
}
|
||||
|
||||
extension AppCoordinator: TunnelsTableViewControllerDelegate {
|
||||
func exportTunnels(tunnelsTableViewController: TunnelsTableViewController, barButtonItem: UIBarButtonItem) {
|
||||
self.exportConfigs(barButtonItem: barButtonItem)
|
||||
}
|
||||
|
||||
func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus {
|
||||
let session = self.providerManager(for: tunnel)?.connection as? NETunnelProviderSession
|
||||
return session?.status ?? .invalid
|
||||
@@ -495,14 +499,9 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
|
||||
}
|
||||
|
||||
extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate {
|
||||
func export(tunnel: Tunnel, barButtonItem: UIBarButtonItem) {
|
||||
exportConfig(tunnel: tunnel, barButtonItem: barButtonItem)
|
||||
}
|
||||
|
||||
func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController) {
|
||||
saveTunnel(tunnel)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension AppCoordinator: QRScanViewControllerDelegate {
|
||||
@@ -510,3 +509,9 @@ extension AppCoordinator: QRScanViewControllerDelegate {
|
||||
showTunnelConfigurationViewController(tunnel: tunnel, context: tunnel.managedObjectContext!)
|
||||
}
|
||||
}
|
||||
|
||||
extension AppCoordinator: SettingsTableViewControllerDelegate {
|
||||
func exportTunnels(settingsTableViewController: SettingsTableViewController, sourceView: UIView) {
|
||||
self.exportConfigs(sourceView: sourceView)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Copyright © 2018 WireGuard LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
protocol SettingsTableViewControllerDelegate: class {
|
||||
func exportTunnels(settingsTableViewController: SettingsTableViewController, sourceView: UIView)
|
||||
}
|
||||
|
||||
class SettingsTableViewController: UITableViewController {
|
||||
|
||||
weak var delegate: SettingsTableViewControllerDelegate?
|
||||
@IBOutlet weak var versionInfoCell: UITableViewCell!
|
||||
@IBOutlet weak var goVersionInfoCell: UITableViewCell!
|
||||
@IBOutlet weak var exportCell: UITableViewCell!
|
||||
|
||||
@IBOutlet weak var versionInfoLabel: UILabel!
|
||||
@IBOutlet weak var goVersionInfoLabel: UILabel!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
versionInfoLabel.text = versionInformation
|
||||
goVersionInfoLabel.text = goVersionInformation
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if let cell = tableView.cellForRow(at: indexPath) {
|
||||
switch cell {
|
||||
case versionInfoCell, goVersionInfoCell:
|
||||
UIPasteboard.general.string = ["WireGuard for iOS:", versionInformation, "Go userspace backend:", goVersionInformation].joined(separator: "\n")
|
||||
showCopyConfirmation()
|
||||
case exportCell:
|
||||
delegate?.exportTunnels(settingsTableViewController: self, sourceView: exportCell)
|
||||
default:
|
||||
()
|
||||
}
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
var versionInformation: String {
|
||||
var versionElements: [String] = []
|
||||
if let appBuildNumber = Bundle.main.infoDictionary!["CFBundleVersion"] as? String, let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String {
|
||||
versionElements.append(appVersion)
|
||||
versionElements.append("(\(appBuildNumber))")
|
||||
}
|
||||
|
||||
return versionElements.joined(separator: " ")
|
||||
}
|
||||
|
||||
var goVersionInformation: String {
|
||||
return wgVersion().flatMap { String(cString: $0) } ?? ""
|
||||
}
|
||||
|
||||
private func showCopyConfirmation() {
|
||||
let confirmationAlertController = UIAlertController(title: NSLocalizedString("Copied version information", comment: ""), message: UIPasteboard.general.string, preferredStyle: .alert)
|
||||
confirmationAlertController.addAction(UIAlertAction(title: NSLocalizedString("Ok", comment: "Generic OK button"), style: .default, handler: nil))
|
||||
|
||||
present(confirmationAlertController, animated: true, completion: nil)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension SettingsTableViewController: Identifyable {}
|
||||
@@ -9,13 +9,12 @@ import PromiseKit
|
||||
|
||||
protocol TunnelConfigurationTableViewControllerDelegate: class {
|
||||
func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController)
|
||||
func export(tunnel: Tunnel, barButtonItem: UIBarButtonItem)
|
||||
func showSettings()
|
||||
}
|
||||
|
||||
class TunnelConfigurationTableViewController: UITableViewController {
|
||||
|
||||
@IBOutlet weak var saveButton: UIBarButtonItem!
|
||||
@IBOutlet weak var exportButton: UIBarButtonItem!
|
||||
|
||||
private var viewContext: NSManagedObjectContext!
|
||||
private weak var delegate: TunnelConfigurationTableViewControllerDelegate?
|
||||
@@ -41,6 +40,10 @@ class TunnelConfigurationTableViewController: UITableViewController {
|
||||
return tunnel
|
||||
}
|
||||
|
||||
@IBAction func showSettings(_ sender: Any) {
|
||||
delegate?.showSettings()
|
||||
}
|
||||
|
||||
@IBAction func addPeer(_ sender: Any) {
|
||||
if let moc = tunnel.managedObjectContext {
|
||||
tableView.beginUpdates()
|
||||
@@ -55,10 +58,6 @@ class TunnelConfigurationTableViewController: UITableViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func exportTunnel(_ sender: UIBarButtonItem) {
|
||||
self.delegate?.export(tunnel: tunnel, barButtonItem: sender)
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import PromiseKit
|
||||
|
||||
protocol TunnelInfoTableViewControllerDelegate: class {
|
||||
func configure(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController)
|
||||
func showSettings()
|
||||
}
|
||||
|
||||
class TunnelInfoTableViewController: UITableViewController {
|
||||
@@ -63,6 +64,10 @@ class TunnelInfoTableViewController: UITableViewController {
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func showSettings(_ sender: Any) {
|
||||
delegate?.showSettings()
|
||||
}
|
||||
|
||||
@IBAction func editTunnelConfiguration(_ sender: Any) {
|
||||
delegate?.configure(tunnel: self.tunnel, tunnelInfoTableViewController: self)
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import BNRCoreDataStack
|
||||
import NetworkExtension
|
||||
|
||||
protocol TunnelsTableViewControllerDelegate: class {
|
||||
func exportTunnels(tunnelsTableViewController: TunnelsTableViewController, barButtonItem: UIBarButtonItem)
|
||||
func addProvider(tunnelsTableViewController: TunnelsTableViewController)
|
||||
func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func disconnect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func info(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
|
||||
func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus
|
||||
func showSettings()
|
||||
}
|
||||
|
||||
class TunnelsTableViewController: UITableViewController {
|
||||
@@ -66,8 +66,8 @@ class TunnelsTableViewController: UITableViewController {
|
||||
tableView.tableFooterView = UIView(frame: CGRect.zero)
|
||||
}
|
||||
|
||||
@IBAction func exportTunnels(_ sender: UIBarButtonItem) {
|
||||
delegate?.exportTunnels(tunnelsTableViewController: self, barButtonItem: sender)
|
||||
@IBAction func showSettings(_ sender: Any) {
|
||||
delegate?.showSettings()
|
||||
}
|
||||
|
||||
@IBAction func addProvider(_ sender: UIBarButtonItem) {
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
//
|
||||
|
||||
#import "Crypto/x25519.h"
|
||||
#import "../wireguard-go-bridge/wireguard.h"
|
||||
|
||||
Reference in New Issue
Block a user