This commit is contained in:
Joseph Henry
2016-06-14 16:01:19 -07:00
parent 76b7e0fef7
commit c1ce7dc87a
436 changed files with 87247 additions and 473 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Netcon-iOS.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../NetconServiceSetup.cpp"
timestampString = "486073266.541748"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "105"
endingLineNumber = "105"
landmarkName = "set_intercept_status(int mode)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Netcon-iOS/NetconWrapper.cpp"
timestampString = "486081595.331827"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "28"
endingLineNumber = "28"
landmarkName = "zt_join_network(const char * nwid)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../NetconSockets.c"
timestampString = "486083531.823264"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "326"
endingLineNumber = "326"
landmarkName = "zt_socket()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50141C70A0BA00CC09EC"
BuildableName = "Netcon-iOS.app"
BlueprintName = "Netcon-iOS"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50281C70A0BA00CC09EC"
BuildableName = "Netcon-iOSTests.xctest"
BlueprintName = "Netcon-iOSTests"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50331C70A0BA00CC09EC"
BuildableName = "Netcon-iOSUITests.xctest"
BlueprintName = "Netcon-iOSUITests"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50531C70A21100CC09EC"
BuildableName = "ZeroTierNetconTests.xctest"
BlueprintName = "ZeroTierNetconTests"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50141C70A0BA00CC09EC"
BuildableName = "Netcon-iOS.app"
BlueprintName = "Netcon-iOS"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50141C70A0BA00CC09EC"
BuildableName = "Netcon-iOS.app"
BlueprintName = "Netcon-iOS"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB50141C70A0BA00CC09EC"
BuildableName = "Netcon-iOS.app"
BlueprintName = "Netcon-iOS"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CD698161C725E0300F21A9E"
BuildableName = "libServiceSetup.a"
BlueprintName = "ServiceSetup"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CD698161C725E0300F21A9E"
BuildableName = "libServiceSetup.a"
BlueprintName = "ServiceSetup"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CD698161C725E0300F21A9E"
BuildableName = "libServiceSetup.a"
BlueprintName = "ServiceSetup"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB504A1C70A21100CC09EC"
BuildableName = "ZeroTierNetcon.framework"
BlueprintName = "ZeroTierNetcon"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB504A1C70A21100CC09EC"
BuildableName = "ZeroTierNetcon.framework"
BlueprintName = "ZeroTierNetcon"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7CDB504A1C70A21100CC09EC"
BuildableName = "ZeroTierNetcon.framework"
BlueprintName = "ZeroTierNetcon"
ReferencedContainer = "container:Netcon-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Netcon-iOS.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>ServiceSetup.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>ZeroTierNetcon.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>7CD698161C725E0300F21A9E</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7CDB50141C70A0BA00CC09EC</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7CDB50281C70A0BA00CC09EC</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7CDB50331C70A0BA00CC09EC</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7CDB504A1C70A21100CC09EC</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>7CDB50531C70A21100CC09EC</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// Netcon-iOS
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}

View File

