Add settings screen. Move export as zip to settings screen.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts 2018-09-18 21:47:43 +02:00
parent 1c7cf59059
commit 089315ddc5
9 changed files with 255 additions and 43 deletions

View File

@ -10,6 +10,7 @@
48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 861983CAE8FDC13BC83E7E04 /* Pods_WireGuard.framework */; }; 48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 861983CAE8FDC13BC83E7E04 /* Pods_WireGuard.framework */; };
4A430E802139DC8F0078172C /* icon_20pt@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4A430E7F2139DC8F0078172C /* icon_20pt@3x.png */; }; 4A430E802139DC8F0078172C /* icon_20pt@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4A430E7F2139DC8F0078172C /* icon_20pt@3x.png */; };
4A430E842139DCFB0078172C /* icon_60pt@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4A430E832139DCFB0078172C /* icon_60pt@3x.png */; }; 4A430E842139DCFB0078172C /* icon_60pt@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4A430E832139DCFB0078172C /* icon_60pt@3x.png */; };
4A4349752151865E00EF92F8 /* libwg-go.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AD0900120DC4171000E9CF5 /* libwg-go.a */; };
4A4351592124956200261999 /* Validators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4351582124956200261999 /* Validators.swift */; }; 4A4351592124956200261999 /* Validators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4351582124956200261999 /* Validators.swift */; };
4A43515A2124956200261999 /* Validators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4351582124956200261999 /* Validators.swift */; }; 4A43515A2124956200261999 /* Validators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4351582124956200261999 /* Validators.swift */; };
4A43515C21249E5700261999 /* ValidatorsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A43515B21249E5700261999 /* ValidatorsTests.swift */; }; 4A43515C21249E5700261999 /* ValidatorsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A43515B21249E5700261999 /* ValidatorsTests.swift */; };
@ -46,6 +47,7 @@
4AD095C820DC4190000E9CF5 /* libwg-go.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AD0900120DC4171000E9CF5 /* libwg-go.a */; }; 4AD095C820DC4190000E9CF5 /* libwg-go.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AD0900120DC4171000E9CF5 /* libwg-go.a */; };
4AEAC32920F14B3B007B67AB /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEAC32820F14B3B007B67AB /* Log.swift */; }; 4AEAC32920F14B3B007B67AB /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEAC32820F14B3B007B67AB /* Log.swift */; };
4AEAC32B20F14BA9007B67AB /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEAC32A20F14BA9007B67AB /* Log.swift */; }; 4AEAC32B20F14BA9007B67AB /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AEAC32A20F14BA9007B67AB /* Log.swift */; };
4AFB99C42150545500A745DA /* SetttingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AFB99C32150545500A745DA /* SetttingsTableViewController.swift */; };
5FA1D4CB21249F7D00DBA2E6 /* Peer+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D4CA21249F7D00DBA2E6 /* Peer+Extension.swift */; }; 5FA1D4CB21249F7D00DBA2E6 /* Peer+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D4CA21249F7D00DBA2E6 /* Peer+Extension.swift */; };
5FA1D4CD2124A05C00DBA2E6 /* Interface+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D4CC2124A05C00DBA2E6 /* Interface+Extension.swift */; }; 5FA1D4CD2124A05C00DBA2E6 /* Interface+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D4CC2124A05C00DBA2E6 /* Interface+Extension.swift */; };
5FA1D5102124D80C00DBA2E6 /* String+Arrays.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D50F2124D80C00DBA2E6 /* String+Arrays.swift */; }; 5FA1D5102124D80C00DBA2E6 /* String+Arrays.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FA1D50F2124D80C00DBA2E6 /* String+Arrays.swift */; };
@ -134,6 +136,7 @@
4AD095C920DC42CD000E9CF5 /* WireGuardNetworkExtension-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WireGuardNetworkExtension-Bridging-Header.h"; sourceTree = "<group>"; }; 4AD095C920DC42CD000E9CF5 /* WireGuardNetworkExtension-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WireGuardNetworkExtension-Bridging-Header.h"; sourceTree = "<group>"; };
4AEAC32820F14B3B007B67AB /* Log.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; }; 4AEAC32820F14B3B007B67AB /* Log.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; };
4AEAC32A20F14BA9007B67AB /* Log.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; }; 4AEAC32A20F14BA9007B67AB /* Log.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; };
4AFB99C32150545500A745DA /* SetttingsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetttingsTableViewController.swift; sourceTree = "<group>"; };
5FA1D4CA21249F7D00DBA2E6 /* Peer+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Peer+Extension.swift"; sourceTree = "<group>"; }; 5FA1D4CA21249F7D00DBA2E6 /* Peer+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Peer+Extension.swift"; sourceTree = "<group>"; };
5FA1D4CC2124A05C00DBA2E6 /* Interface+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Interface+Extension.swift"; sourceTree = "<group>"; }; 5FA1D4CC2124A05C00DBA2E6 /* Interface+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Interface+Extension.swift"; sourceTree = "<group>"; };
5FA1D50F2124D80C00DBA2E6 /* String+Arrays.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Arrays.swift"; sourceTree = "<group>"; }; 5FA1D50F2124D80C00DBA2E6 /* String+Arrays.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Arrays.swift"; sourceTree = "<group>"; };
@ -149,6 +152,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
4ABFFEA3212D3C8300107136 /* Security.framework in Frameworks */, 4ABFFEA3212D3C8300107136 /* Security.framework in Frameworks */,
4A4349752151865E00EF92F8 /* libwg-go.a in Frameworks */,
48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */, 48CF751B34E9703133F1B1AF /* Pods_WireGuard.framework in Frameworks */,
4A61D83520D98D25006C7A76 /* NetworkExtension.framework in Frameworks */, 4A61D83520D98D25006C7A76 /* NetworkExtension.framework in Frameworks */,
); );
@ -257,6 +261,7 @@
4ABF718D214D8B0300A1E0BF /* TunnelInfoTableViewController.swift */, 4ABF718D214D8B0300A1E0BF /* TunnelInfoTableViewController.swift */,
4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */, 4A4BA6D720B73CBA00223AB8 /* TunnelConfigurationTableViewController.swift */,
5FCC4342212B3092009A9C58 /* QRScanViewController.swift */, 5FCC4342212B3092009A9C58 /* QRScanViewController.swift */,
4AFB99C32150545500A745DA /* SetttingsTableViewController.swift */,
); );
path = ViewControllers; path = ViewControllers;
sourceTree = "<group>"; sourceTree = "<group>";
@ -593,6 +598,7 @@
5FA1D4CB21249F7D00DBA2E6 /* Peer+Extension.swift in Sources */, 5FA1D4CB21249F7D00DBA2E6 /* Peer+Extension.swift in Sources */,
5FA1D5122124DA6400DBA2E6 /* String+Base64.swift in Sources */, 5FA1D5122124DA6400DBA2E6 /* String+Base64.swift in Sources */,
4AC5462E2116306F00749D21 /* Tunnel+Extension.swift in Sources */, 4AC5462E2116306F00749D21 /* Tunnel+Extension.swift in Sources */,
4AFB99C42150545500A745DA /* SetttingsTableViewController.swift in Sources */,
5FCC4343212B3092009A9C58 /* QRScanViewController.swift in Sources */, 5FCC4343212B3092009A9C58 /* QRScanViewController.swift in Sources */,
4ABF718E214D8B0300A1E0BF /* TunnelInfoTableViewController.swift in Sources */, 4ABF718E214D8B0300A1E0BF /* TunnelInfoTableViewController.swift in Sources */,
4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */, 4A4BAD0E20B5F6C300F12B28 /* Coordinator.swift in Sources */,
@ -796,6 +802,10 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/wireguard-go-bridge",
);
PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios; PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development";
@ -823,6 +833,10 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/wireguard-go-bridge",
);
PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios; PRODUCT_BUNDLE_IDENTIFIER = com.wireguard.ios;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development"; PROVISIONING_PROFILE_SPECIFIER = "WireGuard Development";

