updated
This commit is contained in:
46
integrations/iOS/Netcon-iOS/AppDelegate.swift
Normal file
46
integrations/iOS/Netcon-iOS/AppDelegate.swift
Normal 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:.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
151
integrations/iOS/Netcon-iOS/Base.lproj/Main.storyboard
Normal file
151
integrations/iOS/Netcon-iOS/Base.lproj/Main.storyboard
Normal 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>
|
||||
54
integrations/iOS/Netcon-iOS/Info.plist
Normal file
54
integrations/iOS/Netcon-iOS/Info.plist
Normal 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>
|
||||
27
integrations/iOS/Netcon-iOS/Netcon-iOS-Bridging-Header.h
Normal file
27
integrations/iOS/Netcon-iOS/Netcon-iOS-Bridging-Header.h
Normal 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);
|
||||
63
integrations/iOS/Netcon-iOS/NetconWrapper.cpp
Normal file
63
integrations/iOS/Netcon-iOS/NetconWrapper.cpp
Normal 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);
|
||||
}
|
||||
14
integrations/iOS/Netcon-iOS/NetconWrapper.hpp
Normal file
14
integrations/iOS/Netcon-iOS/NetconWrapper.hpp
Normal 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 */
|
||||
309
integrations/iOS/Netcon-iOS/ViewController.swift
Normal file
309
integrations/iOS/Netcon-iOS/ViewController.swift
Normal 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.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user