@@ -0,0 +1,73 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Netcon_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<webView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7gZ-1D-6tC">
<rect key="frame" x="20" y="492" width="284" height="88"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="deviceRGB"/>
</webView>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="3Ud-Fu-11d">
<rect key="frame" x="119" y="221" width="203" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="8Ou-mX-Fsa">
<rect key="frame" x="119" y="254" width="203" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="dest_addr" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TBc-Pq-4GK">
<rect key="frame" x="29" y="225" width="76" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="dest_port" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bas-wF-ZtN">
<rect key="frame" x="31" y="258" width="74" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vtb-3B-ko5">
<rect key="frame" x="20" y="454" width="133" height="30"/>
<state key="normal" title="HTTP Request Test"/>
<connections>
<action selector="WebRequestAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="JUf-PJ-g9W"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Shim" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bxc-Uj-YbV">
<rect key="frame" x="43" y="75" width="39" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<segmentedControl opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="YVr-bS-2fj">
<rect key="frame" x="90" y="72" width="265" height="29"/>
<segments>
<segment title="Hook"/>
<segment title="Proxy"/>
<segment title="Changeling"/>
<segment title="Direct"/>
</segments>
<connections>
<action selector="ShimControlSelected:" destination="BYZ-38-t0r" eventType="valueChanged" id="Zae-5t-Oyf"/>
</connections>
</segmentedControl>
<segmentedControl opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="Ftv-f4-HM7">
<rect key="frame" x="90" y="110" width="109" height="29"/>
<segments>
<segment title="Client"/>
<segment title="Server"/>
</segments>
<connections>
<action selector="ModeControlSelected:" destination="BYZ-38-t0r" eventType="valueChanged" id="Ery-t7-K6J"/>
</connections>
</segmentedControl>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MP6-G7-yPg">
<rect key="frame" x="38" y="114" width="44" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rb6-1T-04M">
<rect key="frame" x="301" y="20" width="34" height="30"/>
<state key="normal" title="JOIN">
<color key="titleColor" red="0.0" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="joinNetworkClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="f72-0Y-15e"/>
</connections>
</button>
<segmentedControl opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="1bK-8O-cZQ">
<rect key="frame" x="90" y="148" width="109" height="29"/>
<segments>
<segment title="TCP"/>
<segment title="UDP"/>
</segments>
<connections>
<action selector="ProtocolControlSelected:" destination="BYZ-38-t0r" eventType="valueChanged" id="3GN-J8-AxF"/>
</connections>
</segmentedControl>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Protocol" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hn2-TZ-Qeg">
<rect key="frame" x="18" y="151" width="64" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DTA-cY-dX8">
<rect key="frame" x="90" y="20" width="203" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="txtNWIDChanged:" destination="BYZ-38-t0r" eventType="editingDidEnd" id="L7S-41-0Sy"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5Kf-aZ-Qzc">
<rect key="frame" x="119" y="335" width="88" height="65"/>
<fontDescription key="fontDescription" type="system" pointSize="33"/>
<state key="normal" title="TEST">
<color key="titleColor" red="0.0" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="ExecuteTest:" destination="BYZ-38-t0r" eventType="touchUpInside" id="QWf-di-MWP"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="ModeControl" destination="Ftv-f4-HM7" id="VtU-yG-rZZ"/>
<outlet property="ProtocolControl" destination="1bK-8O-cZQ" id="fux-kG-puM"/>
<outlet property="ShimControl" destination="YVr-bS-2fj" id="hEM-6a-gFC"/>
<outlet property="WebRequest" destination="Vtb-3B-ko5" id="IvH-hT-sJd"/>
<outlet property="btnExecuteTest" destination="5Kf-aZ-Qzc" id="dsQ-Ft-XLj"/>
<outlet property="btnJoinNetwork" destination="Rb6-1T-04M" id="r4r-K5-1vV"/>
<outlet property="myWebView" destination="7gZ-1D-6tC" id="pSv-UW-je0"/>
<outlet property="txtAddr" destination="3Ud-Fu-11d" id="lK3-e5-3pI"/>
<outlet property="txtNWID" destination="DTA-cY-dX8" id="eoe-ox-X3M"/>
<outlet property="txtPort" destination="8Ou-mX-Fsa" id="RJu-ta-2I3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="234" y="458"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,27 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
int start_intercept();
int start_service(const char * path);
int join_network(const char * nwid);
void disable_intercept();
void enable_intercept();
#include <sys/socket.h>
#include "signatures.h"
void zt_join_network(const char *nwid);
void zt_leave_network(const char *nwid);
// Direct Call ZT API
// These functions will provide direct access to ZT-enabled sockets with no hassle
int zts_connect(CONNECT_SIG);
int zt_bind(BIND_SIG);
int zt_accept(ACCEPT_SIG);
int zt_listen(LISTEN_SIG);
int zts_socket(SOCKET_SIG);
int zt_setsockopt(SETSOCKOPT_SIG);
int zt_getsockopt(GETSOCKOPT_SIG);
int zt_close(CLOSE_SIG);
int zt_getsockname(GETSOCKNAME_SIG);

View File