View File

@ -89,16 +89,16 @@
<navigationItem key="navigationItem" title="WireGuard" largeTitleDisplayMode="always" id="j0L-5U-jDs"> <navigationItem key="navigationItem" title="WireGuard" largeTitleDisplayMode="always" id="j0L-5U-jDs">
<barButtonItem key="backBarButtonItem" title="Tunnels" id="pxL-gR-QXU"/> <barButtonItem key="backBarButtonItem" title="Tunnels" id="pxL-gR-QXU"/>
<rightBarButtonItems> <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"> <barButtonItem systemItem="add" id="h2H-H8-3Tn">
<connections> <connections>
<action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/> <action selector="addProvider:" destination="kTU-BV-32R" id="xSg-ap-3Fx"/>
</connections> </connections>
</barButtonItem> </barButtonItem>
<barButtonItem systemItem="action" id="zxB-ao-5JR">
<connections>
<action selector="exportTunnels:" destination="kTU-BV-32R" id="PwM-I1-n6B"/>
</connections>
</barButtonItem>
</rightBarButtonItems> </rightBarButtonItems>
</navigationItem> </navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
@ -548,27 +548,26 @@
</tableView> </tableView>
<navigationItem key="navigationItem" title="Tunnel settings" id="PPu-rX-T38"> <navigationItem key="navigationItem" title="Tunnel settings" id="PPu-rX-T38">
<rightBarButtonItems> <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"> <barButtonItem systemItem="save" id="mft-1l-bWa">
<connections> <connections>
<action selector="saveTunnelConfiguration:" destination="0VM-73-EPX" id="Hni-0w-hFF"/> <action selector="saveTunnelConfiguration:" destination="0VM-73-EPX" id="Hni-0w-hFF"/>
</connections> </connections>
</barButtonItem> </barButtonItem>
<barButtonItem systemItem="action" id="uim-Mz-omJ">
<connections>
<action selector="exportTunnel:" destination="0VM-73-EPX" id="oVI-TL-4o9"/>
</connections>
</barButtonItem>
</rightBarButtonItems> </rightBarButtonItems>
</navigationItem> </navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections> <connections>
<outlet property="exportButton" destination="uim-Mz-omJ" id="1Tq-ie-xo7"/>
<outlet property="saveButton" destination="mft-1l-bWa" id="Uif-KZ-isx"/> <outlet property="saveButton" destination="mft-1l-bWa" id="Uif-KZ-isx"/>
</connections> </connections>
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="j96-PK-ghN" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="j96-PK-ghN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="916" y="-263"/> <point key="canvasLocation" x="-671" y="-1262"/>
</scene> </scene>
<!--Tunnel info--> <!--Tunnel info-->
<scene sceneID="jJx-Qm-bKA"> <scene sceneID="jJx-Qm-bKA">
@ -802,11 +801,18 @@
</connections> </connections>
</tableView> </tableView>
<navigationItem key="navigationItem" title="Tunnel info" id="Eh1-Vi-78e"> <navigationItem key="navigationItem" title="Tunnel info" id="Eh1-Vi-78e">
<barButtonItem key="rightBarButtonItem" systemItem="edit" id="YRj-Ox-eKc"> <rightBarButtonItems>
<connections> <barButtonItem title=" ⚙︎" id="OME-id-5vt">
<action selector="editTunnelConfiguration:" destination="h8W-vj-IcI" id="f1k-Y6-4c3"/> <connections>
</connections> <action selector="showSettings:" destination="h8W-vj-IcI" id="mZN-SL-gZJ"/>
</barButtonItem> </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> </navigationItem>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<connections> <connections>
@ -815,7 +821,7 @@
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cXx-q2-SBO" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="cXx-q2-SBO" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="121" y="-263"/> <point key="canvasLocation" x="-671" y="-469"/>
</scene> </scene>
<!--Scan Code--> <!--Scan Code-->
<scene sceneID="gKN-k2-HoW"> <scene sceneID="gKN-k2-HoW">
@ -845,7 +851,126 @@
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TQ2-zp-o40" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="TQ2-zp-o40" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </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> </scene>
</scenes> </scenes>
<resources> <resources>