@@ -0,0 +1,63 @@
//
// NetconWrapper.cpp
// Netcon-iOS
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#include "Netcon.h"
#include "NetconWrapper.hpp"
#include "signatures.h"
#include <sys/socket.h>
#define INTERCEPT_ENABLED 111
#define INTERCEPT_DISABLED 222
#include "NetconServiceSetup.hpp"
// Starts a service at the specified path
extern "C" int start_service(const char * path) {
init_service(INTERCEPT_DISABLED, path);
return 1;
}
// Joins a network
extern "C" void zt_join_network(const char * nwid){
join_network(nwid); // Instruct ZeroTier service to join network
zt_init_rpc(nwid); // Tells the RPC code where to contact the ZeroTier service
}
// Leaves a network
extern "C" void zt_leave_network(const char * nwid){
leave_network(nwid);
}
// Explicit ZT API wrappers
extern "C" int zts_socket(SOCKET_SIG) {
return zt_socket(socket_family, socket_type, protocol);
}
extern "C" int zts_connect(CONNECT_SIG) {
return zt_connect(__fd, __addr, __len);
}
extern "C" int zt_bind(BIND_SIG){
return zt_bind(sockfd, addr, addrlen);
}
extern "C" int zt_accept(ACCEPT_SIG) {
return zt_accept(sockfd, addr, addrlen);
}
extern "C" int zt_listen(LISTEN_SIG) {
return zt_listen(sockfd, backlog);
}
extern "C" int zt_setsockopt(SETSOCKOPT_SIG) {
return zt_setsockopt(socket, level, option_name, option_value, option_len);
}
extern "C" int zt_getsockopt(GETSOCKOPT_SIG) {
return zt_getsockopt(sockfd, level, optname, optval, optlen);
}
extern "C" int zt_close(CLOSE_SIG) {
return zt_close(fd);
}
extern "C" int zt_getsockname(GETSOCKNAME_SIG) {
return zt_getsockname(sockfd, addr, addrlen);
}

View File

@@ -0,0 +1,14 @@
//
// NetconWrapper.hpp
// Netcon-iOS
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#ifndef NetconWrapper_hpp
#define NetconWrapper_hpp
#include <stdio.h>
#endif /* NetconWrapper_hpp */

View File

@@ -0,0 +1,309 @@
//
// ViewController.swift
// Netcon-iOS
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myWebView: UIWebView!
@IBOutlet weak var btnTcpServerTest: UIButton!
@IBOutlet weak var btnTcpClientTest: UIButton!
@IBOutlet weak var btnUdpServerTest: UIButton!
@IBOutlet weak var btnUdpClientTest: UIButton!
@IBOutlet weak var btnExecuteTest: UIButton!
@IBOutlet weak var txtPort: UITextField!
@IBOutlet weak var txtAddr: UITextField!
@IBOutlet weak var urlTextField: UITextField!
var serverPort:UInt16 = 8888
var serverAddr:String = "10.5.5.2"
// Test Network Join
@IBOutlet weak var txtNWID: UITextField!
@IBOutlet weak var btnJoinNetwork: UIButton!
@IBAction func joinNetworkClicked(sender: AnyObject) {
zt_join_network(txtNWID.text!);
zt_join_network("e5cd7a9e1c2e194f");
}
// Shim { Hook, Proxy, Changeling, Direct Call }
@IBOutlet weak var ShimControl: UISegmentedControl!
var selectedShim:UInt16 = 0
@IBAction func ShimControlSelected(sender: AnyObject) {
switch sender.selectedSegmentIndex
{
case 0:
print("Selected Hook\n");
selectedShim = 0
case 1:
print("Selected Proxy\n");
selectedShim = 1
case 2:
print("Selected Changeling\n");
selectedShim = 2
case 3:
print("Selected Direct\n");
selectedShim = 3
default:
break;
}
}
// Mode { Client / Server }
@IBOutlet weak var ModeControl: UISegmentedControl!
var selectedMode:UInt16 = 0
@IBAction func ModeControlSelected(sender: AnyObject) {
switch sender.selectedSegmentIndex
{
case 0:
print("Selected client\n");
selectedMode = 0
case 1:
print("Selected server\n");
selectedMode = 1
default:
break;
}
}
// Protocol { TCP / UDP }
@IBOutlet weak var ProtocolControl: UISegmentedControl!
var selectedProtocol:Int32 = SOCK_STREAM
@IBAction func ProtocolControlSelected(sender: AnyObject) {
switch sender.selectedSegmentIndex
{
case 0:
print("Selected TCP (SOCK_STREAM)\n");
selectedProtocol = SOCK_STREAM
case 1:
print("Selected UDP (SOCK_DGRAM)\n");
selectedProtocol = SOCK_DGRAM
default:
break;
}
}
@IBAction func ExecuteTest(sender: AnyObject) {
print("Running Test...\n")
switch selectedShim
{
case 0:
print("test_client_hook_bsd_socket_api\n");
test_client_hook_bsd_socket_api()
case 1:
print("test_intercepted_proxy_streams\n");
test_client_proxy_nsstream()
case 2:
print("test_client_changeling\n");
test_client_changeling()
case 3:
print("test_client_direct_call_zt_socket\n");
test_client_direct_call_zt_socket()
default:
break;
}
}
@IBOutlet weak var btnSockTest: UIButton!
@IBAction func SocksTestAction(sender: AnyObject) {
// Remove
}
@IBOutlet weak var WebRequest: UIButton!
@IBAction func WebRequestAction(sender: AnyObject) {
// TODO: Re-test
let url_str = "http://" + txtAddr.text! + "/"
let url = NSURL (string: url_str);
//urlTextField.text = url_str;
let requestObj = NSURLRequest(URL: url!);
myWebView.loadRequest(requestObj);
}
// Mode: Client Test
// Shim: SOCKS5 Proxy
// Method: NSStream
func test_client_proxy_nsstream()
{
// For HTTP request
var buffer = [UInt8](count: 100, repeatedValue: 0)
let str = "GET / HTTP/1.0\r\n\r\n"
//let str = "Welcome to the machine"
print("strlen = %d\n", str.characters.count)
let encodedDataArray = [UInt8](str.utf8)
var inputStream:NSInputStream?
var outputStream:NSOutputStream?
// As usual, get our streams to our desired "local" address
NSStream.getStreamsToHostWithName(serverAddr, port: Int(serverPort), inputStream: &inputStream, outputStream: &outputStream)
// SOCKS Proxy config dictionary
let myDict:NSDictionary = [NSStreamSOCKSProxyHostKey : "0.0.0.0",
NSStreamSOCKSProxyPortKey : 1337,
NSStreamSOCKSProxyVersionKey : NSStreamSOCKSProxyVersion5]
// Give configuration to NSStreams
inputStream!.setProperty(myDict, forKey: NSStreamSOCKSProxyConfigurationKey)
outputStream!.setProperty(myDict, forKey: NSStreamSOCKSProxyConfigurationKey)
/* If you're interested in what happens next:
NSStream objects will generate native sockets internally which then connect to
the SOCKS proxy on 'localhost'. Once this connection is established the Proxy server
will handle a connection request to the "local address" of your choice. The subsequent
socket(), and connect() calls will be intercepted and sent to the Netcon service via
an RPC mechanism mediated by unix domain sockets. These RPC calls are dissected and
sent to the lwIP stack and finally to the ZeroTierOne service
*/
inputStream!.open()
outputStream!.open()
outputStream?.write(encodedDataArray, maxLength: encodedDataArray.count)
//sleep(5)
//inputStream?.read(&buffer, maxLength: 100)
//print("buffer = \(buffer)\n")
}
// Mode: Client Test
// Shim: Hook
// Method: BSD-like socket API
func test_client_hook_bsd_socket_api()
{
// TCP
if(selectedProtocol == SOCK_STREAM)
{
let sd = socket(AF_INET, SOCK_STREAM, 0)
var addr = sockaddr_in(sin_len: UInt8(sizeof(sockaddr_in)),
sin_family: UInt8(AF_INET),
sin_port: serverPort.bigEndian,
sin_addr: in_addr(s_addr: 0),
sin_zero: (0,0,0,0,0,0,0,0))
inet_pton(AF_INET, serverAddr, &(addr.sin_addr));
let connect_fd = connect(sd, UnsafePointer<sockaddr>([addr]), UInt32(addr.sin_len))
print("connect_fd = \(connect_fd),\(errno)")
if connect_fd < 0 {
let err = errno
print("Error connecting IPv4 socket \(err)")
return
}
}
// UDP
if(selectedProtocol == SOCK_DGRAM)
{
}
}
// Mode: Client Test
// Shim: N/A
// Method: Direct Call to ZT API
func test_client_direct_call_zt_socket()
{
// TCP
if(selectedProtocol == SOCK_STREAM)
{
// Note: We merely added the 'zt_' prefix to the standard native bsd socket calls
// This gets you direct access to ZeroTier Sockets
let sd = zts_socket(AF_INET, SOCK_STREAM, 0)
var addr = sockaddr_in(sin_len: UInt8(sizeof(sockaddr_in)),
sin_family: UInt8(AF_INET),
sin_port: serverPort.bigEndian,
sin_addr: in_addr(s_addr: 0),
sin_zero: (0,0,0,0,0,0,0,0))
inet_pton(AF_INET, serverAddr, &(addr.sin_addr));
let connect_fd = zts_connect(sd, UnsafePointer<sockaddr>([addr]), UInt32(addr.sin_len))
print("connect_fd = \(connect_fd),\(errno)")
if connect_fd < 0 {
let err = errno
print("Error connecting IPv4 socket \(err)")
return
}
}
// UDP
if(selectedProtocol == SOCK_DGRAM)
{
}
}
// Mode: Client Test
// Shim: Changeling
// Method: BSD-like socket API
func test_client_changeling()
{
// Technically this scenario is using the same bsd socket API as the
// 'test_client_hook_bsd_socket_api' test, we're just handling the native
// sockets in a different way, so we'll just call the same test function
test_client_hook_bsd_socket_api()
}
// -------- BEGIN ZEROTIER SERVICE AND PROXY THREAD DEFINITIONS
var service_thread : NSThread!
func ztnc_start_service() {
// FIXME: We use this to get a path for the ZeroTierOne service to use, this should be done differently for production
let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
//disable_intercept() // We don't want the ZeroTier service to use intercepted calls
print("start_service()\n")
start_service(path[0])
}
// ------- END
override func viewDidLoad() {
txtNWID.text = "e5cd7a9e1c3511dd"
// Style
self.view.backgroundColor = UIColor.blackColor()
btnExecuteTest.setTitleColor(UIColor.greenColor(), forState: UIControlState.Normal)
btnExecuteTest.layer.cornerRadius = 6
btnExecuteTest.layer.backgroundColor = UIColor.grayColor().CGColor
btnExecuteTest.layer.borderColor = UIColor.grayColor().CGColor
super.viewDidLoad()
// ------- BEGIN INITIALIZATION OF ZEROTIER SERVICE AND PROXY
// ZeroTier Service thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {
self.service_thread = NSThread(target:self, selector:"ztnc_start_service", object:nil)
self.service_thread.start()
});
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,36 @@
//
// Netcon_iOSTests.swift
// Netcon-iOSTests
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
import XCTest
@testable import Netcon_iOS
class Netcon_iOSTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,36 @@
//
// Netcon_iOSUITests.swift
// Netcon-iOSUITests
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
import XCTest
class Netcon_iOSUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests its important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}