View File

@ -137,7 +137,7 @@ class AppCoordinator: RootViewCoordinator {
} }
// swiftlint:disable next function_body_length // swiftlint:disable next function_body_length
func exportConfigs(barButtonItem: UIBarButtonItem) { func exportConfigs(sourceView: UIView) {
guard let path = FileManager.default guard let path = FileManager.default
.urls(for: .documentDirectory, in: .userDomainMask).first else { .urls(for: .documentDirectory, in: .userDomainMask).first else {
return return
@ -196,7 +196,7 @@ class AppCoordinator: RootViewCoordinator {
activityItems: [saveFileURL], activityItems: [saveFileURL],
applicationActivities: nil) applicationActivities: nil)
if let popoverPresentationController = activityViewController.popoverPresentationController { if let popoverPresentationController = activityViewController.popoverPresentationController {
popoverPresentationController.barButtonItem = barButtonItem popoverPresentationController.sourceView = sourceView
} }
navigationController.present(activityViewController, animated: true) { navigationController.present(activityViewController, animated: true) {
} }
@ -273,6 +273,14 @@ class AppCoordinator: RootViewCoordinator {
self.navigationController.pushViewController(tunnelConfigurationViewController, animated: true) 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) { public func showError(_ error: Error) {
showAlert(title: NSLocalizedString("Error", comment: "Error alert title"), message: error.localizedDescription) showAlert(title: NSLocalizedString("Error", comment: "Error alert title"), message: error.localizedDescription)
} }
@ -316,10 +324,6 @@ extension AppCoordinator: TunnelInfoTableViewControllerDelegate {
} }
extension AppCoordinator: TunnelsTableViewControllerDelegate { extension AppCoordinator: TunnelsTableViewControllerDelegate {
func exportTunnels(tunnelsTableViewController: TunnelsTableViewController, barButtonItem: UIBarButtonItem) {
self.exportConfigs(barButtonItem: barButtonItem)
}
func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus { func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus {
let session = self.providerManager(for: tunnel)?.connection as? NETunnelProviderSession let session = self.providerManager(for: tunnel)?.connection as? NETunnelProviderSession
return session?.status ?? .invalid return session?.status ?? .invalid
@ -495,14 +499,9 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
} }
extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate { extension AppCoordinator: TunnelConfigurationTableViewControllerDelegate {
func export(tunnel: Tunnel, barButtonItem: UIBarButtonItem) {
exportConfig(tunnel: tunnel, barButtonItem: barButtonItem)
}
func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController) { func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController) {
saveTunnel(tunnel) saveTunnel(tunnel)
} }
} }
extension AppCoordinator: QRScanViewControllerDelegate { extension AppCoordinator: QRScanViewControllerDelegate {
@ -510,3 +509,9 @@ extension AppCoordinator: QRScanViewControllerDelegate {
showTunnelConfigurationViewController(tunnel: tunnel, context: tunnel.managedObjectContext!) showTunnelConfigurationViewController(tunnel: tunnel, context: tunnel.managedObjectContext!)
} }
} }
extension AppCoordinator: SettingsTableViewControllerDelegate {
func exportTunnels(settingsTableViewController: SettingsTableViewController, sourceView: UIView) {
self.exportConfigs(sourceView: sourceView)
}
}

View File

@ -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 {}

View File

@ -9,13 +9,12 @@ import PromiseKit
protocol TunnelConfigurationTableViewControllerDelegate: class { protocol TunnelConfigurationTableViewControllerDelegate: class {
func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController) func didSave(tunnel: Tunnel, tunnelConfigurationTableViewController: TunnelConfigurationTableViewController)
func export(tunnel: Tunnel, barButtonItem: UIBarButtonItem) func showSettings()
} }
class TunnelConfigurationTableViewController: UITableViewController { class TunnelConfigurationTableViewController: UITableViewController {
@IBOutlet weak var saveButton: UIBarButtonItem! @IBOutlet weak var saveButton: UIBarButtonItem!
@IBOutlet weak var exportButton: UIBarButtonItem!
private var viewContext: NSManagedObjectContext! private var viewContext: NSManagedObjectContext!
private weak var delegate: TunnelConfigurationTableViewControllerDelegate? private weak var delegate: TunnelConfigurationTableViewControllerDelegate?
@ -41,6 +40,10 @@ class TunnelConfigurationTableViewController: UITableViewController {
return tunnel return tunnel
} }
@IBAction func showSettings(_ sender: Any) {
delegate?.showSettings()
}
@IBAction func addPeer(_ sender: Any) { @IBAction func addPeer(_ sender: Any) {
if let moc = tunnel.managedObjectContext { if let moc = tunnel.managedObjectContext {
tableView.beginUpdates() 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 { override func numberOfSections(in tableView: UITableView) -> Int {
return 3 return 3
} }

View File

@ -9,6 +9,7 @@ import PromiseKit
protocol TunnelInfoTableViewControllerDelegate: class { protocol TunnelInfoTableViewControllerDelegate: class {
func configure(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController) func configure(tunnel: Tunnel, tunnelInfoTableViewController: TunnelInfoTableViewController)
func showSettings()
} }
class TunnelInfoTableViewController: UITableViewController { class TunnelInfoTableViewController: UITableViewController {
@ -63,6 +64,10 @@ class TunnelInfoTableViewController: UITableViewController {
} }
} }
@IBAction func showSettings(_ sender: Any) {
delegate?.showSettings()
}
@IBAction func editTunnelConfiguration(_ sender: Any) { @IBAction func editTunnelConfiguration(_ sender: Any) {
delegate?.configure(tunnel: self.tunnel, tunnelInfoTableViewController: self) delegate?.configure(tunnel: self.tunnel, tunnelInfoTableViewController: self)
} }

View File

@ -10,13 +10,13 @@ import BNRCoreDataStack
import NetworkExtension import NetworkExtension
protocol TunnelsTableViewControllerDelegate: class { protocol TunnelsTableViewControllerDelegate: class {
func exportTunnels(tunnelsTableViewController: TunnelsTableViewController, barButtonItem: UIBarButtonItem)
func addProvider(tunnelsTableViewController: TunnelsTableViewController) func addProvider(tunnelsTableViewController: TunnelsTableViewController)
func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) func connect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func disconnect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) func disconnect(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func info(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) func info(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController)
func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus func status(for tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) -> NEVPNStatus
func showSettings()
} }
class TunnelsTableViewController: UITableViewController { class TunnelsTableViewController: UITableViewController {
@ -66,8 +66,8 @@ class TunnelsTableViewController: UITableViewController {
tableView.tableFooterView = UIView(frame: CGRect.zero) tableView.tableFooterView = UIView(frame: CGRect.zero)
} }
@IBAction func exportTunnels(_ sender: UIBarButtonItem) { @IBAction func showSettings(_ sender: Any) {
delegate?.exportTunnels(tunnelsTableViewController: self, barButtonItem: sender) delegate?.showSettings()
} }
@IBAction func addProvider(_ sender: UIBarButtonItem) { @IBAction func addProvider(_ sender: UIBarButtonItem) {

View File

@ -3,3 +3,4 @@
// //
#import "Crypto/x25519.h" #import "Crypto/x25519.h"
#import "../wireguard-go-bridge/wireguard.h"

View File

@ -135,8 +135,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
private func connect(interfaceName: String, settings: String) -> Int32 { // swiftlint:disable:this cyclomatic_complexity private func connect(interfaceName: String, settings: String) -> Int32 { // swiftlint:disable:this cyclomatic_complexity
return withStringsAsGoStrings(interfaceName, settings) { (nameGoStr, settingsGoStr) -> Int32 in return withStringsAsGoStrings(interfaceName, settings) { (nameGoStr, settingsGoStr) -> Int32 in
return withUnsafeMutablePointer(to: &wgContext) { (wgCtxPtr) -> Int32 in return withUnsafeMutablePointer(to: &wgContext) { (wgCtxPtr) -> Int32 in
return wgTurnOn(nameGoStr, settingsGoStr, return wgTurnOn(nameGoStr, settingsGoStr, { (wgCtxPtr, buf, len) -> Int in
{ (wgCtxPtr, buf, len) -> Int in
// read_fn: Read from the TUN interface and pass it on to WireGuard // read_fn: Read from the TUN interface and pass it on to WireGuard
guard let wgCtxPtr = wgCtxPtr else { return 0 } guard let wgCtxPtr = wgCtxPtr else { return 0 }
guard let buf = buf else { return 0 } guard let buf = buf else { return 0 }
@ -150,8 +149,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
return packetData.count return packetData.count
} }
return 0 return 0
}, }, { (wgCtxPtr, buf, len) -> Int in
{ (wgCtxPtr, buf, len) -> Int in
// write_fn: Receive packets from WireGuard and write to the TUN interface // write_fn: Receive packets from WireGuard and write to the TUN interface
guard let wgCtxPtr = wgCtxPtr else { return 0 } guard let wgCtxPtr = wgCtxPtr else { return 0 }
guard let buf = buf else { return 0 } guard let buf = buf else { return 0 }