View File

@@ -0,0 +1,13 @@
//
// ServiceSetup.h
// ServiceSetup
//
// Created by Joseph Henry on 2/15/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ServiceSetup : NSObject
@end

View File

@@ -0,0 +1,13 @@
//
// ServiceSetup.m
// ServiceSetup
//
// Created by Joseph Henry on 2/15/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import "ServiceSetup.h"
@implementation ServiceSetup
@end

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@@ -0,0 +1,19 @@
//
// ZeroTierNetcon.h
// ZeroTierNetcon
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for ZeroTierNetcon.
FOUNDATION_EXPORT double ZeroTierNetconVersionNumber;
//! Project version string for ZeroTierNetcon.
FOUNDATION_EXPORT const unsigned char ZeroTierNetconVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <ZeroTierNetcon/PublicHeader.h>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,36 @@
//
// ZeroTierNetconTests.swift
// ZeroTierNetconTests
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
import XCTest
@testable import ZeroTierNetcon
class ZeroTierNetconTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}
}

View File

@@ -0,0 +1,13 @@
//
// ZeroTierOne.h
// ZeroTierOne
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ZeroTierOne : NSObject
@end

View File

@@ -0,0 +1,13 @@
//
// ZeroTierOne.m
// ZeroTierOne
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import "ZeroTierOne.h"
@implementation ZeroTierOne
@end

View File

@@ -0,0 +1,78 @@
iOS + ZeroTier SDK
====
Welcome!
Imagine a flat, encrypted, no-configuration LAN for all of the instances of your iOS app.
This short tutorial will show you how to enable ZeroTier functionality for your iOS app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works and [Shim Techniques](https://www.zerotier.com/blog) for a discussion of shims available for your app/technology.
In this example we aim to set up a minimal XCode project which contains all of the components necessary to enable ZeroTier for your app. If you'd rather skip all of these steps and grab the code, look in the [sdk/iOS](https://github.com/zerotier/ZeroTierOne/tree/dev/sdk/iOS) folder of the source tree. Otherwise, let's get started!
**Step 1: Add ZeroTier source and Netcon-iOS XCode project to yours**
- Place a copy of the ZeroTierOne source in a folder at the same level as your project
- Add `ZeroTierOne/netcon/tests/iOS/Netcon-iOS.xcodeproj` to your project
**Step 2: Add ZeroTier binaries to your app**
- Add `ZeroTierNetcon.frameworkiOS` to *General->Embedded Binaries*
- Add `libServiceSetup.a` and `ZeroTierNetcon.framework` to *Build Phases->Link Binary With Libraries*
**Step 3: Configure your project**
- Add `$(SRCROOT)/../ZeroTierOne/netcon` to *Build Settings->Header Search Paths* for your project
- Add `-D__IOS__` to *Build Settings->Other C Flags*
- Add `../netcon/tests/iOS/Netcon-iOS/NetconWrapper.cpp` and `../netcon/tests/iOS/Netcon-iOS/NetconWrapper.hpp` to your project:
- Add contents of `ZeroTierOne/netcon/tests/iOS/Netcon-iOS/Netcon-iOS-Bridging-Header.h` to your projects bridging header.
*Note: You should have been prompted to create a bridging header for your project, if you haven't make sure you do this and add the native function prototypes manually from the bridging header we provide.*
**Step 4: App Code Modifications**
After you've linked the two projects you need to find a place in your code to set up the ZeroTier service thread:
```
var service_thread : NSThread!
func ztnc_start_service() {
let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
start_service(path[0])
}
```
...and then start it. If you enabled the proxy service via `-DUSE_SOCKS_PROXY` it will start automatically and be reachable at `0.0.0.0:1337`:
```
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {
self.service_thread = NSThread(target:self, selector:"ztnc_start_service", object:nil)
self.service_thread.start()
});
```
**Step 5: Pick a shim for your app**
This integration allows for the following shim combinations:
- `Hook of BSD-like sockets`: Use BSD-like sockets as you normally would.
- `Proxy of NSStream`: Create NSStream. Configure stream for SOCKS5 Proxy. Use stream.
- `Changeling of BSD-like sockets`: Call `start_changeling()` and then use BSD-like sockets as you normally would.
- `Direct Call`: Consult [Netcon-iOS-Bridging-Header.h](netcon/iOS/Netcon-iOS/Netcon-iOS-Bridging-Header.h).
If functional interposition isn't available for the API or library you've chosen to use, ZeroTier offers a SOCKS5 proxy server which can allow connectivity to your virtual network as long as your client API supports the SOCKS5 protocol. This proxy service will run alongside the tap service and can be turned on by compiling with the `-DUSE_SOCKS_PROXY` flag in *Build Settings->Other C Flags*. By default, the proxy service is available at `0.0.0.0:1337`.
**Step 6: Join a network!**
Simply call `zt_join_network("XXXXXXXXXXXXXXXX")`
***
**NSStream and SOCKS Proxy:**
As an example, here's how one would configure a NSStream object to redirect all network activity to the ZeroTier SOCKS proxy server:
```
// BEGIN proxy configuration
let myDict:NSDictionary = [NSStreamSOCKSProxyHostKey : "0.0.0.0",
NSStreamSOCKSProxyPortKey : 1337,
NSStreamSOCKSProxyVersionKey : NSStreamSOCKSProxyVersion5]
inputStream!.setProperty(myDict, forKey: NSStreamSOCKSProxyConfigurationKey)
outputStream!.setProperty(myDict, forKey: NSStreamSOCKSProxyConfigurationKey)
// END proxy configuration
```

View File

@@ -0,0 +1,13 @@
//
// lwIP.h
// lwIP
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface lwIP : NSObject
@end

View File

@@ -0,0 +1,13 @@
//
// lwIP.m
// lwIP
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#import "lwIP.h"
@implementation lwIP
@end