From 058233801596c706efb1cb668068f1c8e0135cb6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 14 May 2016 13:54:49 -0700 Subject: Initial Commit --- ZeroTier One.xcodeproj/project.pbxproj | 278 +++++++++ .../project.xcworkspace/contents.xcworkspacedata | 7 + .../xcschemes/ZeroTier One.xcscheme | 91 +++ .../xcschemes/xcschememanagement.plist | 22 + ZeroTier One/AppDelegate.swift | 27 + .../AppIcon.appiconset/Contents.json | 58 ++ ZeroTier One/Base.lproj/MainMenu.xib | 680 +++++++++++++++++++++ ZeroTier One/Info.plist | 34 ++ 8 files changed, 1197 insertions(+) create mode 100644 ZeroTier One.xcodeproj/project.pbxproj create mode 100644 ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme create mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 ZeroTier One/AppDelegate.swift create mode 100644 ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ZeroTier One/Base.lproj/MainMenu.xib create mode 100644 ZeroTier One/Info.plist diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj new file mode 100644 index 00000000..10787067 --- /dev/null +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -0,0 +1,278 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; }; + 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; + 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 93326BE01CE7C816005CA2AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 93326BE21CE7C816005CA2AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 93326BD51CE7C816005CA2AC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 93326BCF1CE7C816005CA2AC = { + isa = PBXGroup; + children = ( + 93326BDA1CE7C816005CA2AC /* ZeroTier One */, + 93326BD91CE7C816005CA2AC /* Products */, + ); + sourceTree = ""; + }; + 93326BD91CE7C816005CA2AC /* Products */ = { + isa = PBXGroup; + children = ( + 93326BD81CE7C816005CA2AC /* ZeroTier One.app */, + ); + name = Products; + sourceTree = ""; + }; + 93326BDA1CE7C816005CA2AC /* ZeroTier One */ = { + isa = PBXGroup; + children = ( + 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, + 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, + 93326BDF1CE7C816005CA2AC /* MainMenu.xib */, + 93326BE21CE7C816005CA2AC /* Info.plist */, + ); + path = "ZeroTier One"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 93326BD71CE7C816005CA2AC /* ZeroTier One */ = { + isa = PBXNativeTarget; + buildConfigurationList = 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */; + buildPhases = ( + 93326BD41CE7C816005CA2AC /* Sources */, + 93326BD51CE7C816005CA2AC /* Frameworks */, + 93326BD61CE7C816005CA2AC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ZeroTier One"; + productName = "ZeroTier One"; + productReference = 93326BD81CE7C816005CA2AC /* ZeroTier One.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 93326BD01CE7C816005CA2AC /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = "ZeroTier, Inc"; + TargetAttributes = { + 93326BD71CE7C816005CA2AC = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 93326BCF1CE7C816005CA2AC; + productRefGroup = 93326BD91CE7C816005CA2AC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 93326BD71CE7C816005CA2AC /* ZeroTier One */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 93326BD61CE7C816005CA2AC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, + 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 93326BD41CE7C816005CA2AC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 93326BDF1CE7C816005CA2AC /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 93326BE01CE7C816005CA2AC /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 93326BE31CE7C816005CA2AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 93326BE41CE7C816005CA2AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 93326BE61CE7C816005CA2AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "ZeroTier One/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 93326BE71CE7C816005CA2AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "ZeroTier One/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 93326BE31CE7C816005CA2AC /* Debug */, + 93326BE41CE7C816005CA2AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 93326BE61CE7C816005CA2AC /* Debug */, + 93326BE71CE7C816005CA2AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 93326BD01CE7C816005CA2AC /* Project object */; +} diff --git a/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..fd60338e --- /dev/null +++ b/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme new file mode 100644 index 00000000..ea3f64f8 --- /dev/null +++ b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..70969d2d --- /dev/null +++ b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + ZeroTier One.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 93326BD71CE7C816005CA2AC + + primary + + + + + diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift new file mode 100644 index 00000000..6ac5a5c1 --- /dev/null +++ b/ZeroTier One/AppDelegate.swift @@ -0,0 +1,27 @@ +// +// AppDelegate.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/14/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + @IBOutlet weak var window: NSWindow! + + + func applicationDidFinishLaunching(aNotification: NSNotification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(aNotification: NSNotification) { + // Insert code here to tear down your application + } + + +} + diff --git a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..2db2b1c7 --- /dev/null +++ b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ZeroTier One/Base.lproj/MainMenu.xib b/ZeroTier One/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..3bcfb090 --- /dev/null +++ b/ZeroTier One/Base.lproj/MainMenu.xib @@ -0,0 +1,680 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist new file mode 100644 index 00000000..d5b744c6 --- /dev/null +++ b/ZeroTier One/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2016 ZeroTier, Inc. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + -- cgit v1.2.3 From 225c2b095b03e4b0383a99863349fc28b6a3f893 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 14 May 2016 15:42:45 -0700 Subject: Initial start of the menu bar app. Has menu items to join/leave networks which currently displays an empty popover from the icon (icon needs to be made still) --- ZeroTier One.xcodeproj/project.pbxproj | 16 ++++++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 ++ ZeroTier One/AppDelegate.swift | 64 ++++++++++++++++++++- ZeroTier One/Assets.xcassets/Contents.json | 6 ++ .../MenuBarIconMac.imageset/Contents.json | 21 +++++++ .../MenuBarIconMac.imageset/MenuBarIconMac.png | Bin 0 -> 3810 bytes .../MenuBarIconMac.imageset/MenuBarIconMac@2x.png | Bin 0 -> 5444 bytes ZeroTier One/Base.lproj/MainMenu.xib | 11 ++-- ZeroTier One/Info.plist | 2 + ZeroTier One/JoinNetworkViewController.swift | 18 ++++++ ZeroTier One/JoinNetworkViewController.xib | 20 +++++++ ZeroTier One/ShowNetworksViewController.swift | 18 ++++++ ZeroTier One/ShowNetworksViewController.xib | 20 +++++++ 13 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 ZeroTier One/Assets.xcassets/Contents.json create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png create mode 100644 ZeroTier One/JoinNetworkViewController.swift create mode 100644 ZeroTier One/JoinNetworkViewController.xib create mode 100644 ZeroTier One/ShowNetworksViewController.swift create mode 100644 ZeroTier One/ShowNetworksViewController.xib diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 10787067..2730b987 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -10,6 +10,10 @@ 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; }; 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; + 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */; }; + 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */; }; + 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */; }; + 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -18,6 +22,10 @@ 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 93326BE01CE7C816005CA2AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 93326BE21CE7C816005CA2AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinNetworkViewController.swift; sourceTree = ""; }; + 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JoinNetworkViewController.xib; sourceTree = ""; }; + 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowNetworksViewController.swift; sourceTree = ""; }; + 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowNetworksViewController.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,9 +59,13 @@ isa = PBXGroup; children = ( 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, + 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */, + 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */, 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, 93326BDF1CE7C816005CA2AC /* MainMenu.xib */, 93326BE21CE7C816005CA2AC /* Info.plist */, + 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */, + 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */, ); path = "ZeroTier One"; sourceTree = ""; @@ -116,6 +128,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */, + 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */, 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, ); @@ -129,6 +143,8 @@ buildActionMask = 2147483647; files = ( 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, + 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, + 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 00000000..fe2b4541 --- /dev/null +++ b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index 6ac5a5c1..e5932f5f 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -14,8 +14,34 @@ class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! + let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2.0) + + let networkListPopover = NSPopover() + let joinNetworkPopover = NSPopover() + + var transientMonitor: AnyObject? = nil + func applicationDidFinishLaunching(aNotification: NSNotification) { - // Insert code here to initialize your application + + + statusItem.image = NSImage(named: "MenuBarIconMac") + + let menu = NSMenu() + + menu.addItem(NSMenuItem(title: "Show Networks", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) + menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) + menu.addItem(NSMenuItem.separatorItem()) + menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q")) + + statusItem.menu = menu + + joinNetworkPopover.contentViewController = JoinNetworkViewController( + nibName: "JoinNetworkViewController", bundle: nil) + joinNetworkPopover.behavior = .Transient + + networkListPopover.contentViewController = ShowNetworksViewController( + nibName: "ShowNetworksViewController", bundle: nil) + networkListPopover.behavior = .Transient } func applicationWillTerminate(aNotification: NSNotification) { @@ -23,5 +49,41 @@ class AppDelegate: NSObject, NSApplicationDelegate { } + func showNetworks() { + if let button = statusItem.button { + networkListPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY) + + if transientMonitor == nil { + transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask( + [.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in + + NSEvent.removeMonitor(self.transientMonitor!) + self.transientMonitor = nil + self.networkListPopover.close() + } + } + } + } + + func joinNetwork() { + if let button = statusItem.button { + joinNetworkPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY) + + if transientMonitor == nil { + transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask( + [.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in + + NSEvent.removeMonitor(self.transientMonitor!) + self.transientMonitor = nil + self.joinNetworkPopover.close() + + } + } + } + } + + func quit() { + NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0) + } } diff --git a/ZeroTier One/Assets.xcassets/Contents.json b/ZeroTier One/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/ZeroTier One/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json new file mode 100644 index 00000000..ab75ef9a --- /dev/null +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "mac", + "filename" : "MenuBarIconMac.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "filename" : "MenuBarIconMac@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png new file mode 100644 index 00000000..74e59fe7 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png new file mode 100644 index 00000000..1c99f851 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png differ diff --git a/ZeroTier One/Base.lproj/MainMenu.xib b/ZeroTier One/Base.lproj/MainMenu.xib index 3bcfb090..4722fac2 100644 --- a/ZeroTier One/Base.lproj/MainMenu.xib +++ b/ZeroTier One/Base.lproj/MainMenu.xib @@ -1,7 +1,8 @@ - + - + + @@ -11,7 +12,7 @@ - + @@ -666,11 +667,11 @@ - + - + diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index d5b744c6..f5d0dc94 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -2,6 +2,8 @@ + LSUIElement + CFBundleDevelopmentRegion en CFBundleExecutable diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift new file mode 100644 index 00000000..d071ce91 --- /dev/null +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -0,0 +1,18 @@ +// +// JoinNetworkViewController.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/14/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class JoinNetworkViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + +} diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib new file mode 100644 index 00000000..7f3f1329 --- /dev/null +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift new file mode 100644 index 00000000..0ecb38f5 --- /dev/null +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -0,0 +1,18 @@ +// +// ShowNetworksViewController.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/14/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class ShowNetworksViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + +} diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib new file mode 100644 index 00000000..2fe5f22f --- /dev/null +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From b4a80579948038989c382fd41101f1f489245124 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 17:51:14 -0700 Subject: limit the join network combobox to hex characters. Join only clickable when a valid network is entered --- ZeroTier One.xcodeproj/project.pbxproj | 1 + ZeroTier One/JoinNetworkViewController.swift | 72 ++++++++++++++++++++++++++-- ZeroTier One/JoinNetworkViewController.xib | 35 +++++++++++++- 3 files changed, 103 insertions(+), 5 deletions(-) diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 2730b987..4fb0a76e 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -287,6 +287,7 @@ 93326BE71CE7C816005CA2AC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index d071ce91..0aaaf10f 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -8,11 +8,77 @@ import Cocoa -class JoinNetworkViewController: NSViewController { +extension String { + func contains(find: String) -> Bool { + return self.rangeOfString(find) != nil + } + + func trunc(length: Int, trailing: String? = "...") -> String { + if self.characters.count > length { + return self.substringToIndex(self.startIndex.advancedBy(length)) + (trailing ?? "") + } else { + return self + } + } +} + +class JoinNetworkViewController: NSViewController, NSComboBoxDelegate { + + @IBOutlet var network: NSComboBox! + @IBOutlet var joinButton: NSButton! override func viewDidLoad() { super.viewDidLoad() - // Do view setup here. + network.setDelegate(self) + } + + @IBAction func onJoinClicked(sender: AnyObject?) { + let networkId = UInt64(network.stringValue, radix: 16) + + // TODO: Execute join network call + + network.stringValue = "" + } + + + // NSComboBoxDelegate Methods + + override func controlTextDidChange(obj: NSNotification) { + let cb = obj.object as! NSComboBox + let value = cb.stringValue + + + let allowedCharacters = "abcdefABCDEF0123456789" + + var outValue = "" + + for char in value.characters { + if !allowedCharacters.contains(String(char)) { + NSBeep() + } + else { + outValue += String(char) + } + } + + + + if outValue.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 16 { + joinButton.enabled = true + } + else { + + if outValue.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) > 16 { + outValue = outValue.trunc(16, trailing: "") + NSBeep() + joinButton.enabled = true + } + else { + joinButton.enabled = false + } + } + + cb.stringValue = outValue } - + // end NSComboBoxDelegate Methods } diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 7f3f1329..2de44c9d 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -1,5 +1,5 @@ - + @@ -7,14 +7,45 @@ + + - + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From ccbd6f97cda44999230222b8b54d077b7a754e0c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 18:02:26 -0700 Subject: remove some mistakenly committed files and add .gitignore for Xcode projects --- .gitignore | 105 +++++++++++++++++++++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 - .../xcschemes/ZeroTier One.xcscheme | 91 ------------------ .../xcschemes/xcschememanagement.plist | 22 ----- 4 files changed, 105 insertions(+), 118 deletions(-) create mode 100644 .gitignore delete mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist delete mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme delete mode 100644 ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c62c7939 --- /dev/null +++ b/.gitignore @@ -0,0 +1,105 @@ +##### +# OS X temporary files that should never be committed +# +# c.f. http://www.westwind.com/reference/os-x/invisibles.html + +.DS_Store + +# c.f. http://www.westwind.com/reference/os-x/invisibles.html + +.Trashes + +# c.f. http://www.westwind.com/reference/os-x/invisibles.html + +*.swp + +# +# *.lock - this is used and abused by many editors for many different things. +# For the main ones I use (e.g. Eclipse), it should be excluded +# from source-control, but YMMV. +# (lock files are usually local-only file-synchronization on the local FS that should NOT go in git) +# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations! +# +# In particular, if you're using CocoaPods, you'll want to comment-out this line: +*.lock + + +# +# profile - REMOVED temporarily (on double-checking, I can't find it in OS X docs?) +#profile + + +#### +# Xcode temporary files that should never be committed +# +# NB: NIB/XIB files still exist even on Storyboard projects, so we want this... + +*~.nib + + +#### +# Xcode build files - +# +# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData" + +DerivedData/ + +# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build" + +build/ + + +##### +# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) +# +# This is complicated: +# +# SOMETIMES you need to put this file in version control. +# Apple designed it poorly - if you use "custom executables", they are +# saved in this file. +# 99% of projects do NOT use those, so they do NOT want to version control this file. +# ..but if you're in the 1%, comment out the line "*.pbxuser" + +# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html + +*.pbxuser + +# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html + +*.mode1v3 + +# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html + +*.mode2v3 + +# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file + +*.perspectivev3 + +# NB: also, whitelist the default ones, some projects need to use these +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + + +#### +# Xcode 4 - semi-personal settings +# +# Apple Shared data that Apple put in the wrong folder +# c.f. http://stackoverflow.com/a/19260712/153422 +# FROM ANSWER: Apple says "don't ignore it" +# FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode +# Up to you, but ... current advice: ignore it. +*.xccheckout + +# +# +# OPTION 1: --------------------------------- +# throw away ALL personal settings (including custom schemes! +# - unless they are "shared") +# As per build/ and DerivedData/, this ought to have a trailing slash +# +# NB: this is exclusive with OPTION 2 below +xcuserdata/ + diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist deleted file mode 100644 index fe2b4541..00000000 --- a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme deleted file mode 100644 index ea3f64f8..00000000 --- a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/ZeroTier One.xcscheme +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist b/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 70969d2d..00000000 --- a/ZeroTier One.xcodeproj/xcuserdata/grant.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - ZeroTier One.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - 93326BD71CE7C816005CA2AC - - primary - - - - - -- cgit v1.2.3 From acd6978a3094ae7cffdfb5cf79e4c2473ab3bb0f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 18:26:33 -0700 Subject: set the combo box to use a data source and remember the last 20 networks input --- ZeroTier One/JoinNetworkViewController.swift | 71 +++++++++++++++++++++++++++- ZeroTier One/JoinNetworkViewController.xib | 16 +++---- 2 files changed, 77 insertions(+), 10 deletions(-) diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index 0aaaf10f..c9fdcebe 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -22,22 +22,54 @@ extension String { } } -class JoinNetworkViewController: NSViewController, NSComboBoxDelegate { +let joinedNetworksKey = "com.zerotier.one.joined-networks" + + +class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBoxDataSource { @IBOutlet var network: NSComboBox! @IBOutlet var joinButton: NSButton! + var values: [String] = [String]() + override func viewDidLoad() { super.viewDidLoad() network.setDelegate(self) + network.dataSource = self + } + + override func viewWillAppear() { + let defaults = NSUserDefaults.standardUserDefaults() + + let vals = defaults.stringArrayForKey(joinedNetworksKey) + + if let v = vals { + values = v + } + } + + override func viewDidDisappear() { + let defaults = NSUserDefaults.standardUserDefaults() + + defaults.setObject(values, forKey: joinedNetworksKey) } @IBAction func onJoinClicked(sender: AnyObject?) { - let networkId = UInt64(network.stringValue, radix: 16) + let networkString = network.stringValue + let networkId = UInt64(networkString, radix: 16) // TODO: Execute join network call network.stringValue = "" + + + if !values.contains(networkString) { + values.insert(networkString, atIndex: 0) + + while values.count > 20 { + values.removeLast() + } + } } @@ -81,4 +113,39 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate { cb.stringValue = outValue } // end NSComboBoxDelegate Methods + + + // NSComboBoxDataSource methods + + func numberOfItemsInComboBox(aComboBox: NSComboBox) -> Int { + return values.count + } + + func comboBox(aComboBox: NSComboBox, objectValueForItemAtIndex index: Int) -> AnyObject { + return values[index] + } + + func comboBox(aComboBox: NSComboBox, indexOfItemWithStringValue string: String) -> Int { + + var counter = 0 + for val in values { + if val == string { + return counter + } + counter += 1 + } + return NSNotFound + } + + func comboBox(aComboBox: NSComboBox, completedString string: String) -> String? { + for val in values { + if val.hasPrefix(string) { + return val + } + } + + return nil + } + + // end NSComboBoxDataSorce methods } diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 2de44c9d..7a2ffe70 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -26,14 +26,6 @@ - - - - - - - - + + + + + + + + -- cgit v1.2.3 From 4653ebc97ff15db5f22066a49d7fe4e5f8a9345d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 19:08:00 -0700 Subject: add table view to show networks view --- ZeroTier One/ShowNetworksViewController.swift | 2 + ZeroTier One/ShowNetworksViewController.xib | 100 +++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 0ecb38f5..8bf84a1c 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -10,6 +10,8 @@ import Cocoa class ShowNetworksViewController: NSViewController { + @IBOutlet var tableView: NSTableView! + override func viewDidLoad() { super.viewDidLoad() // Do view setup here. diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 2fe5f22f..e17bc5a9 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,5 +1,5 @@ - + @@ -7,6 +7,7 @@ + @@ -15,6 +16,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 40198d6c1398da33fb1c6340c03927da890d816e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 19:25:20 -0700 Subject: call super functions on a few overrides --- ZeroTier One/JoinNetworkViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index c9fdcebe..1ac3c7ea 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -39,6 +39,8 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo } override func viewWillAppear() { + super.viewWillAppear() + let defaults = NSUserDefaults.standardUserDefaults() let vals = defaults.stringArrayForKey(joinedNetworksKey) @@ -49,6 +51,8 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo } override func viewDidDisappear() { + super.viewWillDisappear() + let defaults = NSUserDefaults.standardUserDefaults() defaults.setObject(values, forKey: joinedNetworksKey) -- cgit v1.2.3 From da30d2898e59d34dc47b251a07376db70fcd3e96 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 16 May 2016 19:58:24 -0700 Subject: beginning of communicating with the zero tier service --- ZeroTier One.xcodeproj/project.pbxproj | 4 ++ ZeroTier One/Info.plist | 5 ++ ZeroTier One/ServiceCom.swift | 97 +++++++++++++++++++++++++++ ZeroTier One/ShowNetworksViewController.swift | 6 ++ 4 files changed, 112 insertions(+) create mode 100644 ZeroTier One/ServiceCom.swift diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 4fb0a76e..d0441a5c 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; }; 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; @@ -17,6 +18,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -61,6 +63,7 @@ 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */, 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */, + 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */, 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, 93326BDF1CE7C816005CA2AC /* MainMenu.xib */, 93326BE21CE7C816005CA2AC /* Info.plist */, @@ -145,6 +148,7 @@ 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, + 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index f5d0dc94..7a6ab723 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -2,6 +2,11 @@ + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + LSUIElement CFBundleDevelopmentRegion diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift new file mode 100644 index 00000000..a1bb0a3c --- /dev/null +++ b/ZeroTier One/ServiceCom.swift @@ -0,0 +1,97 @@ +// +// ServiceCom.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/16/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class ServiceCom: NSObject { + static let baseURL = "http://localhost:9993" + static var key: NSString? = "ddeb3b1e6996b6b4f2d12d10" + + static func getNetworkList() { + + let urlString = baseURL + "/network?auth=\(ServiceCom.key!)" + + let url = NSURL(string: urlString) + + if let u = url { + let request = NSMutableURLRequest(URL: u) + let session = NSURLSession.sharedSession() + let task = session.dataTaskWithRequest(request) { (data, response, error) in + let httpResponse = response as! NSHTTPURLResponse + let status = httpResponse.statusCode + + if status == 200 { + do { + let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) + print("\(json)") + } + catch { + print("JSON Error: \(error)") + } + } + } + + task.resume() + } + else { + print("bad URL") + } + } + + + static func joinNetwork(network: String) { + let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.key!)" + let url = NSURL(string: urlString) + + if let u = url { + let request = NSMutableURLRequest(URL: u) + request.HTTPMethod = "POST" + + let session = NSURLSession.sharedSession() + let task = session.dataTaskWithRequest(request) { (data, response, error) in + let httpResponse = response as! NSHTTPURLResponse + let status = httpResponse.statusCode + + if status == 200 { + print("join ok") + } + else { + print("join error: \(status)") + } + } + + task.resume() + } + } + + static func leaveNetwork(network: String) { + let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.key!)" + let url = NSURL(string: urlString) + + if let u = url { + let request = NSMutableURLRequest(URL: u) + request.HTTPMethod = "DELETE" + + let session = NSURLSession.sharedSession() + let task = session.dataTaskWithRequest(request) { (data, response, error) in + let httpResponse = response as! NSHTTPURLResponse + let status = httpResponse.statusCode + + if status == 200 { + print("leave ok") + } + else { + print("leave error: \(status)") + } + } + + task.resume() + } + } + +} diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 8bf84a1c..0e8fd4b6 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -16,5 +16,11 @@ class ShowNetworksViewController: NSViewController { super.viewDidLoad() // Do view setup here. } + + override func viewWillAppear() { + super.viewWillAppear() + + ServiceCom.getNetworkList() + } } -- cgit v1.2.3 From d5620288d56085e749c04ae5bb9908a61238aaa4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 17 May 2016 19:41:54 -0700 Subject: Parse JSON network list into Network objects for the view --- ZeroTier One.xcodeproj/project.pbxproj | 4 + ZeroTier One/Network.swift | 112 ++++++++++++++++++++++++++ ZeroTier One/ServiceCom.swift | 13 ++- ZeroTier One/ShowNetworksViewController.swift | 23 +++++- ZeroTier One/ShowNetworksViewController.xib | 48 ++--------- 5 files changed, 151 insertions(+), 49 deletions(-) create mode 100644 ZeroTier One/Network.swift diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index d0441a5c..0fcc7860 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; + 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; }; 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; @@ -19,6 +20,7 @@ /* Begin PBXFileReference section */ 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; + 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -62,6 +64,7 @@ children = ( 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */, + 9330F1361CEBF87200687EC8 /* Network.swift */, 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */, 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */, 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, @@ -145,6 +148,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9330F1371CEBF87200687EC8 /* Network.swift in Sources */, 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift new file mode 100644 index 00000000..4ee2f748 --- /dev/null +++ b/ZeroTier One/Network.swift @@ -0,0 +1,112 @@ +// +// Network.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/17/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +enum NetworkStatus : CustomStringConvertible { + case REQUESTING_CONFIGURATION + case OK + case ACCESS_DENIED + case NOT_FOUND + case PORT_ERROR + case CLIENT_TOO_OLD + + var description: String { + switch self { + case .REQUESTING_CONFIGURATION: return "REQUESTING_CONFIGURATION" + case .OK: return "OK" + case .ACCESS_DENIED: return "ACCESS_DENIED" + case .NOT_FOUND: return "NOT_FOUND" + case .PORT_ERROR: return "PORT_ERROR" + case .CLIENT_TOO_OLD: return "CLIENT_TOO_OLD" + } + } +} + +enum NetworkType: CustomStringConvertible { + case PUBLIC + case PRIVATE + + var description: String { + switch self { + case .PUBLIC: return "PUBLIC" + case .PRIVATE: return "PRIVATE" + } + } +} + +class Network: NSObject { + var assignedAddresses: [String] = [String]() + var bridge: Bool = false + var broadcastEnabled: Bool = false + var dhcp: Bool = false + var mac: String = "" + var mtu: Int = 0 + var multicastSubscriptions: [String] = [String]() + var name: String = "" + var netconfRevision: Int = 232 + var nwid: UInt64 = 0 + var portDeviceName: String = "" + var portError: Int = 0 + var status: NetworkStatus = .REQUESTING_CONFIGURATION + var type: NetworkType = .PRIVATE + + init(jsonData: [String: AnyObject]) { + super.init() + + let aa = jsonData["assignedAddresses"] as! [String] + for a in aa { + assignedAddresses.append(a) + } + + bridge = (jsonData["bridge"] as! NSNumber).boolValue + broadcastEnabled = (jsonData["broadcastEnabled"] as! NSNumber).boolValue + dhcp = (jsonData["dhcp"] as! NSNumber).boolValue + mac = jsonData["mac"] as! String + mtu = (jsonData["mtu"] as! NSNumber).integerValue + + let multSubs = jsonData["multicastSubscriptions"] as! [String] + for ms in multSubs { + multicastSubscriptions.append(ms) + } + + name = jsonData["name"] as! String + netconfRevision = (jsonData["netconfRevision"] as! NSNumber).integerValue + nwid = UInt64((jsonData["nwid"] as! String), radix: 16)! + portDeviceName = jsonData["portDeviceName"] as! String + portError = (jsonData["portError"] as! NSNumber).integerValue + + let statusStr = jsonData["status"] as! String + switch statusStr { + case "REQUESTING_CONFIGURATION": + status = .REQUESTING_CONFIGURATION + case "OK": + status = .OK + case "ACCESS_DENIED": + status = .ACCESS_DENIED + case "NOT_FOUND": + status = .NOT_FOUND + case "PORT_ERROR": + status = .PORT_ERROR + case "CLIENT_TOO_OLD": + status = .CLIENT_TOO_OLD + default: + break + } + + let typeStr = jsonData["type"] as! String + switch typeStr { + case "PRIVATE": + type = .PRIVATE + case "PUBLIC": + type = .PUBLIC + default: + break + } + } +} diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index a1bb0a3c..bdb59792 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -12,7 +12,7 @@ class ServiceCom: NSObject { static let baseURL = "http://localhost:9993" static var key: NSString? = "ddeb3b1e6996b6b4f2d12d10" - static func getNetworkList() { + static func getNetworkList(completionHandler: ([Network]) -> Void) { let urlString = baseURL + "/network?auth=\(ServiceCom.key!)" @@ -27,11 +27,16 @@ class ServiceCom: NSObject { if status == 200 { do { - let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) - print("\(json)") + let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions()) as! [[String: AnyObject]] + + var networks = [Network]() + for jobj in json { + networks.append(Network(jsonData: jobj)) + } + + completionHandler(networks) } catch { - print("JSON Error: \(error)") } } } diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 0e8fd4b6..d914c30e 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -8,19 +8,36 @@ import Cocoa -class ShowNetworksViewController: NSViewController { +class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource { @IBOutlet var tableView: NSTableView! + var networkList: [Network] = [Network]() + override func viewDidLoad() { super.viewDidLoad() // Do view setup here. + + tableView.setDelegate(self) + tableView.setDataSource(self) } override func viewWillAppear() { super.viewWillAppear() - ServiceCom.getNetworkList() + ServiceCom.getNetworkList() { (networkList) -> Void in + NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in + self.networkList = networkList + self.tableView.reloadData() + } + } + } + + // NSTableViewDataSource + + func numberOfRowsInTableView(tableView: NSTableView) -> Int { + return networkList.count } - + + // end NSTableViewDataSource } diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index e17bc5a9..fcc6cbfa 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -20,17 +20,17 @@ - + - - + + - + @@ -44,7 +44,7 @@ - + @@ -62,44 +62,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From 940c0f2b93ab2cebd55f5f0199499b68fef07d90 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 27 May 2016 13:28:32 -0700 Subject: WIP. Mac UI --- ZeroTier One.xcodeproj/project.pbxproj | 4 + ZeroTier One/NetworkInfoCell.swift | 22 ++++ ZeroTier One/ShowNetworksViewController.swift | 16 +++ ZeroTier One/ShowNetworksViewController.xib | 143 +++++++++++++++++++++++--- 4 files changed, 170 insertions(+), 15 deletions(-) create mode 100644 ZeroTier One/NetworkInfoCell.swift diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 0fcc7860..256d75e7 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; + 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; }; 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */; }; 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; @@ -21,6 +22,7 @@ /* Begin PBXFileReference section */ 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; + 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = ""; }; 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -65,6 +67,7 @@ 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */, 9330F1361CEBF87200687EC8 /* Network.swift */, + 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */, 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */, 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */, 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, @@ -150,6 +153,7 @@ files = ( 9330F1371CEBF87200687EC8 /* Network.swift in Sources */, 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, + 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */, 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */, diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift new file mode 100644 index 00000000..694eded5 --- /dev/null +++ b/ZeroTier One/NetworkInfoCell.swift @@ -0,0 +1,22 @@ +// +// NetworkInfoCell.swift +// ZeroTier One +// +// Created by Grant Limberg on 5/24/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class NetworkInfoCell: NSTableCellView { + + @IBOutlet var networkIdField: NSTextField! + @IBOutlet var networkNameField: NSTextField! + + override func drawRect(dirtyRect: NSRect) { + super.drawRect(dirtyRect) + + // Drawing code here. + } + +} diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index d914c30e..53f2e0f4 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -40,4 +40,20 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable } // end NSTableViewDataSource + + // NSTableViewDelegate + + func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? { + if let cell = tableView.makeViewWithIdentifier("NetworkInfoCell", owner: nil) as? NetworkInfoCell { + let network = networkList[row] + cell.networkIdField.stringValue = String(network.nwid, radix: 16) + cell.networkNameField.stringValue = network.name + + return cell + } + + return nil + } + + // end NSTableViewDelegate } diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index fcc6cbfa..85dee589 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -14,23 +14,23 @@ - + - - - - + + + + - - + + - + @@ -43,21 +43,127 @@ - - + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -77,6 +183,13 @@ + + + + + + + -- cgit v1.2.3 From 1d27adb1021852709f144b6fef11cf83ef593e80 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 27 May 2016 13:48:22 -0700 Subject: Finished wiring up the view --- ZeroTier One/NetworkInfoCell.swift | 9 ++ ZeroTier One/ShowNetworksViewController.swift | 17 ++++ ZeroTier One/ShowNetworksViewController.xib | 121 ++++++++++++++++++++++---- 3 files changed, 129 insertions(+), 18 deletions(-) diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index 694eded5..038507ca 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -13,6 +13,15 @@ class NetworkInfoCell: NSTableCellView { @IBOutlet var networkIdField: NSTextField! @IBOutlet var networkNameField: NSTextField! + @IBOutlet var statusField: NSTextField! + @IBOutlet var typeField: NSTextField! + @IBOutlet var macField: NSTextField! + @IBOutlet var mtuField: NSTextField! + @IBOutlet var broadcastField: NSTextField! + @IBOutlet var bridgingField: NSTextField! + @IBOutlet var deviceField: NSTextField! + @IBOutlet var addressesField: NSTextField! + override func drawRect(dirtyRect: NSRect) { super.drawRect(dirtyRect) diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 53f2e0f4..a12e0743 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -49,6 +49,23 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable cell.networkIdField.stringValue = String(network.nwid, radix: 16) cell.networkNameField.stringValue = network.name + cell.statusField.stringValue = network.status.description + cell.typeField.stringValue = network.type.description + cell.macField.stringValue = network.mac + cell.mtuField.stringValue = String(network.mtu) + cell.broadcastField.stringValue = network.broadcastEnabled ? "ENABLED" : "DISABLED" + cell.bridgingField.stringValue = network.bridge ? "ENABLED" : "DISABLED" + cell.deviceField.stringValue = network.portDeviceName + + + cell.addressesField.stringValue = "" + + for nw in network.assignedAddresses { + cell.addressesField.stringValue += nw + cell.addressesField.stringValue += "\n" + } + + return cell } diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 85dee589..93286f86 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -17,14 +17,14 @@ - + - - + + @@ -44,11 +44,11 @@ - + - + @@ -56,7 +56,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -128,8 +128,64 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -137,33 +193,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 67d472424d92e1bd8dd2fff8d9ca911035569faf Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 27 May 2016 15:07:20 -0700 Subject: make the view show up light instead of dark --- ZeroTier One/AppDelegate.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index e5932f5f..c7cbc09a 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -39,9 +39,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { nibName: "JoinNetworkViewController", bundle: nil) joinNetworkPopover.behavior = .Transient + joinNetworkPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) + networkListPopover.contentViewController = ShowNetworksViewController( nibName: "ShowNetworksViewController", bundle: nil) networkListPopover.behavior = .Transient + + networkListPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) } func applicationWillTerminate(aNotification: NSNotification) { -- cgit v1.2.3 From 59cf2ea34158ef6f6e827fbd9d062be6beef5691 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 27 May 2016 15:21:23 -0700 Subject: add proper border around the network list --- ZeroTier One/ShowNetworksViewController.swift | 1 + ZeroTier One/ShowNetworksViewController.xib | 40 +++++++++++++-------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index a12e0743..857e2147 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -20,6 +20,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable tableView.setDelegate(self) tableView.setDataSource(self) + tableView.backgroundColor = NSColor.clearColor() } override func viewWillAppear() { diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 93286f86..6b12ea3f 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -14,23 +14,23 @@ - + - - + + - + - + - + @@ -44,7 +44,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -151,7 +151,7 @@ - + @@ -159,7 +159,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -175,7 +175,7 @@ - + @@ -269,12 +269,12 @@ - - - - + + + + - + -- cgit v1.2.3 From 41328eef94e0f45a890c57b9d85862c7a54e0175 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 27 May 2016 15:25:32 -0700 Subject: . --- ZeroTier One/NetworkInfoCell.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index 038507ca..73305f83 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -22,6 +22,10 @@ class NetworkInfoCell: NSTableCellView { @IBOutlet var deviceField: NSTextField! @IBOutlet var addressesField: NSTextField! + override func awakeFromNib() { + super.awakeFromNib() + + } override func drawRect(dirtyRect: NSRect) { super.drawRect(dirtyRect) -- cgit v1.2.3 From b4f3dfc34727ec99853e22e7abb0c1dff9e5c205 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 May 2016 13:50:43 -0700 Subject: look up authtoken in user's app support directory --- ZeroTier One/ServiceCom.swift | 53 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index bdb59792..28957265 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -10,11 +10,56 @@ import Cocoa class ServiceCom: NSObject { static let baseURL = "http://localhost:9993" - static var key: NSString? = "ddeb3b1e6996b6b4f2d12d10" + + private static func getKey() -> String { + struct Holder { + static var key: String? = nil + } + + if Holder.key == nil { + do { + // Check the user's ZeroTier application support directory. If + // authtoken.secret exists, use it. + + var appSupportDir = try NSFileManager.defaultManager().URLForDirectory(.ApplicationSupportDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false) + NSLog("\(appSupportDir)") + + + appSupportDir = appSupportDir.URLByAppendingPathComponent("ZeroTier") + NSLog("\(appSupportDir)") + + appSupportDir = appSupportDir.URLByAppendingPathComponent("One") + NSLog("\(appSupportDir)") + + let authtokenURL = appSupportDir.URLByAppendingPathComponent("authtoken.secret") + + NSLog("\(authtokenURL)") + + if NSFileManager.defaultManager().fileExistsAtPath(authtokenURL.path!) { + Holder.key = try String(contentsOfURL: authtokenURL) + } + else { + // TODO: Elevate priviledge to copy /Library/Application Support/ZeroTier/One/authtoken.secret to the user's local AppSupport directory + } + } + catch { + NSLog("Error getting app support dir: \(error)") + Holder.key = nil + } + + } + + if let k = Holder.key { + return k + } + else { + return "" + } + } static func getNetworkList(completionHandler: ([Network]) -> Void) { - let urlString = baseURL + "/network?auth=\(ServiceCom.key!)" + let urlString = baseURL + "/network?auth=\(ServiceCom.getKey())" let url = NSURL(string: urlString) @@ -50,7 +95,7 @@ class ServiceCom: NSObject { static func joinNetwork(network: String) { - let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.key!)" + let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())" let url = NSURL(string: urlString) if let u = url { @@ -75,7 +120,7 @@ class ServiceCom: NSObject { } static func leaveNetwork(network: String) { - let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.key!)" + let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())" let url = NSURL(string: urlString) if let u = url { -- cgit v1.2.3 From 51e74f8d4f200a7e3be9a6ac4bef8486f83a5d5d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 May 2016 15:01:42 -0700 Subject: remove some extra logging --- ZeroTier One/ServiceCom.swift | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 28957265..3aa9dc54 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -22,19 +22,10 @@ class ServiceCom: NSObject { // authtoken.secret exists, use it. var appSupportDir = try NSFileManager.defaultManager().URLForDirectory(.ApplicationSupportDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false) - NSLog("\(appSupportDir)") - - appSupportDir = appSupportDir.URLByAppendingPathComponent("ZeroTier") - NSLog("\(appSupportDir)") - appSupportDir = appSupportDir.URLByAppendingPathComponent("One") - NSLog("\(appSupportDir)") - let authtokenURL = appSupportDir.URLByAppendingPathComponent("authtoken.secret") - NSLog("\(authtokenURL)") - if NSFileManager.defaultManager().fileExistsAtPath(authtokenURL.path!) { Holder.key = try String(contentsOfURL: authtokenURL) } -- cgit v1.2.3 From 975bcb8affa7fbd7ca534dac9ec8d642e6c977f7 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 May 2016 17:19:22 -0700 Subject: some OS X Authentication Services wizardry to get /Library/Application Support/ZeroTier/One/authtoken.secret and copy it to ~/Library/Application Support/ZeroTier/One/authtoken.secret --- ZeroTier One.xcodeproj/project.pbxproj | 13 +++++ ZeroTier One/AuthtokenCopy.h | 16 ++++++ ZeroTier One/AuthtokenCopy.m | 87 +++++++++++++++++++++++++++++ ZeroTier One/ServiceCom.swift | 31 +++++++++- ZeroTier One/ZeroTier One-Bridging-Header.h | 5 ++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 ZeroTier One/AuthtokenCopy.h create mode 100644 ZeroTier One/AuthtokenCopy.m create mode 100644 ZeroTier One/ZeroTier One-Bridging-Header.h diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 256d75e7..7c1e29be 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */; }; 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */; }; 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */; }; + 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -32,6 +33,9 @@ 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JoinNetworkViewController.xib; sourceTree = ""; }; 93326BEC1CE7DA30005CA2AC /* ShowNetworksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShowNetworksViewController.swift; sourceTree = ""; }; 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowNetworksViewController.xib; sourceTree = ""; }; + 93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ZeroTier One-Bridging-Header.h"; sourceTree = ""; }; + 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthtokenCopy.m; sourceTree = ""; }; + 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthtokenCopy.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -75,6 +79,9 @@ 93326BE21CE7C816005CA2AC /* Info.plist */, 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */, 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */, + 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */, + 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */, + 93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */, ); path = "ZeroTier One"; sourceTree = ""; @@ -153,6 +160,7 @@ files = ( 9330F1371CEBF87200687EC8 /* Network.swift in Sources */, 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, + 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */, 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */, 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, @@ -260,11 +268,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; }; @@ -272,11 +283,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; }; name = Release; }; diff --git a/ZeroTier One/AuthtokenCopy.h b/ZeroTier One/AuthtokenCopy.h new file mode 100644 index 00000000..43c927e2 --- /dev/null +++ b/ZeroTier One/AuthtokenCopy.h @@ -0,0 +1,16 @@ +// +// AuthtokenCopy.h +// ZeroTier One +// +// Created by Grant Limberg on 5/31/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +#ifndef AuthtokenCopy_h +#define AuthtokenCopy_h + +#import + +NSString* getAdminAuthToken(AuthorizationRef authRef); + +#endif /* AuthtokenCopy_h */ diff --git a/ZeroTier One/AuthtokenCopy.m b/ZeroTier One/AuthtokenCopy.m new file mode 100644 index 00000000..893d90cf --- /dev/null +++ b/ZeroTier One/AuthtokenCopy.m @@ -0,0 +1,87 @@ +// +// AuthtokenCopy.m +// ZeroTier One +// +// Created by Grant Limberg on 5/31/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +#import + +#import "AuthtokenCopy.h" + + +NSString* getAdminAuthToken(AuthorizationRef authRef) { + char *tool = "/bin/cat"; + char *args[] = { "/Library/Application Support/ZeroTier/One/authtoken.secret", NULL}; + FILE *pipe = nil; + char token[25]; + memset(token, 0, sizeof(char)*25); + + + OSStatus status = AuthorizationExecuteWithPrivileges(authRef, tool, kAuthorizationFlagDefaults, args, &pipe); + + if (status != errAuthorizationSuccess) { + NSLog(@"Reading authtoken failed!"); + + + switch(status) { + case errAuthorizationDenied: + NSLog(@"Autorization Denied"); + break; + case errAuthorizationCanceled: + NSLog(@"Authorization Canceled"); + break; + case errAuthorizationInternal: + NSLog(@"Authorization Internal"); + break; + case errAuthorizationBadAddress: + NSLog(@"Bad Address"); + break; + case errAuthorizationInvalidRef: + NSLog(@"Invalid Ref"); + break; + case errAuthorizationInvalidSet: + NSLog(@"Invalid Set"); + break; + case errAuthorizationInvalidTag: + NSLog(@"Invalid Tag"); + break; + case errAuthorizationInvalidFlags: + NSLog(@"Invalid Flags"); + break; + case errAuthorizationInvalidPointer: + NSLog(@"Invalid Pointer"); + break; + case errAuthorizationToolExecuteFailure: + NSLog(@"Tool Execute Failure"); + break; + case errAuthorizationToolEnvironmentError: + NSLog(@"Tool Environment Failure"); + break; + case errAuthorizationExternalizeNotAllowed: + NSLog(@"Externalize Not Allowed"); + break; + case errAuthorizationInteractionNotAllowed: + NSLog(@"Interaction Not Allowed"); + break; + case errAuthorizationInternalizeNotAllowed: + NSLog(@"Internalize Not Allowed"); + break; + default: + NSLog(@"Unknown Error"); + break; + } + + return @""; + } + + if(pipe != nil) { + fread(&token, sizeof(char), 24, pipe); + fclose(pipe); + + return [NSString stringWithUTF8String:token]; + } + + return @""; +} \ No newline at end of file diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 3aa9dc54..e2526610 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -30,7 +30,36 @@ class ServiceCom: NSObject { Holder.key = try String(contentsOfURL: authtokenURL) } else { - // TODO: Elevate priviledge to copy /Library/Application Support/ZeroTier/One/authtoken.secret to the user's local AppSupport directory + try NSFileManager.defaultManager().createDirectoryAtURL(appSupportDir, withIntermediateDirectories: true, attributes: nil) + + var authRef: AuthorizationRef = nil + var status = AuthorizationCreate(nil, nil, .Defaults, &authRef) + + if status != errAuthorizationSuccess { + NSLog("Authorization Failed! \(status)") + return "" + } + + var authItem = AuthorizationItem(name: kAuthorizationRightExecute, valueLength: 0, value: nil, flags: 0) + var authRights = AuthorizationRights(count: 1, items: &authItem) + let authFlags: AuthorizationFlags = [.Defaults, .InteractionAllowed, .PreAuthorize, .ExtendRights] + + status = AuthorizationCopyRights(authRef, &authRights, nil, authFlags, nil) + + if status != errAuthorizationSuccess { + NSLog("Authorization Failed! \(status)") + return "" + } + + let localKey = getAdminAuthToken(authRef) + AuthorizationFree(authRef, .DestroyRights) + + if localKey != nil && localKey.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) > 0 { + NSLog("\(localKey)") + Holder.key = localKey + + try localKey.writeToURL(authtokenURL, atomically: true, encoding: NSUTF8StringEncoding) + } } } catch { diff --git a/ZeroTier One/ZeroTier One-Bridging-Header.h b/ZeroTier One/ZeroTier One-Bridging-Header.h new file mode 100644 index 00000000..68795a0e --- /dev/null +++ b/ZeroTier One/ZeroTier One-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "AuthtokenCopy.h" -- cgit v1.2.3 From 188f8021f806ff922924949054b94e53dc0fed30 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Jun 2016 19:59:05 -0700 Subject: Joining/Deleting networks now implemented. Still need to implement known networks cache so we can join/leave networks without deleting them from the UI --- ZeroTier One/JoinNetworkViewController.swift | 2 +- ZeroTier One/NetworkInfoCell.swift | 32 +++++++++++- ZeroTier One/ShowNetworksViewController.swift | 5 ++ ZeroTier One/ShowNetworksViewController.xib | 75 ++++++++++++++++++--------- 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index 1ac3c7ea..cc768254 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -62,7 +62,7 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo let networkString = network.stringValue let networkId = UInt64(networkString, radix: 16) - // TODO: Execute join network call + ServiceCom.joinNetwork(networkString) network.stringValue = "" diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index 73305f83..c31fcb91 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -10,6 +10,8 @@ import Cocoa class NetworkInfoCell: NSTableCellView { + weak var parent: ShowNetworksViewController! + @IBOutlet var networkIdField: NSTextField! @IBOutlet var networkNameField: NSTextField! @@ -22,6 +24,9 @@ class NetworkInfoCell: NSTableCellView { @IBOutlet var deviceField: NSTextField! @IBOutlet var addressesField: NSTextField! + @IBOutlet var connectedCheckbox: NSButton! + @IBOutlet var deleteButton: NSButton! + override func awakeFromNib() { super.awakeFromNib() @@ -31,5 +36,30 @@ class NetworkInfoCell: NSTableCellView { // Drawing code here. } - + + @IBAction func onConnectCheckStateChanged(sender: NSButton) { + NSLog("Checked State Changed") + + if(sender.state == NSOnState) { + NSLog("Checked") + joinNetwork(networkIdField.stringValue) + } + else { + NSLog("Unchecked") + leaveNetwork(networkIdField.stringValue) + } + } + + @IBAction func deleteNetwork(sender: NSButton) { + leaveNetwork(networkIdField.stringValue) + parent.deleteNetworkFromList(networkIdField.stringValue) + } + + func joinNetwork(nwid: String) { + ServiceCom.joinNetwork(nwid) + } + + func leaveNetwork(nwid: String) { + ServiceCom.leaveNetwork(nwid) + } } diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 857e2147..33148f83 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -34,6 +34,10 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable } } + func deleteNetworkFromList(nwid: String) { + + } + // NSTableViewDataSource func numberOfRowsInTableView(tableView: NSTableView) -> Int { @@ -47,6 +51,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? { if let cell = tableView.makeViewWithIdentifier("NetworkInfoCell", owner: nil) as? NetworkInfoCell { let network = networkList[row] + cell.parent = self cell.networkIdField.stringValue = String(network.nwid, radix: 16) cell.networkNameField.stringValue = network.name diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 6b12ea3f..12f1ea3c 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -17,14 +17,14 @@ - + - - + + @@ -44,11 +44,11 @@ - + - + @@ -56,7 +56,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -128,7 +128,7 @@ - + @@ -136,7 +136,7 @@ - + @@ -144,7 +144,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -160,7 +160,7 @@ - + @@ -168,7 +168,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -184,13 +184,33 @@ - + + + @@ -210,6 +230,7 @@ + @@ -222,14 +243,18 @@ + + + + @@ -242,6 +267,8 @@ + + -- cgit v1.2.3 From b085329bca3e1eb1300045bf2cd2df52039e99d9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 13 Jun 2016 19:46:54 -0700 Subject: Base functionality complete. Can join/leave/list networks. Can disconnect from networks without removing them from the network list. --- ZeroTier One/Network.swift | 62 ++++++++++++++++++- ZeroTier One/ShowNetworksViewController.swift | 89 +++++++++++++++++++++++++-- 2 files changed, 143 insertions(+), 8 deletions(-) diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index 4ee2f748..28f3eda6 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -8,7 +8,7 @@ import Cocoa -enum NetworkStatus : CustomStringConvertible { +enum NetworkStatus : Int, CustomStringConvertible { case REQUESTING_CONFIGURATION case OK case ACCESS_DENIED @@ -28,7 +28,7 @@ enum NetworkStatus : CustomStringConvertible { } } -enum NetworkType: CustomStringConvertible { +enum NetworkType: Int, CustomStringConvertible { case PUBLIC case PRIVATE @@ -40,7 +40,25 @@ enum NetworkType: CustomStringConvertible { } } -class Network: NSObject { + +struct PropertyKeys { + static let addressesKey = "addresses" + static let bridgeKey = "bridge" + static let broadcastKey = "broadcast" + static let dhcpKey = "dhcp" + static let macKey = "mac" + static let mtuKey = "mtu" + static let multicastKey = "multicast" + static let nameKey = "name" + static let netconfKey = "netconf" + static let nwidKey = "nwid" + static let portNameKey = "port" + static let portErrorKey = "portError" + static let statusKey = "status" + static let typeKey = "type" +} + +class Network: NSObject, NSCoding { var assignedAddresses: [String] = [String]() var bridge: Bool = false var broadcastEnabled: Bool = false @@ -55,6 +73,7 @@ class Network: NSObject { var portError: Int = 0 var status: NetworkStatus = .REQUESTING_CONFIGURATION var type: NetworkType = .PRIVATE + var connected: Bool = false // NOT PERSISTED. Set to true if loaded via JSON init(jsonData: [String: AnyObject]) { super.init() @@ -108,5 +127,42 @@ class Network: NSObject { default: break } + + // if it's being initialized via JSON, it's connected + connected = true + } + + required init?(coder aDecoder: NSCoder) { + self.assignedAddresses = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + self.bridge = aDecoder.decodeBoolForKey(PropertyKeys.bridgeKey) + self.broadcastEnabled = aDecoder.decodeBoolForKey(PropertyKeys.broadcastKey) + self.dhcp = aDecoder.decodeBoolForKey(PropertyKeys.dhcpKey) + self.mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + self.mtu = aDecoder.decodeIntegerForKey(PropertyKeys.mtuKey) + self.multicastSubscriptions = aDecoder.decodeObjectForKey(PropertyKeys.multicastKey) as! [String] + self.name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + self.netconfRevision = aDecoder.decodeIntegerForKey(PropertyKeys.netconfKey) + self.nwid = (aDecoder.decodeObjectForKey(PropertyKeys.nwidKey) as! NSNumber).unsignedLongLongValue + self.portDeviceName = aDecoder.decodeObjectForKey(PropertyKeys.portNameKey) as! String + self.portError = aDecoder.decodeIntegerForKey(PropertyKeys.portErrorKey) + self.status = NetworkStatus(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.statusKey))! + self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))! + } + + func encodeWithCoder(aCoder: NSCoder) { + aCoder.encodeObject(self.assignedAddresses, forKey: PropertyKeys.addressesKey) + aCoder.encodeBool(self.bridge, forKey: PropertyKeys.bridgeKey) + aCoder.encodeBool(self.broadcastEnabled, forKey: PropertyKeys.broadcastKey) + aCoder.encodeBool(self.dhcp, forKey: PropertyKeys.dhcpKey) + aCoder.encodeObject(self.mac, forKey: PropertyKeys.macKey) + aCoder.encodeInteger(self.mtu, forKey: PropertyKeys.mtuKey) + aCoder.encodeObject(self.multicastSubscriptions, forKey: PropertyKeys.multicastKey) + aCoder.encodeObject(self.name, forKey: PropertyKeys.nameKey) + aCoder.encodeInteger(self.netconfRevision, forKey: PropertyKeys.netconfKey) + aCoder.encodeObject(NSNumber(unsignedLongLong: self.nwid), forKey: PropertyKeys.nwidKey) + aCoder.encodeObject(self.portDeviceName, forKey: PropertyKeys.portNameKey) + aCoder.encodeInteger(self.portError, forKey: PropertyKeys.portErrorKey) + aCoder.encodeInteger(self.status.rawValue, forKey: PropertyKeys.statusKey) + aCoder.encodeInteger(self.type.rawValue, forKey: PropertyKeys.typeKey) } } diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 33148f83..ed2479d1 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -23,19 +23,92 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable tableView.backgroundColor = NSColor.clearColor() } + private func dataFile() -> String { + var appSupport = NSFileManager.defaultManager().URLsForDirectory(.ApplicationSupportDirectory, inDomains: .UserDomainMask)[0] + appSupport = appSupport.URLByAppendingPathComponent("ZeroTier").URLByAppendingPathComponent("One").URLByAppendingPathComponent("networks.dat") + return appSupport.path! + } + + + private func findNetworkWithID(id: UInt64) -> Int { + + for (index, element) in networkList.enumerate() { + + if element.nwid == id { + return index + } + } + + return NSNotFound + } + override func viewWillAppear() { super.viewWillAppear() - ServiceCom.getNetworkList() { (networkList) -> Void in - NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in - self.networkList = networkList - self.tableView.reloadData() + let filePath = dataFile() + + if NSFileManager.defaultManager().fileExistsAtPath(filePath) { + networkList = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + + ServiceCom.getNetworkList() { (networkList) -> Void in + + for nw in networkList { + let index = self.findNetworkWithID(nw.nwid) + + if index != NSNotFound { + self.networkList[index] = nw + } + else { + self.networkList.append(nw) + } + } + + NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in + self.networkList.sortInPlace({ (left, right) -> Bool in + if left.nwid < right.nwid { + return true + } + + return false + }) + self.tableView.reloadData() + } + } + } + else { + ServiceCom.getNetworkList() { (networkList) -> Void in + NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in + self.networkList.sortInPlace({ (left, right) -> Bool in + if left.nwid < right.nwid { + return true + } + + return false + }) + + self.networkList = networkList + self.tableView.reloadData() + } } } } + override func viewWillDisappear() { + super.viewWillDisappear() + + let filePath = dataFile() + NSKeyedArchiver.archiveRootObject(self.networkList, toFile: filePath) + } + func deleteNetworkFromList(nwid: String) { - + if let nwid = UInt64(nwid, radix: 16) { + let index = findNetworkWithID(nwid) + + if index != NSNotFound { + networkList.removeAtIndex(index) + tableView.reloadData() + } + } } // NSTableViewDataSource @@ -71,6 +144,12 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable cell.addressesField.stringValue += "\n" } + if network.connected { + cell.connectedCheckbox.state = NSOnState + } + else { + cell.connectedCheckbox.state = NSOffState + } return cell } -- cgit v1.2.3 From 2c1a8524f0e79b8eb4a7e7160960bd4402d06a6e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 13 Jun 2016 19:56:43 -0700 Subject: remove unused variables --- ZeroTier One/JoinNetworkViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index cc768254..92e30cae 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -60,7 +60,6 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo @IBAction func onJoinClicked(sender: AnyObject?) { let networkString = network.stringValue - let networkId = UInt64(networkString, radix: 16) ServiceCom.joinNetwork(networkString) -- cgit v1.2.3 From 89cb0e260a65540ab6f3538ede1dc2493b031aba Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 13 Jun 2016 19:58:21 -0700 Subject: Set deployment target to 10.10 for the minimum OS X version for this app I'm currently using features only available in 10.10 or above. We'll have to discuss this and see what can be done for OS X 10.7 through 10.9. --- ZeroTier One.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 7c1e29be..0a8188c9 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -272,6 +272,7 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; @@ -287,6 +288,7 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; -- cgit v1.2.3 From c8750e5812f6ad453cb482fe3ff629536e376960 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 14 Jun 2016 18:09:30 -0700 Subject: more error checking when parsing JSON for network list remove "multicastSubscriptions" field as it isn't used anyway --- ZeroTier One/Info.plist | 16 ++-- ZeroTier One/Network.swift | 189 ++++++++++++++++++++++++++++++--------------- 2 files changed, 133 insertions(+), 72 deletions(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 7a6ab723..5777ef6c 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -2,13 +2,6 @@ - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - LSUIElement - CFBundleDevelopmentRegion en CFBundleExecutable @@ -28,9 +21,16 @@ CFBundleSignature ???? CFBundleVersion - 1 + 2 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSHumanReadableCopyright Copyright © 2016 ZeroTier, Inc. All rights reserved. NSMainNibFile diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index 28f3eda6..95b3d93f 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -65,7 +65,6 @@ class Network: NSObject, NSCoding { var dhcp: Bool = false var mac: String = "" var mtu: Int = 0 - var multicastSubscriptions: [String] = [String]() var name: String = "" var netconfRevision: Int = 232 var nwid: UInt64 = 0 @@ -78,54 +77,80 @@ class Network: NSObject, NSCoding { init(jsonData: [String: AnyObject]) { super.init() - let aa = jsonData["assignedAddresses"] as! [String] - for a in aa { - assignedAddresses.append(a) - } - - bridge = (jsonData["bridge"] as! NSNumber).boolValue - broadcastEnabled = (jsonData["broadcastEnabled"] as! NSNumber).boolValue - dhcp = (jsonData["dhcp"] as! NSNumber).boolValue - mac = jsonData["mac"] as! String - mtu = (jsonData["mtu"] as! NSNumber).integerValue - - let multSubs = jsonData["multicastSubscriptions"] as! [String] - for ms in multSubs { - multicastSubscriptions.append(ms) - } - - name = jsonData["name"] as! String - netconfRevision = (jsonData["netconfRevision"] as! NSNumber).integerValue - nwid = UInt64((jsonData["nwid"] as! String), radix: 16)! - portDeviceName = jsonData["portDeviceName"] as! String - portError = (jsonData["portError"] as! NSNumber).integerValue - - let statusStr = jsonData["status"] as! String - switch statusStr { - case "REQUESTING_CONFIGURATION": - status = .REQUESTING_CONFIGURATION - case "OK": - status = .OK - case "ACCESS_DENIED": - status = .ACCESS_DENIED - case "NOT_FOUND": - status = .NOT_FOUND - case "PORT_ERROR": - status = .PORT_ERROR - case "CLIENT_TOO_OLD": - status = .CLIENT_TOO_OLD - default: - break - } - - let typeStr = jsonData["type"] as! String - switch typeStr { - case "PRIVATE": - type = .PRIVATE - case "PUBLIC": - type = .PUBLIC - default: - break + if let aa = jsonData["assignedAddresses"] as? [String] { + for a in aa { + assignedAddresses.append(a) + } + } + + if let b = jsonData["bridge"] as? NSNumber { + bridge = b.boolValue + } + + if let b = jsonData["broadcastEnabled"] as? NSNumber { + broadcastEnabled = b.boolValue + } + + if let d = jsonData["dhcp"] as? NSNumber { + dhcp = d.boolValue + } + + if let m = jsonData["mac"] as? String { + mac = m + } + + if let m = jsonData["mtu"] as? NSNumber { + mtu = m.integerValue + } + + if let n = jsonData["name"] as? String { + name = n + } + + if let n = jsonData["netconfRevision"] as? NSNumber { + netconfRevision = n.integerValue + } + + if let n = UInt64((jsonData["nwid"] as! String), radix: 16) { + nwid = n + } + + if let p = jsonData["portDeviceName"] as? String { + portDeviceName = p + } + + if let p = jsonData["portError"] as? NSNumber { + portError = p.integerValue + } + + if let statusStr = jsonData["status"] as? String { + switch statusStr { + case "REQUESTING_CONFIGURATION": + status = .REQUESTING_CONFIGURATION + case "OK": + status = .OK + case "ACCESS_DENIED": + status = .ACCESS_DENIED + case "NOT_FOUND": + status = .NOT_FOUND + case "PORT_ERROR": + status = .PORT_ERROR + case "CLIENT_TOO_OLD": + status = .CLIENT_TOO_OLD + default: + break + } + } + + if let typeStr = jsonData["type"] as? String { + switch typeStr { + case "PRIVATE": + type = .PRIVATE + case "PUBLIC": + type = .PUBLIC + default: + break + } } // if it's being initialized via JSON, it's connected @@ -133,20 +158,57 @@ class Network: NSObject, NSCoding { } required init?(coder aDecoder: NSCoder) { - self.assignedAddresses = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] - self.bridge = aDecoder.decodeBoolForKey(PropertyKeys.bridgeKey) - self.broadcastEnabled = aDecoder.decodeBoolForKey(PropertyKeys.broadcastKey) - self.dhcp = aDecoder.decodeBoolForKey(PropertyKeys.dhcpKey) - self.mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String - self.mtu = aDecoder.decodeIntegerForKey(PropertyKeys.mtuKey) - self.multicastSubscriptions = aDecoder.decodeObjectForKey(PropertyKeys.multicastKey) as! [String] - self.name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String - self.netconfRevision = aDecoder.decodeIntegerForKey(PropertyKeys.netconfKey) - self.nwid = (aDecoder.decodeObjectForKey(PropertyKeys.nwidKey) as! NSNumber).unsignedLongLongValue - self.portDeviceName = aDecoder.decodeObjectForKey(PropertyKeys.portNameKey) as! String - self.portError = aDecoder.decodeIntegerForKey(PropertyKeys.portErrorKey) - self.status = NetworkStatus(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.statusKey))! - self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))! + if aDecoder.containsValueForKey(PropertyKeys.addressesKey) { + self.assignedAddresses = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + } + + if aDecoder.containsValueForKey(PropertyKeys.bridgeKey) { + self.bridge = aDecoder.decodeBoolForKey(PropertyKeys.bridgeKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.broadcastKey) { + self.broadcastEnabled = aDecoder.decodeBoolForKey(PropertyKeys.broadcastKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.dhcpKey) { + self.dhcp = aDecoder.decodeBoolForKey(PropertyKeys.dhcpKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.macKey) { + self.mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + } + + if aDecoder.containsValueForKey(PropertyKeys.mtuKey) { + self.mtu = aDecoder.decodeIntegerForKey(PropertyKeys.mtuKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.nameKey) { + self.name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + } + + if aDecoder.containsValueForKey(PropertyKeys.netconfKey) { + self.netconfRevision = aDecoder.decodeIntegerForKey(PropertyKeys.netconfKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.nwidKey) { + self.nwid = (aDecoder.decodeObjectForKey(PropertyKeys.nwidKey) as! NSNumber).unsignedLongLongValue + } + + if aDecoder.containsValueForKey(PropertyKeys.portNameKey) { + self.portDeviceName = aDecoder.decodeObjectForKey(PropertyKeys.portNameKey) as! String + } + + if aDecoder.containsValueForKey(PropertyKeys.portErrorKey) { + self.portError = aDecoder.decodeIntegerForKey(PropertyKeys.portErrorKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.statusKey) { + self.status = NetworkStatus(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.statusKey))! + } + + if aDecoder.containsValueForKey(PropertyKeys.typeKey) { + self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))! + } } func encodeWithCoder(aCoder: NSCoder) { @@ -156,7 +218,6 @@ class Network: NSObject, NSCoding { aCoder.encodeBool(self.dhcp, forKey: PropertyKeys.dhcpKey) aCoder.encodeObject(self.mac, forKey: PropertyKeys.macKey) aCoder.encodeInteger(self.mtu, forKey: PropertyKeys.mtuKey) - aCoder.encodeObject(self.multicastSubscriptions, forKey: PropertyKeys.multicastKey) aCoder.encodeObject(self.name, forKey: PropertyKeys.nameKey) aCoder.encodeInteger(self.netconfRevision, forKey: PropertyKeys.netconfKey) aCoder.encodeObject(NSNumber(unsignedLongLong: self.nwid), forKey: PropertyKeys.nwidKey) -- cgit v1.2.3 From bae0060552e652559937287f160a550622a5cab8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 14 Jun 2016 19:59:45 -0700 Subject: add a timer to retrieve the network list every second. --- ZeroTier One/ShowNetworksViewController.swift | 51 ++++++++++++++++----------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index ed2479d1..d9a4291a 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -14,6 +14,9 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable var networkList: [Network] = [Network]() + + var timer: NSTimer? = nil + override func viewDidLoad() { super.viewDidLoad() // Do view setup here. @@ -45,10 +48,36 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable override func viewWillAppear() { super.viewWillAppear() + updateNetworkInfo() + + self.timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(updateNetworkInfo), userInfo: nil, repeats: true) + } + + override func viewWillDisappear() { + super.viewWillDisappear() + + self.timer?.invalidate() + let filePath = dataFile() + NSKeyedArchiver.archiveRootObject(self.networkList, toFile: filePath) + } + + func deleteNetworkFromList(nwid: String) { + if let nwid = UInt64(nwid, radix: 16) { + let index = findNetworkWithID(nwid) + + if index != NSNotFound { + networkList.removeAtIndex(index) + tableView.reloadData() + } + } + } + + func updateNetworkInfo() { + let filePath = self.dataFile() if NSFileManager.defaultManager().fileExistsAtPath(filePath) { - networkList = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + self.networkList = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] ServiceCom.getNetworkList() { (networkList) -> Void in @@ -85,7 +114,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable return false }) - + self.networkList = networkList self.tableView.reloadData() } @@ -93,24 +122,6 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable } } - override func viewWillDisappear() { - super.viewWillDisappear() - - let filePath = dataFile() - NSKeyedArchiver.archiveRootObject(self.networkList, toFile: filePath) - } - - func deleteNetworkFromList(nwid: String) { - if let nwid = UInt64(nwid, radix: 16) { - let index = findNetworkWithID(nwid) - - if index != NSNotFound { - networkList.removeAtIndex(index) - tableView.reloadData() - } - } - } - // NSTableViewDataSource func numberOfRowsInTableView(tableView: NSTableView) -> Int { -- cgit v1.2.3 From c8f85ffec97206174dbffbf6290ebcdcf84355ac Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 16 Jun 2016 20:53:55 -0700 Subject: Factored network updates into its own class. Delivered via notification --- ZeroTier One.xcodeproj/project.pbxproj | 4 + ZeroTier One/AppDelegate.swift | 12 ++- ZeroTier One/Info.plist | 2 +- ZeroTier One/NetworkMonitor.swift | 116 ++++++++++++++++++++++++++ ZeroTier One/ServiceCom.swift | 5 ++ ZeroTier One/ShowNetworksViewController.swift | 87 ++----------------- 6 files changed, 145 insertions(+), 81 deletions(-) create mode 100644 ZeroTier One/NetworkMonitor.swift diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 0a8188c9..ed054cb4 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */; }; 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; }; @@ -21,6 +22,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = ""; }; 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = ""; }; @@ -82,6 +84,7 @@ 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */, 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */, 93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */, + 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */, ); path = "ZeroTier One"; sourceTree = ""; @@ -159,6 +162,7 @@ buildActionMask = 2147483647; files = ( 9330F1371CEBF87200687EC8 /* Network.swift in Sources */, + 932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */, 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */, 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */, diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index c7cbc09a..f0bd0437 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -21,8 +21,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { var transientMonitor: AnyObject? = nil - func applicationDidFinishLaunching(aNotification: NSNotification) { + let monitor = NetworkMonitor() + func applicationDidFinishLaunching(aNotification: NSNotification) { + let nc = NSNotificationCenter.defaultCenter() + nc.addObserver(self, selector: #selector(onNetworkListUpdated(_:)), name: networkUpdateKey, object: nil) statusItem.image = NSImage(named: "MenuBarIconMac") @@ -50,6 +53,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { func applicationWillTerminate(aNotification: NSNotification) { // Insert code here to tear down your application + let nc = NSNotificationCenter.defaultCenter() + nc.removeObserver(self) } @@ -89,5 +94,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { func quit() { NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0) } + + func onNetworkListUpdated(note: NSNotification) { + let netList = note.userInfo!["networks"] as! [Network] + (networkListPopover.contentViewController as! ShowNetworksViewController).setNetworks(netList) + } } diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 5777ef6c..29e935d0 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 2 + 3 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement diff --git a/ZeroTier One/NetworkMonitor.swift b/ZeroTier One/NetworkMonitor.swift new file mode 100644 index 00000000..124fce26 --- /dev/null +++ b/ZeroTier One/NetworkMonitor.swift @@ -0,0 +1,116 @@ +// +// NetworkMonitor.swift +// ZeroTier One +// +// Created by Grant Limberg on 6/16/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +let networkUpdateKey = "com.zerotier.one.network-list" + +class NetworkMonitor: NSObject { + + var timer: NSTimer? = nil + + var savedNetworks: [Network] = [Network]() + var receivedNetworks: [Network] = [Network]() + var allNetworks: [Network] = [Network]() + + override init() { + super.init() + + timer = NSTimer.scheduledTimerWithTimeInterval(1.0, + target: self, + selector: #selector(updateNetworkInfo), + userInfo: nil, + repeats: true) + } + + deinit { + timer?.invalidate() + } + + private func dataFile() -> String { + var appSupport = NSFileManager.defaultManager().URLsForDirectory(.ApplicationSupportDirectory, inDomains: .UserDomainMask)[0] + appSupport = appSupport.URLByAppendingPathComponent("ZeroTier").URLByAppendingPathComponent("One").URLByAppendingPathComponent("networks.dat") + return appSupport.path! + } + + func updateNetworkInfo() { + let filePath = dataFile() + + if NSFileManager.defaultManager().fileExistsAtPath(filePath) { + self.savedNetworks = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + + } + + ServiceCom.getNetworkList() { (networkList) -> Void in + self.receivedNetworks = networkList + + NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in + self.internal_updateNetworkInfo() + } + } + } + + func deleteSavedNetwork(nwid: String) { + if let nwid = UInt64(nwid, radix: 16) { + let index = findNetworkWithID(nwid) + + if index != NSNotFound { + allNetworks.removeAtIndex(index) + } + } + } + + // Only to be called by updateNetworkInfo() + private func internal_updateNetworkInfo() { + var networks = self.savedNetworks + + for nw in receivedNetworks { + let index = findNetworkWithID(nw.nwid) + + if index != NSNotFound { + networks[index] = nw + } + networks.sortInPlace({ (left, right) -> Bool in + if left.nwid < right.nwid { + return true + } + + return false + }) + + objc_sync_enter(allNetworks) + allNetworks = networks + objc_sync_exit(allNetworks) + + saveNetworks() + + let nc = NSNotificationCenter.defaultCenter() + + nc.postNotificationName(networkUpdateKey, object: nil, userInfo: ["networks": networks]) + } + } + + private func findNetworkWithID(nwid: UInt64) -> Int { + for (index, element) in allNetworks.enumerate() { + + if element.nwid == nwid { + return index + } + } + + return NSNotFound + } + + private func saveNetworks() { + let file = dataFile() + + objc_sync_enter(allNetworks) + NSKeyedArchiver.archiveRootObject(self.allNetworks, toFile: file) + objc_sync_exit(allNetworks) + } +} diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index e2526610..21d5529c 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -87,6 +87,11 @@ class ServiceCom: NSObject { let request = NSMutableURLRequest(URL: u) let session = NSURLSession.sharedSession() let task = session.dataTaskWithRequest(request) { (data, response, error) in + if error != nil{ + NSLog("\(error)") + return + } + let httpResponse = response as! NSHTTPURLResponse let status = httpResponse.statusCode diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index d9a4291a..e8b9e332 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -10,20 +10,18 @@ import Cocoa class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource { - @IBOutlet var tableView: NSTableView! + @IBOutlet var tableView: NSTableView? var networkList: [Network] = [Network]() - - - var timer: NSTimer? = nil + var netMonitor: NetworkMonitor! override func viewDidLoad() { super.viewDidLoad() // Do view setup here. - tableView.setDelegate(self) - tableView.setDataSource(self) - tableView.backgroundColor = NSColor.clearColor() + tableView?.setDelegate(self) + tableView?.setDataSource(self) + tableView?.backgroundColor = NSColor.clearColor() } private func dataFile() -> String { @@ -32,94 +30,25 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable return appSupport.path! } - - private func findNetworkWithID(id: UInt64) -> Int { - - for (index, element) in networkList.enumerate() { - - if element.nwid == id { - return index - } - } - - return NSNotFound - } - override func viewWillAppear() { super.viewWillAppear() - - updateNetworkInfo() - - self.timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(updateNetworkInfo), userInfo: nil, repeats: true) } override func viewWillDisappear() { super.viewWillDisappear() - self.timer?.invalidate() - let filePath = dataFile() NSKeyedArchiver.archiveRootObject(self.networkList, toFile: filePath) } func deleteNetworkFromList(nwid: String) { - if let nwid = UInt64(nwid, radix: 16) { - let index = findNetworkWithID(nwid) - if index != NSNotFound { - networkList.removeAtIndex(index) - tableView.reloadData() - } - } } - func updateNetworkInfo() { - let filePath = self.dataFile() - - if NSFileManager.defaultManager().fileExistsAtPath(filePath) { - self.networkList = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] - - ServiceCom.getNetworkList() { (networkList) -> Void in - - for nw in networkList { - let index = self.findNetworkWithID(nw.nwid) - if index != NSNotFound { - self.networkList[index] = nw - } - else { - self.networkList.append(nw) - } - } - - NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in - self.networkList.sortInPlace({ (left, right) -> Bool in - if left.nwid < right.nwid { - return true - } - - return false - }) - self.tableView.reloadData() - } - } - } - else { - ServiceCom.getNetworkList() { (networkList) -> Void in - NSOperationQueue.mainQueue().addOperationWithBlock() { () -> Void in - self.networkList.sortInPlace({ (left, right) -> Bool in - if left.nwid < right.nwid { - return true - } - - return false - }) - - self.networkList = networkList - self.tableView.reloadData() - } - } - } + func setNetworks(list: [Network]) { + networkList = list + tableView?.reloadData() } // NSTableViewDataSource -- cgit v1.2.3 From 6d114b7480ed5a6356b8938a4ebf11a9d19adeec Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 21 Jun 2016 19:44:59 -0700 Subject: dynamically generate the menu so that networks are listed can join/leave networks directly from the menu --- ZeroTier One/AppDelegate.swift | 65 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index f0bd0437..dc7a3b9a 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -23,20 +23,15 @@ class AppDelegate: NSObject, NSApplicationDelegate { let monitor = NetworkMonitor() + var networks = [Network]() + func applicationDidFinishLaunching(aNotification: NSNotification) { let nc = NSNotificationCenter.defaultCenter() nc.addObserver(self, selector: #selector(onNetworkListUpdated(_:)), name: networkUpdateKey, object: nil) statusItem.image = NSImage(named: "MenuBarIconMac") - let menu = NSMenu() - - menu.addItem(NSMenuItem(title: "Show Networks", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) - menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) - menu.addItem(NSMenuItem.separatorItem()) - menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q")) - - statusItem.menu = menu + buildMenu() joinNetworkPopover.contentViewController = JoinNetworkViewController( nibName: "JoinNetworkViewController", bundle: nil) @@ -98,6 +93,60 @@ class AppDelegate: NSObject, NSApplicationDelegate { func onNetworkListUpdated(note: NSNotification) { let netList = note.userInfo!["networks"] as! [Network] (networkListPopover.contentViewController as! ShowNetworksViewController).setNetworks(netList) + + self.networks = netList + + buildMenu() + } + + func buildMenu() { + let menu = NSMenu() + + menu.addItem(NSMenuItem(title: "Show Networks", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) + menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) + menu.addItem(NSMenuItem.separatorItem()) + + if networks.count > 0 { + for net in networks { + let id = String(net.nwid, radix: 16) + let networkName = "\(id) (\(net.name))" + + let item = NSMenuItem(title: networkName, action: #selector(AppDelegate.toggleNetwork(_:)), keyEquivalent: "") + + if net.connected { + item.state = NSOnState + } + else { + item.state = NSOffState + } + + item.representedObject = net + + menu.addItem(item) + } + + menu.addItem(NSMenuItem.separatorItem()) + } + + menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q")) + + statusItem.menu = menu + + } + + func toggleNetwork(sender: NSMenuItem) { + NSLog("\(sender.title)") + + let network = sender.representedObject as! Network + + let id = String(network.nwid, radix: 16) + + if network.connected { + ServiceCom.leaveNetwork(id) + } + else { + ServiceCom.joinNetwork(id) + } } } -- cgit v1.2.3 From b5a90a437b177e4cf486c571418f835e32ab8c1d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 21 Jun 2016 19:45:08 -0700 Subject: update build number --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 29e935d0..87cfc3f6 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 3 + 4 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From b256111a17ba9ea223b7d706eebf66605e46c701 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 21 Jun 2016 20:02:18 -0700 Subject: misc cleanup --- ZeroTier One/AppDelegate.swift | 8 +++++++- ZeroTier One/ServiceCom.swift | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index dc7a3b9a..8e0cbf10 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -109,7 +109,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { if networks.count > 0 { for net in networks { let id = String(net.nwid, radix: 16) - let networkName = "\(id) (\(net.name))" + var networkName = "" + if net.name.isEmpty { + networkName = "\(id)" + } + else { + networkName = "\(id) (\(net.name))" + } let item = NSMenuItem(title: networkName, action: #selector(AppDelegate.toggleNetwork(_:)), keyEquivalent: "") diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 21d5529c..23c194c2 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -133,10 +133,10 @@ class ServiceCom: NSObject { let status = httpResponse.statusCode if status == 200 { - print("join ok") + NSLog("join ok") } else { - print("join error: \(status)") + NSLog("join error: \(status)") } } @@ -158,10 +158,10 @@ class ServiceCom: NSObject { let status = httpResponse.statusCode if status == 200 { - print("leave ok") + NSLog("leave ok") } else { - print("leave error: \(status)") + NSLog("leave error: \(status)") } } -- cgit v1.2.3 From c3deedd6fd2198f2ee379c896aee55b7c6d894cb Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 23 Jun 2016 19:44:00 -0700 Subject: Fix menu bar icon. Add app icon. --- ZeroTier One.xcodeproj/project.pbxproj | 6 ++++-- .../Assets.xcassets/AppIcon.appiconset/Contents.json | 3 ++- .../AppIcon.appiconset/ZeroTierIcon512x512.png | Bin 0 -> 51309 bytes .../MenuBarIconMac.imageset/Contents.json | 4 ++-- .../MenuBarIconMac.imageset/MenuBar.png | Bin 0 -> 392 bytes .../MenuBarIconMac.imageset/MenuBar@2x.png | Bin 0 -> 761 bytes .../MenuBarIconMac.imageset/MenuBarIconMac.png | Bin 3810 -> 0 bytes .../MenuBarIconMac.imageset/MenuBarIconMac@2x.png | Bin 5444 -> 0 bytes ZeroTier One/Info.plist | 2 +- ZeroTier One/ZeroTierIcon.icns | Bin 0 -> 125598 bytes 10 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar.png create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png create mode 100644 ZeroTier One/ZeroTierIcon.icns diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index ed054cb4..5aa71456 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */; }; + 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; }; 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; }; @@ -23,6 +24,7 @@ /* Begin PBXFileReference section */ 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = ""; }; + 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = ""; }; 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = ""; }; @@ -70,6 +72,7 @@ 93326BDA1CE7C816005CA2AC /* ZeroTier One */ = { isa = PBXGroup; children = ( + 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */, 93326BDB1CE7C816005CA2AC /* AppDelegate.swift */, 93326BE81CE7D9B9005CA2AC /* JoinNetworkViewController.swift */, 9330F1361CEBF87200687EC8 /* Network.swift */, @@ -151,6 +154,7 @@ 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */, 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, + 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -271,7 +275,6 @@ 93326BE61CE7C816005CA2AC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; @@ -287,7 +290,6 @@ 93326BE71CE7C816005CA2AC /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; diff --git a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json index 2db2b1c7..24c81d35 100644 --- a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -41,8 +41,9 @@ "scale" : "2x" }, { - "idiom" : "mac", "size" : "512x512", + "idiom" : "mac", + "filename" : "ZeroTierIcon512x512.png", "scale" : "1x" }, { diff --git a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png new file mode 100644 index 00000000..d225c2e3 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json index ab75ef9a..3213cbe1 100644 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -2,12 +2,12 @@ "images" : [ { "idiom" : "mac", - "filename" : "MenuBarIconMac.png", + "filename" : "MenuBar.png", "scale" : "1x" }, { "idiom" : "mac", - "filename" : "MenuBarIconMac@2x.png", + "filename" : "MenuBar@2x.png", "scale" : "2x" } ], diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar.png new file mode 100644 index 00000000..2734f6b6 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png new file mode 100644 index 00000000..08afad40 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png deleted file mode 100644 index 74e59fe7..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png deleted file mode 100644 index 1c99f851..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBarIconMac@2x.png and /dev/null differ diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 87cfc3f6..80b0c466 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIconFile - + ZeroTierIcon.icns CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion diff --git a/ZeroTier One/ZeroTierIcon.icns b/ZeroTier One/ZeroTierIcon.icns new file mode 100644 index 00000000..17e60d58 Binary files /dev/null and b/ZeroTier One/ZeroTierIcon.icns differ -- cgit v1.2.3 From 3c534abc9989719061dedd43a74221f73409357b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 23 Jun 2016 19:48:48 -0700 Subject: "Show Networks" -> "Network Details" --- ZeroTier One/AppDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index 8e0cbf10..0179780f 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -102,7 +102,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { func buildMenu() { let menu = NSMenu() - menu.addItem(NSMenuItem(title: "Show Networks", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) + menu.addItem(NSMenuItem(title: "Network Details", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) menu.addItem(NSMenuItem.separatorItem()) -- cgit v1.2.3 From 35d1736c9726d3be8ab2cbc63b445d14b32c4d14 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 23 Jun 2016 20:04:57 -0700 Subject: add preferences view not populated yet --- ZeroTier One.xcodeproj/project.pbxproj | 8 ++++++++ ZeroTier One/AppDelegate.swift | 27 +++++++++++++++++++++++++++ ZeroTier One/JoinNetworkViewController.xib | 1 - ZeroTier One/PreferencesViewController.swift | 18 ++++++++++++++++++ ZeroTier One/PreferencesViewController.xib | 19 +++++++++++++++++++ ZeroTier One/ShowNetworksViewController.xib | 1 - 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 ZeroTier One/PreferencesViewController.swift create mode 100644 ZeroTier One/PreferencesViewController.xib diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 5aa71456..d6b38dd8 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */; }; 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; }; + 932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */; }; + 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; }; 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; }; @@ -25,6 +27,8 @@ /* Begin PBXFileReference section */ 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = ""; }; 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = ""; }; + 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = ""; }; + 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = ""; }; 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = ""; }; @@ -88,6 +92,8 @@ 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */, 93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */, 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */, + 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */, + 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */, ); path = "ZeroTier One"; sourceTree = ""; @@ -155,6 +161,7 @@ 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */, + 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -167,6 +174,7 @@ files = ( 9330F1371CEBF87200687EC8 /* Network.swift in Sources */, 932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */, + 932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */, 93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */, 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */, 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */, diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index 0179780f..f37eba73 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -18,6 +18,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let networkListPopover = NSPopover() let joinNetworkPopover = NSPopover() + let preferencesPopover = NSPopover() var transientMonitor: AnyObject? = nil @@ -44,6 +45,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { networkListPopover.behavior = .Transient networkListPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) + + preferencesPopover.contentViewController = PreferencesViewController( + nibName: "PreferencesViewController", bundle: nil) + preferencesPopover.behavior = .Transient + + preferencesPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) } func applicationWillTerminate(aNotification: NSNotification) { @@ -86,6 +93,22 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + func showPreferences() { + if let button = statusItem.button { + preferencesPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY) + + if transientMonitor == nil { + transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask( + [.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in + + NSEvent.removeMonitor(self.transientMonitor!) + self.transientMonitor = nil + self.preferencesPopover.close() + } + } + } + } + func quit() { NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0) } @@ -134,6 +157,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(NSMenuItem.separatorItem()) } + menu.addItem(NSMenuItem(title: "Preferences...", action: #selector(AppDelegate.showPreferences), keyEquivalent: ",")) + + menu.addItem(NSMenuItem.separatorItem()) + menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q")) statusItem.menu = menu diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 7a2ffe70..625f1a3e 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -1,7 +1,6 @@ - diff --git a/ZeroTier One/PreferencesViewController.swift b/ZeroTier One/PreferencesViewController.swift new file mode 100644 index 00000000..95d2d882 --- /dev/null +++ b/ZeroTier One/PreferencesViewController.swift @@ -0,0 +1,18 @@ +// +// PreferencesViewController.swift +// ZeroTier One +// +// Created by Grant Limberg on 6/23/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class PreferencesViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + +} diff --git a/ZeroTier One/PreferencesViewController.xib b/ZeroTier One/PreferencesViewController.xib new file mode 100644 index 00000000..2a80a43a --- /dev/null +++ b/ZeroTier One/PreferencesViewController.xib @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 12f1ea3c..69120fc9 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,7 +1,6 @@ - -- cgit v1.2.3 From f2e2632ae706a97c7172e6925d395d8752b044ed Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 23 Jun 2016 20:22:03 -0700 Subject: Added About view also not yet populated --- ZeroTier One.xcodeproj/project.pbxproj | 8 ++++++++ ZeroTier One/AboutViewController.swift | 18 ++++++++++++++++++ ZeroTier One/AboutViewController.xib | 19 +++++++++++++++++++ ZeroTier One/AppDelegate.swift | 25 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 ZeroTier One/AboutViewController.swift create mode 100644 ZeroTier One/AboutViewController.xib diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index d6b38dd8..657f5150 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; }; 932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */; }; 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; }; + 932D47361D1CDC9B004BCFE2 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D47341D1CDC9B004BCFE2 /* AboutViewController.swift */; }; + 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */; }; 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; }; 9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; }; 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; }; @@ -29,6 +31,8 @@ 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = ""; }; 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = ""; }; 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = ""; }; + 932D47341D1CDC9B004BCFE2 /* AboutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; }; + 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AboutViewController.xib; sourceTree = ""; }; 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = ""; }; 9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = ""; }; 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = ""; }; @@ -94,6 +98,8 @@ 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */, 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */, 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */, + 932D47341D1CDC9B004BCFE2 /* AboutViewController.swift */, + 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */, ); path = "ZeroTier One"; sourceTree = ""; @@ -157,6 +163,7 @@ buildActionMask = 2147483647; files = ( 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */, + 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */, 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */, 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, @@ -180,6 +187,7 @@ 9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */, 93326BEA1CE7D9B9005CA2AC /* JoinNetworkViewController.swift in Sources */, 93326BEE1CE7DA30005CA2AC /* ShowNetworksViewController.swift in Sources */, + 932D47361D1CDC9B004BCFE2 /* AboutViewController.swift in Sources */, 9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ZeroTier One/AboutViewController.swift b/ZeroTier One/AboutViewController.swift new file mode 100644 index 00000000..bbca975a --- /dev/null +++ b/ZeroTier One/AboutViewController.swift @@ -0,0 +1,18 @@ +// +// AboutViewController.swift +// ZeroTier One +// +// Created by Grant Limberg on 6/23/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class AboutViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + +} diff --git a/ZeroTier One/AboutViewController.xib b/ZeroTier One/AboutViewController.xib new file mode 100644 index 00000000..8722929f --- /dev/null +++ b/ZeroTier One/AboutViewController.xib @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index f37eba73..2ca97f3c 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -19,6 +19,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let networkListPopover = NSPopover() let joinNetworkPopover = NSPopover() let preferencesPopover = NSPopover() + let aboutPopover = NSPopover() var transientMonitor: AnyObject? = nil @@ -51,6 +52,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { preferencesPopover.behavior = .Transient preferencesPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) + + aboutPopover.contentViewController = AboutViewController( + nibName: "AboutViewController", bundle: nil) + aboutPopover.behavior = .Transient + + aboutPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) + } func applicationWillTerminate(aNotification: NSNotification) { @@ -109,6 +117,22 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + func showAbout() { + if let button = statusItem.button { + aboutPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY) + + if transientMonitor == nil { + transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask( + [.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in + + NSEvent.removeMonitor(self.transientMonitor!) + self.transientMonitor = nil + self.aboutPopover.close() + } + } + } + } + func quit() { NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0) } @@ -157,6 +181,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(NSMenuItem.separatorItem()) } + menu.addItem(NSMenuItem(title: "About ZeroTier One...", action: #selector(AppDelegate.showAbout), keyEquivalent: "")) menu.addItem(NSMenuItem(title: "Preferences...", action: #selector(AppDelegate.showPreferences), keyEquivalent: ",")) menu.addItem(NSMenuItem.separatorItem()) -- cgit v1.2.3 From e621058cfd6ad505de9dcb5ee38e0d0983091f66 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 24 Jun 2016 15:24:03 -0700 Subject: build number 5 --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 80b0c466..b4345ac4 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 4 + 5 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From 5da4fd2aef1f510d1bae4e90fa195f8e7962e36f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 24 Jun 2016 15:24:29 -0700 Subject: Added "..." to menu items to signify it pops up in a window --- ZeroTier One/AppDelegate.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index 2ca97f3c..e52b7be5 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -149,8 +149,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { func buildMenu() { let menu = NSMenu() - menu.addItem(NSMenuItem(title: "Network Details", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) - menu.addItem(NSMenuItem(title: "Join Network", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) + menu.addItem(NSMenuItem(title: "Network Details...", action: #selector(AppDelegate.showNetworks), keyEquivalent: "n")) + menu.addItem(NSMenuItem(title: "Join Network...", action: #selector(AppDelegate.joinNetwork), keyEquivalent: "j")) menu.addItem(NSMenuItem.separatorItem()) if networks.count > 0 { -- cgit v1.2.3 From 9c94d6527a1968468567232698818c479c04b44b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 16:11:30 -0700 Subject: add allowGlobal, allowDefault, allowManaged options to joining a network --- ZeroTier One/JoinNetworkViewController.swift | 10 +++++-- ZeroTier One/JoinNetworkViewController.xib | 34 +++++++++++++++++---- ZeroTier One/ServiceCom.swift | 45 ++++++++++++++++++---------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index 92e30cae..cef30d4e 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -30,6 +30,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo @IBOutlet var network: NSComboBox! @IBOutlet var joinButton: NSButton! + @IBOutlet var allowManagedCheckBox: NSButton! + @IBOutlet var allowGlobalCheckBox: NSButton! + @IBOutlet var allowDefaultCheckBox:NSButton! + var values: [String] = [String]() override func viewDidLoad() { @@ -61,8 +65,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo @IBAction func onJoinClicked(sender: AnyObject?) { let networkString = network.stringValue - ServiceCom.joinNetwork(networkString) - + ServiceCom.joinNetwork(networkString, + allowManaged: allowManagedCheckBox.state == NSOnState, + allowGlobal: allowGlobalCheckBox.state == NSOnState, + allowDefault: allowDefaultCheckBox.state == NSOnState) network.stringValue = "" diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 625f1a3e..187af008 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -6,6 +6,9 @@ + + + @@ -14,11 +17,11 @@ - + - + @@ -26,7 +29,7 @@ - + + + + - + diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 23c194c2..4c920ad2 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -119,29 +119,44 @@ class ServiceCom: NSObject { } - static func joinNetwork(network: String) { + static func joinNetwork(network: String, allowManaged: Bool = true, allowGlobal: Bool = false, allowDefault: Bool = false) { let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())" let url = NSURL(string: urlString) - if let u = url { - let request = NSMutableURLRequest(URL: u) - request.HTTPMethod = "POST" + var jsonDict = [String: AnyObject]() + jsonDict["allowManaged"] = NSNumber(bool: allowManaged) + jsonDict["allowGlobal"] = NSNumber(bool: allowGlobal) + jsonDict["allowDefault"] = NSNumber(bool: allowDefault) - let session = NSURLSession.sharedSession() - let task = session.dataTaskWithRequest(request) { (data, response, error) in - let httpResponse = response as! NSHTTPURLResponse - let status = httpResponse.statusCode + do { + let json = try NSJSONSerialization.dataWithJSONObject(jsonDict, options: NSJSONWritingOptions()) - if status == 200 { - NSLog("join ok") - } - else { - NSLog("join error: \(status)") + if let u = url { + let request = NSMutableURLRequest(URL: u) + request.HTTPMethod = "POST" + request.HTTPBody = json + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + + let session = NSURLSession.sharedSession() + let task = session.dataTaskWithRequest(request) { (data, response, error) in + let httpResponse = response as! NSHTTPURLResponse + let status = httpResponse.statusCode + + if status == 200 { + NSLog("join ok") + } + else { + NSLog("join error: \(status)") + } } - } - task.resume() + task.resume() + } } + catch { + NSLog("\(error)") + } + } static func leaveNetwork(network: String) { -- cgit v1.2.3 From 7e17a2072cbae143dde41a1a5bda646622cf3979 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 16:41:52 -0700 Subject: add allowManaged, allowGlobal, allowDefault to Network object --- ZeroTier One/Network.swift | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index 95b3d93f..2e66ac8e 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -56,6 +56,9 @@ struct PropertyKeys { static let portErrorKey = "portError" static let statusKey = "status" static let typeKey = "type" + static let allowManagedKey = "allowManaged" + static let allowGlobalKey = "allowGlobal" + static let allowDefaultKey = "allowDefault" } class Network: NSObject, NSCoding { @@ -72,6 +75,9 @@ class Network: NSObject, NSCoding { var portError: Int = 0 var status: NetworkStatus = .REQUESTING_CONFIGURATION var type: NetworkType = .PRIVATE + var allowManaged: Bool = true + var allowGlobal: Bool = false + var allowDefault: Bool = false var connected: Bool = false // NOT PERSISTED. Set to true if loaded via JSON init(jsonData: [String: AnyObject]) { @@ -123,6 +129,18 @@ class Network: NSObject, NSCoding { portError = p.integerValue } + if let a = jsonData["allowManaged"] as? NSNumber { + allowManaged = a.boolValue + } + + if let a = jsonData["allowGlobal"] as? NSNumber { + allowGlobal = a.boolValue + } + + if let a = jsonData["allowDefault"] as? NSNumber { + allowDefault = a.boolValue + } + if let statusStr = jsonData["status"] as? String { switch statusStr { case "REQUESTING_CONFIGURATION": @@ -209,6 +227,18 @@ class Network: NSObject, NSCoding { if aDecoder.containsValueForKey(PropertyKeys.typeKey) { self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))! } + + if aDecoder.containsValueForKey(PropertyKeys.allowManagedKey) { + self.allowManaged = aDecoder.decodeBoolForKey(PropertyKeys.allowManagedKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.allowGlobalKey) { + self.allowGlobal = aDecoder.decodeBoolForKey(PropertyKeys.allowGlobalKey) + } + + if aDecoder.containsValueForKey(PropertyKeys.allowDefaultKey) { + self.allowDefault = aDecoder.decodeBoolForKey(PropertyKeys.allowDefaultKey) + } } func encodeWithCoder(aCoder: NSCoder) { @@ -225,5 +255,8 @@ class Network: NSObject, NSCoding { aCoder.encodeInteger(self.portError, forKey: PropertyKeys.portErrorKey) aCoder.encodeInteger(self.status.rawValue, forKey: PropertyKeys.statusKey) aCoder.encodeInteger(self.type.rawValue, forKey: PropertyKeys.typeKey) + aCoder.encodeBool(self.allowManaged, forKey: PropertyKeys.allowManagedKey) + aCoder.encodeBool(self.allowGlobal, forKey: PropertyKeys.allowGlobalKey) + aCoder.encodeBool(self.allowDefault, forKey: PropertyKeys.allowDefaultKey) } } -- cgit v1.2.3 From d57e343245558312847dc37ecdbebf6b65b6a66e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 17:21:45 -0700 Subject: add UI elements in network details for allowDefault, allowGlobal, allowManaged --- ZeroTier One/Network.swift | 10 + ZeroTier One/NetworkInfoCell.swift | 4 + ZeroTier One/ShowNetworksViewController.swift | 17 ++ ZeroTier One/ShowNetworksViewController.xib | 280 +++++++++++++++----------- 4 files changed, 197 insertions(+), 114 deletions(-) diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index 2e66ac8e..b344b6c2 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -260,3 +260,13 @@ class Network: NSObject, NSCoding { aCoder.encodeBool(self.allowDefault, forKey: PropertyKeys.allowDefaultKey) } } + +func defaultRouteExists(netList: [Network]) -> Bool { + for net in netList { + if net.allowDefault { + return true + } + } + + return false +} diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index c31fcb91..427bdc84 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -24,6 +24,10 @@ class NetworkInfoCell: NSTableCellView { @IBOutlet var deviceField: NSTextField! @IBOutlet var addressesField: NSTextField! + @IBOutlet var allowManaged: NSButton! + @IBOutlet var allowGlobal: NSButton! + @IBOutlet var allowDefault: NSButton! + @IBOutlet var connectedCheckbox: NSButton! @IBOutlet var deleteButton: NSButton! diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index e8b9e332..250cc73a 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -77,6 +77,23 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable cell.deviceField.stringValue = network.portDeviceName + if network.allowDefault { + cell.allowDefault.state = NSOnState + } + else { + cell.allowDefault.state = NSOffState + + if defaultRouteExists(networkList) { + cell.allowDefault.enabled = false + } + else { + cell.allowDefault.enabled = true + } + } + + cell.allowGlobal.state = (network.allowGlobal ? NSOnState : NSOffState) + cell.allowManaged.state = (network.allowManaged ? NSOnState : NSOffState) + cell.addressesField.stringValue = "" for nw in network.assignedAddresses { diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 69120fc9..74582eb6 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -16,13 +16,13 @@ - + - + @@ -43,83 +43,75 @@ - + - - - - - - - - - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -127,143 +119,203 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 1756e8b0f2bb5a322f38f5e0e079d27cfcfecd57 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 17:33:46 -0700 Subject: Wire up checkboxes for allowGlobal, allowDefault, allowManaged to set the proper state in zerotier daemon checkboxes are disabled if the network is not currently connected. --- ZeroTier One/NetworkInfoCell.swift | 13 ++++++++----- ZeroTier One/ShowNetworksViewController.swift | 8 ++++++++ ZeroTier One/ShowNetworksViewController.xib | 9 +++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ZeroTier One/NetworkInfoCell.swift b/ZeroTier One/NetworkInfoCell.swift index 427bdc84..12e71948 100644 --- a/ZeroTier One/NetworkInfoCell.swift +++ b/ZeroTier One/NetworkInfoCell.swift @@ -42,14 +42,10 @@ class NetworkInfoCell: NSTableCellView { } @IBAction func onConnectCheckStateChanged(sender: NSButton) { - NSLog("Checked State Changed") - if(sender.state == NSOnState) { - NSLog("Checked") joinNetwork(networkIdField.stringValue) } else { - NSLog("Unchecked") leaveNetwork(networkIdField.stringValue) } } @@ -60,10 +56,17 @@ class NetworkInfoCell: NSTableCellView { } func joinNetwork(nwid: String) { - ServiceCom.joinNetwork(nwid) + ServiceCom.joinNetwork(nwid, + allowManaged: allowManaged.state == NSOnState, + allowGlobal: allowGlobal.state == NSOnState, + allowDefault: !defaultRouteExists(parent.networkList) && (allowDefault.state == NSOnState)) } func leaveNetwork(nwid: String) { ServiceCom.leaveNetwork(nwid) } + + @IBAction func onAllowStatusChanged(sender: NSButton) { + joinNetwork(networkIdField.stringValue) + } } diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index 250cc73a..e2bdd105 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -103,9 +103,17 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable if network.connected { cell.connectedCheckbox.state = NSOnState + + cell.allowDefault.enabled = true + cell.allowGlobal.enabled = true + cell.allowManaged.enabled = true } else { cell.connectedCheckbox.state = NSOffState + + cell.allowDefault.enabled = false + cell.allowGlobal.enabled = false + cell.allowManaged.enabled = false } return cell diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 74582eb6..1535c668 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -168,6 +168,9 @@ + + + -- cgit v1.2.3 From 3fc11e2278a5e88ebc4ec3150fda050959e0c446 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sun, 26 Jun 2016 18:18:59 -0700 Subject: misc bug fixes related to default routes --- ZeroTier One/AppDelegate.swift | 3 ++ ZeroTier One/JoinNetworkViewController.swift | 4 +++ ZeroTier One/JoinNetworkViewController.xib | 2 +- ZeroTier One/Network.swift | 2 +- ZeroTier One/NetworkMonitor.swift | 43 ++++++++++++++++++--------- ZeroTier One/ShowNetworksViewController.swift | 28 +++++++++-------- 6 files changed, 53 insertions(+), 29 deletions(-) diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index e52b7be5..25c11229 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -164,6 +164,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { networkName = "\(id) (\(net.name))" } + if net.allowDefault && net.connected { + networkName += " [default]" + } let item = NSMenuItem(title: networkName, action: #selector(AppDelegate.toggleNetwork(_:)), keyEquivalent: "") if net.connected { diff --git a/ZeroTier One/JoinNetworkViewController.swift b/ZeroTier One/JoinNetworkViewController.swift index cef30d4e..ecab8f6c 100644 --- a/ZeroTier One/JoinNetworkViewController.swift +++ b/ZeroTier One/JoinNetworkViewController.swift @@ -45,6 +45,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo override func viewWillAppear() { super.viewWillAppear() + allowManagedCheckBox.state = NSOnState + allowGlobalCheckBox.state = NSOffState + allowDefaultCheckBox.state = NSOffState + let defaults = NSUserDefaults.standardUserDefaults() let vals = defaults.stringArrayForKey(joinedNetworksKey) diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 187af008..338d35ee 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -62,7 +62,7 @@ + + -- cgit v1.2.3 From ba0a45365c985a8a54b3d10a2942293ef5bb8148 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Jun 2016 19:42:23 -0700 Subject: Work around for several strange corner cases in Automatic Reference Counting in Apple's runtime --- ZeroTier One/LaunchAtLoginController.m | 2 +- ZeroTier One/Network.swift | 13 ++++++++++--- ZeroTier One/NetworkMonitor.swift | 7 ++++++- ZeroTier One/ServiceCom.swift | 3 +-- ZeroTier One/ShowNetworksViewController.swift | 3 +-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/ZeroTier One/LaunchAtLoginController.m b/ZeroTier One/LaunchAtLoginController.m index f8aaafa0..53eb2b08 100644 --- a/ZeroTier One/LaunchAtLoginController.m +++ b/ZeroTier One/LaunchAtLoginController.m @@ -69,7 +69,7 @@ void sharedFileListDidChange(LSSharedFileListRef inList, void *context) if (wantedURL == NULL || fileList == NULL) return NULL; - NSArray *listSnapshot = (__bridge NSArray*)LSSharedFileListCopySnapshot(fileList, NULL); + NSArray *listSnapshot = (__bridge_transfer NSArray*)LSSharedFileListCopySnapshot(fileList, NULL); for (id itemObject in listSnapshot) { LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef) itemObject; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; diff --git a/ZeroTier One/Network.swift b/ZeroTier One/Network.swift index b5f6b423..45151686 100644 --- a/ZeroTier One/Network.swift +++ b/ZeroTier One/Network.swift @@ -177,7 +177,11 @@ class Network: NSObject, NSCoding { required init?(coder aDecoder: NSCoder) { if aDecoder.containsValueForKey(PropertyKeys.addressesKey) { - self.assignedAddresses = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + let addrs = aDecoder.decodeObjectForKey(PropertyKeys.addressesKey) as! [String] + + for a in addrs { + self.assignedAddresses.append(a) + } } if aDecoder.containsValueForKey(PropertyKeys.bridgeKey) { @@ -193,7 +197,8 @@ class Network: NSObject, NSCoding { } if aDecoder.containsValueForKey(PropertyKeys.macKey) { - self.mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + let mac = aDecoder.decodeObjectForKey(PropertyKeys.macKey) as! String + self.mac = mac } if aDecoder.containsValueForKey(PropertyKeys.mtuKey) { @@ -201,7 +206,9 @@ class Network: NSObject, NSCoding { } if aDecoder.containsValueForKey(PropertyKeys.nameKey) { - self.name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + let name = aDecoder.decodeObjectForKey(PropertyKeys.nameKey) as! String + + self.name = name } if aDecoder.containsValueForKey(PropertyKeys.netconfKey) { diff --git a/ZeroTier One/NetworkMonitor.swift b/ZeroTier One/NetworkMonitor.swift index d6ab55ee..c81ac47d 100644 --- a/ZeroTier One/NetworkMonitor.swift +++ b/ZeroTier One/NetworkMonitor.swift @@ -42,8 +42,13 @@ class NetworkMonitor: NSObject { let filePath = dataFile() if NSFileManager.defaultManager().fileExistsAtPath(filePath) { - self.savedNetworks = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + let networks = NSKeyedUnarchiver.unarchiveObjectWithFile(filePath) as! [Network] + self.savedNetworks.removeAll() + + for n in networks { + self.savedNetworks.append(n) + } } ServiceCom.getNetworkList() { (networkList) -> Void in diff --git a/ZeroTier One/ServiceCom.swift b/ZeroTier One/ServiceCom.swift index 4c920ad2..2a98ec36 100644 --- a/ZeroTier One/ServiceCom.swift +++ b/ZeroTier One/ServiceCom.swift @@ -161,9 +161,8 @@ class ServiceCom: NSObject { static func leaveNetwork(network: String) { let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())" - let url = NSURL(string: urlString) - if let u = url { + if let u = NSURL(string: urlString) { let request = NSMutableURLRequest(URL: u) request.HTTPMethod = "DELETE" diff --git a/ZeroTier One/ShowNetworksViewController.swift b/ZeroTier One/ShowNetworksViewController.swift index cb017075..394a6bdc 100644 --- a/ZeroTier One/ShowNetworksViewController.swift +++ b/ZeroTier One/ShowNetworksViewController.swift @@ -112,8 +112,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable cell.addressesField.stringValue = "" for nw in network.assignedAddresses { - cell.addressesField.stringValue += nw - cell.addressesField.stringValue += "\n" + cell.addressesField.stringValue += "\(nw)\n" } -- cgit v1.2.3 From d786c5265f5260528a7f461bcc0bbc3aa7c933c8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Jun 2016 19:46:59 -0700 Subject: bump version number --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index ce6eb729..9c70406f 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 6 + 7 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From e7476927276cc957dce6710357326bb71ca3f17f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Jun 2016 20:07:22 -0700 Subject: remove background from network details view --- ZeroTier One/ShowNetworksViewController.xib | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 1535c668..91ce57cc 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -18,16 +18,16 @@ - - + + - + - - + + @@ -42,7 +42,7 @@ - + @@ -343,7 +343,7 @@ - + - + diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 338d35ee..2ef43442 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -1,5 +1,5 @@ - + diff --git a/ZeroTier One/ZeroTier One-Bridging-Header.h b/ZeroTier One/ZeroTier One-Bridging-Header.h deleted file mode 100644 index 60700eeb..00000000 --- a/ZeroTier One/ZeroTier One-Bridging-Header.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - -#import "AuthtokenCopy.h" -#import "NodeStatus.h" -#import "Network.h" -#import "ServiceCom.h" -#import "AboutViewController.h" -#import "PreferencesViewController.h" -#import "NetworkMonitor.h" -#import "NetworkInfoCell.h" -#import "ShowNetworksViewController.h" -#import "JoinNetworkViewController.h" diff --git a/ZeroTier One/main.m b/ZeroTier One/main.m new file mode 100644 index 00000000..399c483d --- /dev/null +++ b/ZeroTier One/main.m @@ -0,0 +1,13 @@ +// +// main.m +// testapp +// +// Created by Grant Limberg on 8/7/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} -- cgit v1.2.3 From c15c9775bd4e9699f76d1cd3a1074415890c6245 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Aug 2016 17:45:52 -0700 Subject: explicitly link to WebKit framework --- ZeroTier One.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 49587b99..f10aee87 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 93D167791D5815E600330C99 /* JoinNetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167781D5815E600330C99 /* JoinNetworkViewController.m */; }; 93D1677C1D58228A00330C99 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1677B1D58228A00330C99 /* AppDelegate.m */; }; 93D1679B1D58300F00330C99 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1679A1D58300F00330C99 /* main.m */; }; + 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D1679C1D595F0000330C99 /* WebKit.framework */; }; 93DAFB271D3F0BEE004D5417 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = 93DAFB261D3F0BEE004D5417 /* about.html */; }; 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */; }; /* End PBXBuildFile section */ @@ -60,6 +61,7 @@ 93D1677A1D58228A00330C99 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 93D1677B1D58228A00330C99 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 93D1679A1D58300F00330C99 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 93D1679C1D595F0000330C99 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 93DAFB261D3F0BEE004D5417 /* about.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = about.html; sourceTree = ""; }; 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthtokenCopy.m; sourceTree = ""; }; 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthtokenCopy.h; sourceTree = ""; }; @@ -70,6 +72,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -79,6 +82,7 @@ 93326BCF1CE7C816005CA2AC = { isa = PBXGroup; children = ( + 93D1679C1D595F0000330C99 /* WebKit.framework */, 93326BDA1CE7C816005CA2AC /* ZeroTier One */, 93326BD91CE7C816005CA2AC /* Products */, ); -- cgit v1.2.3 From b5cab8afaae9f5dc715827156f3a78e60aa9c3ec Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Aug 2016 17:46:01 -0700 Subject: update build number --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index c741f8c2..86e7f7fd 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 10 + 11 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From 13682bd91982108aff047f2a42d9133ec0c47ad0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Aug 2016 19:02:09 -0700 Subject: Change Deployment Target to 10.7. Apparently going below 10.10 was only an issue with Swift --- ZeroTier One.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index f10aee87..8f09edda 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -329,7 +329,7 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; @@ -344,7 +344,7 @@ COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = "ZeroTier One/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; -- cgit v1.2.3 From 8ae07fb9c9b183ab93fff13692c974da7ac74241 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Aug 2016 19:04:50 -0700 Subject: build number bump --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 86e7f7fd..f35a6dfc 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 11 + 12 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From 91b8d6f34f15372e1d7bbf7021c5b7958d80050f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 9 Aug 2016 18:03:48 -0700 Subject: [pasteboard declareTypes] needs to be called before every time you set a string to the pasteboard. --- ZeroTier One/AppDelegate.h | 2 -- ZeroTier One/AppDelegate.m | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index efd1b313..b180261c 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -31,8 +31,6 @@ @property (nonatomic) NodeStatus *status; -@property (nonatomic) NSPasteboard *pasteboard; - - (void)buildMenu; - (void)onNetworkListUpdated:(NSNotification*)note; diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 13c70262..6acac165 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -28,9 +28,6 @@ self.monitor = [[NetworkMonitor alloc] init]; self.networks = [NSMutableArray array]; self.status = nil; - self.pasteboard = [NSPasteboard generalPasteboard]; - - [self.pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"firstRun"]; @@ -266,7 +263,9 @@ - (void)copyNodeID { if(self.status != nil) { - [self.pasteboard setString:self.status.address forType:NSPasteboardTypeString]; + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; + [pasteboard setString:self.status.address forType:NSPasteboardTypeString]; } } -- cgit v1.2.3 From a7b635a980a0c74fbdd4ddd2b702dcf481670439 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 9 Aug 2016 19:03:09 -0700 Subject: add border around About web view. added padding to text div in the about page --- ZeroTier One/AboutViewController.m | 6 ++++++ ZeroTier One/AboutViewController.xib | 1 + ZeroTier One/about.html | 3 +++ 3 files changed, 10 insertions(+) diff --git a/ZeroTier One/AboutViewController.m b/ZeroTier One/AboutViewController.m index f6862d26..c0b6ec85 100644 --- a/ZeroTier One/AboutViewController.m +++ b/ZeroTier One/AboutViewController.m @@ -17,6 +17,12 @@ - (void)viewDidLoad { [super viewDidLoad]; + [self.webView setWantsLayer:YES]; + self.webView.layer.borderWidth = 1.0f; + [self.webView.layer setCornerRadius:1.0f]; + self.webView.layer.masksToBounds = YES; + [self.webView.layer setBorderColor:[[NSColor darkGrayColor] CGColor]]; + NSBundle *bundle = [NSBundle mainBundle]; NSURL *path = [bundle URLForResource:@"about" withExtension:@"html"]; if(path) { diff --git a/ZeroTier One/AboutViewController.xib b/ZeroTier One/AboutViewController.xib index ec0712c2..a0df0fcf 100644 --- a/ZeroTier One/AboutViewController.xib +++ b/ZeroTier One/AboutViewController.xib @@ -1,6 +1,7 @@ + diff --git a/ZeroTier One/about.html b/ZeroTier One/about.html index 7754cf8d..4fa41d7b 100644 --- a/ZeroTier One/about.html +++ b/ZeroTier One/about.html @@ -37,6 +37,9 @@ a:link { text-decoration: none; } + div.text { + padding: 5px; + } -- cgit v1.2.3 From 73fd934fecba8caca04215be86c6604068bbfd4c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 9 Aug 2016 20:02:12 -0700 Subject: * Fixed menu icon size * Added icon for dark mode * Added detection for interface mode changing from light to dark and adjusting the icon accordingly --- ZeroTier One/AppDelegate.h | 2 ++ ZeroTier One/AppDelegate.m | 28 ++++++++++++++++++++- .../MenuBarIconMac.imageset/Contents.json | 1 - .../MenuBarIconMac.imageset/MenuBar@2x.png | Bin 15769 -> 0 bytes .../MenuBarIconMac.imageset/Menubar.png | Bin 14843 -> 17234 bytes .../MenuBarIconMacWhite.imageset/Contents.json | 20 +++++++++++++++ .../MenuBarIconMacWhite.imageset/MenubarWhite.png | Bin 0 -> 17234 bytes 7 files changed, 49 insertions(+), 2 deletions(-) delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index b180261c..d7779727 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -46,4 +46,6 @@ - (void)menuWillOpen:(NSMenu*)menu; - (void)menuDidClose:(NSMenu*)menu; +- (void)darkModeChanged:(NSNotification*)note; + @end diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 6acac165..f60ccb6b 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -44,7 +44,19 @@ name:StatusUpdateKey object:nil]; - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + NSString *osxMode = [defaults stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(darkModeChanged:) + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; [self buildMenu]; @@ -82,6 +94,9 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification { [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSDistributedNotificationCenter defaultCenter] removeObserver:self + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; } - (void)showNetworks { @@ -277,4 +292,15 @@ } +- (void)darkModeChanged:(NSNotification*)note { + NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } +} + @end diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json index a680b58b..84b36386 100644 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -7,7 +7,6 @@ }, { "idiom" : "mac", - "filename" : "MenuBar@2x.png", "scale" : "2x" } ], diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png deleted file mode 100644 index ce46c151..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png index 84ca6626..ee0d7e3f 100644 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json new file mode 100644 index 00000000..cd55e6eb --- /dev/null +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images" : [ + { + "idiom" : "mac", + "filename" : "MenubarWhite.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png new file mode 100644 index 00000000..7049ae55 Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png differ -- cgit v1.2.3 From 2300f3c92b57dc5bb4c252935caa0133ffe8fe33 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 9 Aug 2016 20:04:33 -0700 Subject: bump build number --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index f35a6dfc..2688e45e 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 12 + 13 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From bc48a097f8083f4ec16c17bcd208c3dd3719ee85 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 11 Aug 2016 17:41:54 -0700 Subject: add @2x versions of menu bar icon --- .../MenuBarIconMac.imageset/Contents.json | 1 + .../MenuBarIconMac.imageset/MenuBar@2x.png | Bin 0 -> 22973 bytes .../MenuBarIconMacWhite.imageset/Contents.json | 1 + .../MenuBarIconMacWhite.imageset/MenubarWhite@2x.png | Bin 0 -> 22973 bytes ZeroTier One/Info.plist | 2 +- 5 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png create mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json index 84b36386..a680b58b 100644 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -7,6 +7,7 @@ }, { "idiom" : "mac", + "filename" : "MenuBar@2x.png", "scale" : "2x" } ], diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png new file mode 100644 index 00000000..9fd3d3de Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json index cd55e6eb..61737760 100644 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json +++ b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json @@ -7,6 +7,7 @@ }, { "idiom" : "mac", + "filename" : "MenubarWhite@2x.png", "scale" : "2x" } ], diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png new file mode 100644 index 00000000..8c20e36f Binary files /dev/null and b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png differ diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 2688e45e..0e6971b0 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 13 + 14 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From 628ef14d80263db11f5d836a49aa0e21c3e74c70 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 11 Aug 2016 17:50:15 -0700 Subject: added more spacing at the bottom of each network info cell --- ZeroTier One/ShowNetworksViewController.xib | 128 ++++++++++++++-------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 65692307..f26cb446 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,6 +1,7 @@ + @@ -16,13 +17,13 @@ - + - + @@ -44,101 +45,91 @@ - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + - - + + - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -258,13 +249,23 @@ - + + @@ -289,9 +290,9 @@ + - @@ -301,18 +302,19 @@ - - + + + -- cgit v1.2.3 From 35d5ed9c2bdbb920684a4088bd5bb6a3df332121 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 19 Aug 2016 18:13:00 -0700 Subject: version bump i forgot to commit --- ZeroTier One/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist index 0e6971b0..e04b5f28 100644 --- a/ZeroTier One/Info.plist +++ b/ZeroTier One/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 14 + 15 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement -- cgit v1.2.3 From c2a01f6db46273d7013d22c59e4cc6500866fbd3 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 30 Aug 2016 20:28:52 -0700 Subject: Added a path for error handling when fetching data from the ZeroTier daemon Still need to wire up error messages to the user. --- ZeroTier One/AppDelegate.m | 15 ++++- ZeroTier One/JoinNetworkViewController.m | 9 ++- ZeroTier One/NetworkInfoCell.m | 15 ++++- ZeroTier One/NetworkMonitor.m | 20 ++++++- ZeroTier One/ServiceCom.h | 8 +-- ZeroTier One/ServiceCom.m | 95 +++++++++++++++++++++++++------- 6 files changed, 129 insertions(+), 33 deletions(-) diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index f60ccb6b..048fa385 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -266,13 +266,24 @@ NSString *nwid = [NSString stringWithFormat:@"%10llx", network.nwid]; if(network.connected) { - [[ServiceCom sharedInstance] leaveNetwork:nwid]; + NSError *error = nil; + + [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; + + if (error) { + // TODO: Display error message + + } } else { + NSError *error = nil; [[ServiceCom sharedInstance] joinNetwork:nwid allowManaged:network.allowManaged allowGlobal:network.allowGlobal - allowDefault:(network.allowDefault && ![Network defaultRouteExists:self.networks])]; + allowDefault:(network.allowDefault && ![Network defaultRouteExists:self.networks]) + error:&error]; + + // TODO: Display error message } } diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m index 60e8e1cc..f91589d9 100644 --- a/ZeroTier One/JoinNetworkViewController.m +++ b/ZeroTier One/JoinNetworkViewController.m @@ -72,10 +72,17 @@ NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; - (IBAction)onJoinClicked:(id)sender { NSString *networkId = self.network.stringValue; + NSError *error = nil; [[ServiceCom sharedInstance] joinNetwork:networkId allowManaged:(self.allowManagedCheckBox.state == NSOnState) allowGlobal:(self.allowGlobalCheckBox.state == NSOnState) - allowDefault:(self.allowDefaultCheckBox.state == NSOnState)]; + allowDefault:(self.allowDefaultCheckBox.state == NSOnState) + error:&error]; + + if(error) { + // TODO: display error message + return; + } self.network.stringValue = @""; diff --git a/ZeroTier One/NetworkInfoCell.m b/ZeroTier One/NetworkInfoCell.m index 606bb849..6ffb9e71 100644 --- a/ZeroTier One/NetworkInfoCell.m +++ b/ZeroTier One/NetworkInfoCell.m @@ -42,15 +42,26 @@ - (void)joinNetwork:(NSString*)nwid { + NSError *error = nil; [[ServiceCom sharedInstance] joinNetwork:nwid allowManaged:(self.allowManaged.state == NSOnState) allowGlobal:(self.allowGlobal.state == NSOnState) - allowDefault:![Network defaultRouteExists:_parent.networkList] && (self.allowDefault.state == NSOnState)]; + allowDefault:![Network defaultRouteExists:_parent.networkList] && (self.allowDefault.state == NSOnState) + error:&error]; + + if (error) { + // TODO: Display error message + } } - (void)leaveNetwork:(NSString*)nwid { - [[ServiceCom sharedInstance] leaveNetwork:nwid]; + NSError *error = nil; + [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; + + if (error) { + // TODO: Display error message + } } @end diff --git a/ZeroTier One/NetworkMonitor.m b/ZeroTier One/NetworkMonitor.m index 466d7db1..59451325 100644 --- a/ZeroTier One/NetworkMonitor.m +++ b/ZeroTier One/NetworkMonitor.m @@ -74,13 +74,21 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status"; } } + NSError *error = nil; + [[ServiceCom sharedInstance] getNetworklist:^(NSArray *networkList) { _receivedNetworks = networkList; [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [self internal_updateNetworkInfo]; - }]; - }]; + } ]; + } error:&error]; + + if(error) { + // TODO: Display error message + + [self stop]; + } [[ServiceCom sharedInstance] getNodeStatus:^(NodeStatus *status) { NSDictionary *userInfo = [NSDictionary dictionaryWithObject:status forKey:@"status"]; @@ -90,7 +98,13 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status"; object:nil userInfo:userInfo]; }]; - }]; + } error:&error]; + + if (error) { + // TODO: Display error message + + [self stop]; + } } - (void)deleteSavedNetwork:(NSString*)networkId diff --git a/ZeroTier One/ServiceCom.h b/ZeroTier One/ServiceCom.h index a0665001..b24dd4a2 100644 --- a/ZeroTier One/ServiceCom.h +++ b/ZeroTier One/ServiceCom.h @@ -20,9 +20,9 @@ - (id)init; -- (void)getNetworklist:(void (^)(NSArray*))completionHandler; -- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler; -- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault; -- (void)leaveNetwork:(NSString*)networkId; +- (void)getNetworklist:(void (^)(NSArray*))completionHandler error:(NSError* __autoreleasing *)error; +- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error; +- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError*__autoreleasing*)error; +- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error; @end diff --git a/ZeroTier One/ServiceCom.m b/ZeroTier One/ServiceCom.m index 4e23d496..46468e25 100644 --- a/ZeroTier One/ServiceCom.m +++ b/ZeroTier One/ServiceCom.m @@ -39,7 +39,7 @@ return self; } -- (NSString*)key +- (NSString*)key:(NSError* __autoreleasing *)err { static NSString *k = nil; @@ -63,10 +63,20 @@ if (error) { NSLog(@"Error: %@", error); k = nil; + *err = error; return @""; } } else { + NSURL *sysAppSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:false error:nil]; + + sysAppSupportDir = [[sysAppSupportDir URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"]; + NSURL *sysAuthtokenURL = [sysAppSupportDir URLByAppendingPathComponent:@"authtoken.secret"]; + + if(![[NSFileManager defaultManager] fileExistsAtPath:[sysAuthtokenURL path]]) { + + } + [[NSFileManager defaultManager] createDirectoryAtURL:appSupportDir withIntermediateDirectories:YES attributes:nil @@ -74,6 +84,7 @@ if (error) { NSLog(@"Error: %@", error); + *err = error; k = nil; return @""; } @@ -83,6 +94,12 @@ if (status != errAuthorizationSuccess) { NSLog(@"Authorization Failed! %d", status); + + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't create AuthorizationRef", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; + return @""; } @@ -104,6 +121,10 @@ if (status != errAuthorizationSuccess) { NSLog(@"Authorization Failed! %d", status); + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't copy authorization rights", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; return @""; } @@ -120,21 +141,32 @@ if (error) { NSLog(@"Error writing token to disk: %@", error); + *err = error; } } } } if (k == nil) { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Unknown error finding authorization key", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; + return @""; } return k; } -- (void)getNetworklist:(void (^)(NSArray*))completionHandler +- (void)getNetworklist:(void (^)(NSArray *))completionHandler error:(NSError *__autoreleasing*)error { - NSString *urlString = [[baseURL stringByAppendingString:@"/network?auth="] stringByAppendingString:[self key]]; + NSString* key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[baseURL stringByAppendingString:@"/network?auth="] stringByAppendingString:key]; NSURL *url = [NSURL URLWithString:urlString]; NSURLSessionDataTask *task = @@ -171,31 +203,36 @@ [task resume]; } -- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler +- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error { - NSString *urlString = [[baseURL stringByAppendingString:@"/status?auth="] stringByAppendingString:[self key]]; + NSString *key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[baseURL stringByAppendingString:@"/status?auth="] stringByAppendingString:key]; NSURL *url = [NSURL URLWithString:urlString]; NSURLSessionDataTask *task = [session dataTaskWithURL:url - completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - if(error) { - NSLog(@"Error: %@", error); + if(err) { + NSLog(@"Error: %@", err); return; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; NSInteger status = [httpResponse statusCode]; - NSError *err; + NSError *err2; if(status == 200) { NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 - error:&err]; + error:&err2]; - if(err) { - NSLog(@"Error fetching node status: %@", err); + if(err2) { + NSLog(@"Error fetching node status: %@", err2); return; } @@ -207,10 +244,17 @@ [task resume]; } -- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault +- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError *__autoreleasing*)error { + NSString *key = [self key:error]; + if(*error) { + return; + } - NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] stringByAppendingString:networkId] stringByAppendingString:@"?auth="] stringByAppendingString:[self key]]; + NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] + stringByAppendingString:networkId] + stringByAppendingString:@"?auth="] + stringByAppendingString:key]; NSURL *url = [NSURL URLWithString:urlString]; @@ -227,6 +271,7 @@ if(err) { NSLog(@"Error creating json data: %@", err); + *error = err; return; } @@ -236,9 +281,9 @@ [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; NSURLSessionDataTask *task = - [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { if(error) { - NSLog(@"Error posting join request: %@", error); + NSLog(@"Error posting join request: %@", err); } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; @@ -254,9 +299,17 @@ [task resume]; } -- (void)leaveNetwork:(NSString*)networkId +- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error { - NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] stringByAppendingString:networkId] stringByAppendingString:@"?auth="] stringByAppendingString:[self key]]; + NSString *key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] + stringByAppendingString:networkId] + stringByAppendingString:@"?auth="] + stringByAppendingString:key]; NSURL *url = [NSURL URLWithString:urlString]; @@ -264,9 +317,9 @@ request.HTTPMethod = @"DELETE"; NSURLSessionDataTask *task = - [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - if(error) { - NSLog(@"Error posting delete request: %@", error); + [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { + if(err) { + NSLog(@"Error posting delete request: %@", err); return; } -- cgit v1.2.3 From 94263ffcc1213b9e46097dc6c6431b27a2f1d1b3 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 1 Sep 2016 19:02:27 -0700 Subject: Added error handling messages --- ZeroTier One/AppDelegate.m | 13 ++- ZeroTier One/JoinNetworkViewController.m | 6 +- ZeroTier One/NetworkInfoCell.m | 12 ++- ZeroTier One/NetworkMonitor.m | 37 ++++++++- ZeroTier One/ServiceCom.h | 1 + ZeroTier One/ServiceCom.m | 131 +++++++++++++++++++++++++++++-- 6 files changed, 183 insertions(+), 17 deletions(-) diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 048fa385..a0012838 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -271,8 +271,11 @@ [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; if (error) { - // TODO: Display error message + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + [alert runModal]; } } else { @@ -283,7 +286,13 @@ allowDefault:(network.allowDefault && ![Network defaultRouteExists:self.networks]) error:&error]; - // TODO: Display error message + if (error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + } } } diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m index f91589d9..e75cc841 100644 --- a/ZeroTier One/JoinNetworkViewController.m +++ b/ZeroTier One/JoinNetworkViewController.m @@ -80,7 +80,11 @@ NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; error:&error]; if(error) { - // TODO: display error message + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; return; } diff --git a/ZeroTier One/NetworkInfoCell.m b/ZeroTier One/NetworkInfoCell.m index 6ffb9e71..b37fa8a8 100644 --- a/ZeroTier One/NetworkInfoCell.m +++ b/ZeroTier One/NetworkInfoCell.m @@ -50,7 +50,11 @@ error:&error]; if (error) { - // TODO: Display error message + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; } } @@ -60,7 +64,11 @@ [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; if (error) { - // TODO: Display error message + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; } } diff --git a/ZeroTier One/NetworkMonitor.m b/ZeroTier One/NetworkMonitor.m index 59451325..e219e762 100644 --- a/ZeroTier One/NetworkMonitor.m +++ b/ZeroTier One/NetworkMonitor.m @@ -11,6 +11,9 @@ #import "ServiceCom.h" #import "NodeStatus.h" +@import AppKit; + + NSString * const NetworkUpdateKey = @"com.zerotier.one.network-list"; NSString * const StatusUpdateKey = @"com.zerotier.one.status"; @@ -85,9 +88,22 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status"; } error:&error]; if(error) { - // TODO: Display error message - [self stop]; + + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res = [alert runModal]; + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + else if(res == NSAlertSecondButtonReturn) { + [self start]; + return; + } } [[ServiceCom sharedInstance] getNodeStatus:^(NodeStatus *status) { @@ -101,9 +117,22 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status"; } error:&error]; if (error) { - // TODO: Display error message - [self stop]; + + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res = [alert runModal]; + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + else if(res == NSAlertSecondButtonReturn) { + [self start]; + return; + } } } diff --git a/ZeroTier One/ServiceCom.h b/ZeroTier One/ServiceCom.h index b24dd4a2..b7ef8dda 100644 --- a/ZeroTier One/ServiceCom.h +++ b/ZeroTier One/ServiceCom.h @@ -15,6 +15,7 @@ { NSString *baseURL; NSURLSession *session; + BOOL _isQuitting; } + (ServiceCom*)sharedInstance; diff --git a/ZeroTier One/ServiceCom.m b/ZeroTier One/ServiceCom.m index 46468e25..7c1b38be 100644 --- a/ZeroTier One/ServiceCom.m +++ b/ZeroTier One/ServiceCom.m @@ -10,6 +10,7 @@ #import "AuthtokenCopy.h" #import "Network.h" #import "NodeStatus.h" +@import AppKit; @interface ServiceCom (Private) @@ -34,6 +35,7 @@ if(self) { baseURL = @"http://localhost:9993"; session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]]; + _isQuitting = NO; } return self; @@ -171,24 +173,62 @@ NSURL *url = [NSURL URLWithString:urlString]; NSURLSessionDataTask *task = [session dataTaskWithURL:url - completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - if (error) { - NSLog(@"Error: %@", error); + if (err) { + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; return; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; NSInteger status = [httpResponse statusCode]; - NSError *err; + NSError *err2; if (status == 200) { NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 - error:&err]; + error:&err2]; if (err) { - NSLog(@"Error fetching network list: %@", err); + NSLog(@"Error fetching network list: %@", err2); + + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err2]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + _isQuitting = YES; + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + }]; return; } @@ -218,7 +258,25 @@ completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { if(err) { - NSLog(@"Error: %@", err); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; return; } @@ -233,6 +291,25 @@ if(err2) { NSLog(@"Error fetching node status: %@", err2); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err2]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; return; } @@ -282,8 +359,27 @@ NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - if(error) { + if(err) { NSLog(@"Error posting join request: %@", err); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; } NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; @@ -320,6 +416,25 @@ [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { if(err) { NSLog(@"Error posting delete request: %@", err); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; return; } -- cgit v1.2.3 From a813e29491faaa00c807c6784e04ba3e4e4e9eac Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 12:26:48 -0700 Subject: Don't need AppDelegate to be a NSMenuDelegate --- ZeroTier One/AppDelegate.h | 2 +- ZeroTier One/AppDelegate.m | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index d7779727..ef287bbb 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -12,7 +12,7 @@ @class Network; @class NodeStatus; -@interface AppDelegate : NSObject +@interface AppDelegate : NSObject @property (weak, nonatomic) IBOutlet NSWindow *window; diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index a0012838..de28dcdb 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -304,14 +304,6 @@ } } -- (void)menuWillOpen:(NSMenu*)menu { - -} - -- (void)menuDidClose:(NSMenu*)menu { - -} - - (void)darkModeChanged:(NSNotification*)note { NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; -- cgit v1.2.3 From 4730111492f5381f968b5b3def23ad5d7d9531c3 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 12:27:07 -0700 Subject: updated project settings for Xcode 8.0 --- ZeroTier One.xcodeproj/project.pbxproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj index 8f09edda..900daacb 100644 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ b/ZeroTier One.xcodeproj/project.pbxproj @@ -162,7 +162,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0730; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "ZeroTier, Inc"; TargetAttributes = { 93326BD71CE7C816005CA2AC = { @@ -254,8 +254,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; @@ -299,8 +301,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; -- cgit v1.2.3 From 46e9c1195cc232d99f53107c01a01f5ada3e8f8a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 12:29:28 -0700 Subject: more removal of NSMenuDelegate --- ZeroTier One/AppDelegate.h | 4 ++-- ZeroTier One/AppDelegate.m | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index ef287bbb..df66c17d 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -43,8 +43,8 @@ - (void)quit; - (void)toggleNetwork:(NSMenuItem*)sender; - (void)copyNodeID; -- (void)menuWillOpen:(NSMenu*)menu; -- (void)menuDidClose:(NSMenu*)menu; + +- (void)closeJoinNetworkPopover; - (void)darkModeChanged:(NSNotification*)note; diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index de28dcdb..9adbaa98 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -192,7 +192,6 @@ - (void)buildMenu { NSMenu *menu = [[NSMenu alloc] init]; - menu.delegate = self; if(self.status != nil) { NSString *nodeId = @"Node ID: "; @@ -315,4 +314,8 @@ } } +- (void)closeJoinNetworkPopover { + +} + @end -- cgit v1.2.3 From c44c3b053030d57afaf70790e82e69d14c736a83 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 12:31:59 -0700 Subject: cleanup --- ZeroTier One/JoinNetworkViewController.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m index e75cc841..d51f7de0 100644 --- a/ZeroTier One/JoinNetworkViewController.m +++ b/ZeroTier One/JoinNetworkViewController.m @@ -16,7 +16,6 @@ NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; @interface NSString (extra) - (BOOL)contains:(NSString*)find; -//- (NSString*)trunc:(NSInteger)length trailing:(NSString*)trailing; @end @@ -26,10 +25,6 @@ NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; NSRange range = [self rangeOfString:find]; return range.location != NSNotFound; } -// -//- (NSString*)trunc:(NSInteger)length trailing:(NSString*)trailing { -// -//} @end -- cgit v1.2.3 From ed58467d12914a9be53e47060cf148ab218b499a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 13:43:27 -0700 Subject: Clicking "Join" to join a new network now properly closes the popover --- ZeroTier One/AppDelegate.m | 5 +++-- ZeroTier One/JoinNetworkViewController.h | 3 +++ ZeroTier One/JoinNetworkViewController.m | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 9adbaa98..86c83367 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -59,8 +59,9 @@ object:nil]; [self buildMenu]; - - self.joinNetworkPopover.contentViewController = [[JoinNetworkViewController alloc] initWithNibName:@"JoinNetworkViewController" bundle:nil]; + JoinNetworkViewController *jnvc = [[JoinNetworkViewController alloc] initWithNibName:@"JoinNetworkViewController" bundle:nil]; + jnvc.appDelegate = self; + self.joinNetworkPopover.contentViewController = jnvc; self.joinNetworkPopover.behavior = NSPopoverBehaviorTransient; ShowNetworksViewController *showNetworksView = [[ShowNetworksViewController alloc] initWithNibName:@"ShowNetworksViewController" bundle:nil]; diff --git a/ZeroTier One/JoinNetworkViewController.h b/ZeroTier One/JoinNetworkViewController.h index 894b4ec2..a928d046 100644 --- a/ZeroTier One/JoinNetworkViewController.h +++ b/ZeroTier One/JoinNetworkViewController.h @@ -11,6 +11,8 @@ extern NSString * const JoinedNetworksKey; +@class AppDelegate; + @interface JoinNetworkViewController : NSViewController @property (nonatomic, weak) IBOutlet NSComboBox *network; @@ -18,6 +20,7 @@ extern NSString * const JoinedNetworksKey; @property (nonatomic, weak) IBOutlet NSButton *allowManagedCheckBox; @property (nonatomic, weak) IBOutlet NSButton *allowGlobalCheckBox; @property (nonatomic, weak) IBOutlet NSButton *allowDefaultCheckBox; +@property (nonatomic, weak) IBOutlet AppDelegate *appDelegate; @property (nonatomic) NSMutableArray *values; diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m index d51f7de0..abe8f959 100644 --- a/ZeroTier One/JoinNetworkViewController.m +++ b/ZeroTier One/JoinNetworkViewController.m @@ -8,7 +8,7 @@ #import "JoinNetworkViewController.h" #import "ServiceCom.h" - +#import "AppDelegate.h" NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; @@ -92,6 +92,8 @@ NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; [self.values removeLastObject]; } } + + [self.appDelegate closeJoinNetworkPopover]; } // NSComboBoxDelegate methods -- cgit v1.2.3 From f444da80bcafc7ded1395a0c5349e991fef2fcfd Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 13:43:44 -0700 Subject: Add a 2 second delay before the About window shows up on the first run --- ZeroTier One/AppDelegate.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index 86c83367..b1d8cce2 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -84,9 +84,12 @@ [prefsView setLaunchAtLoginEnabled:YES]; - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - [self showAbout]; - }]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + sleep(2); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + [self showAbout]; + }]; + }); } [self.monitor updateNetworkInfo]; @@ -316,7 +319,11 @@ } - (void)closeJoinNetworkPopover { - + if (self.transientMonitor) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + } + [self.joinNetworkPopover close]; } @end -- cgit v1.2.3 From 7c12991f5788d112535b880c282ca6f3e17596b8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 13:48:25 -0700 Subject: wasn't setting the Connected checkbox to off if the network wasn't connected --- ZeroTier One/ShowNetworksViewController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/ZeroTier One/ShowNetworksViewController.m b/ZeroTier One/ShowNetworksViewController.m index 2031af34..64e06197 100644 --- a/ZeroTier One/ShowNetworksViewController.m +++ b/ZeroTier One/ShowNetworksViewController.m @@ -88,6 +88,7 @@ cell.allowManaged.enabled = YES; } else { + cell.connectedCheckbox.state = NSOffState; cell.allowDefault.enabled = NO; cell.allowGlobal.enabled = NO; cell.allowManaged.enabled = NO; -- cgit v1.2.3 From 7025c7090b62d3404c2ea5eda0eb35fad1d2aafa Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 14:43:24 -0700 Subject: set proper copyright/license in code files --- ZeroTier One/AboutViewController.h | 24 +++++++++++++++++------- ZeroTier One/AboutViewController.m | 24 +++++++++++++++++------- ZeroTier One/AppDelegate.h | 24 +++++++++++++++++------- ZeroTier One/AppDelegate.m | 24 +++++++++++++++++------- ZeroTier One/AuthtokenCopy.h | 24 +++++++++++++++++------- ZeroTier One/AuthtokenCopy.m | 26 ++++++++++++++++++-------- ZeroTier One/JoinNetworkViewController.h | 24 +++++++++++++++++------- ZeroTier One/JoinNetworkViewController.m | 24 +++++++++++++++++------- ZeroTier One/Network.h | 24 +++++++++++++++++------- ZeroTier One/Network.m | 24 +++++++++++++++++------- ZeroTier One/NetworkInfoCell.h | 24 +++++++++++++++++------- ZeroTier One/NetworkInfoCell.m | 24 +++++++++++++++++------- ZeroTier One/NetworkMonitor.h | 24 +++++++++++++++++------- ZeroTier One/NetworkMonitor.m | 26 ++++++++++++++++++-------- ZeroTier One/NodeStatus.h | 24 +++++++++++++++++------- ZeroTier One/NodeStatus.m | 25 +++++++++++++++++-------- ZeroTier One/PreferencesViewController.h | 24 +++++++++++++++++------- ZeroTier One/PreferencesViewController.m | 24 +++++++++++++++++------- ZeroTier One/ServiceCom.h | 24 +++++++++++++++++------- ZeroTier One/ServiceCom.m | 24 +++++++++++++++++------- ZeroTier One/ShowNetworksViewController.h | 24 +++++++++++++++++------- ZeroTier One/ShowNetworksViewController.m | 24 +++++++++++++++++------- ZeroTier One/main.m | 24 +++++++++++++++++------- 23 files changed, 393 insertions(+), 164 deletions(-) diff --git a/ZeroTier One/AboutViewController.h b/ZeroTier One/AboutViewController.h index 4260419e..d3d5bc14 100644 --- a/ZeroTier One/AboutViewController.h +++ b/ZeroTier One/AboutViewController.h @@ -1,10 +1,20 @@ -// -// AboutViewController.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import #import diff --git a/ZeroTier One/AboutViewController.m b/ZeroTier One/AboutViewController.m index c0b6ec85..21dceae1 100644 --- a/ZeroTier One/AboutViewController.m +++ b/ZeroTier One/AboutViewController.m @@ -1,10 +1,20 @@ -// -// AboutViewController.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "AboutViewController.h" diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h index df66c17d..a00cfba9 100644 --- a/ZeroTier One/AppDelegate.h +++ b/ZeroTier One/AppDelegate.h @@ -1,10 +1,20 @@ -// -// AppDelegate.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m index b1d8cce2..5da6b354 100644 --- a/ZeroTier One/AppDelegate.m +++ b/ZeroTier One/AppDelegate.m @@ -1,10 +1,20 @@ -// -// AppDelegate.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "AppDelegate.h" #import "NetworkMonitor.h" diff --git a/ZeroTier One/AuthtokenCopy.h b/ZeroTier One/AuthtokenCopy.h index 43c927e2..f0497cc6 100644 --- a/ZeroTier One/AuthtokenCopy.h +++ b/ZeroTier One/AuthtokenCopy.h @@ -1,10 +1,20 @@ -// -// AuthtokenCopy.h -// ZeroTier One -// -// Created by Grant Limberg on 5/31/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #ifndef AuthtokenCopy_h #define AuthtokenCopy_h diff --git a/ZeroTier One/AuthtokenCopy.m b/ZeroTier One/AuthtokenCopy.m index 893d90cf..a10350f7 100644 --- a/ZeroTier One/AuthtokenCopy.m +++ b/ZeroTier One/AuthtokenCopy.m @@ -1,10 +1,20 @@ -// -// AuthtokenCopy.m -// ZeroTier One -// -// Created by Grant Limberg on 5/31/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import @@ -84,4 +94,4 @@ NSString* getAdminAuthToken(AuthorizationRef authRef) { } return @""; -} \ No newline at end of file +} diff --git a/ZeroTier One/JoinNetworkViewController.h b/ZeroTier One/JoinNetworkViewController.h index a928d046..428959fb 100644 --- a/ZeroTier One/JoinNetworkViewController.h +++ b/ZeroTier One/JoinNetworkViewController.h @@ -1,10 +1,20 @@ -// -// JoinNetworkViewController.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m index abe8f959..cae26541 100644 --- a/ZeroTier One/JoinNetworkViewController.m +++ b/ZeroTier One/JoinNetworkViewController.m @@ -1,10 +1,20 @@ -// -// JoinNetworkViewController.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "JoinNetworkViewController.h" #import "ServiceCom.h" diff --git a/ZeroTier One/Network.h b/ZeroTier One/Network.h index f8d0deb4..0f3c4964 100644 --- a/ZeroTier One/Network.h +++ b/ZeroTier One/Network.h @@ -1,10 +1,20 @@ -// -// Network.h -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/Network.m b/ZeroTier One/Network.m index 30b3f884..16efc6e3 100644 --- a/ZeroTier One/Network.m +++ b/ZeroTier One/Network.m @@ -1,10 +1,20 @@ -// -// Network.m -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "Network.h" diff --git a/ZeroTier One/NetworkInfoCell.h b/ZeroTier One/NetworkInfoCell.h index b687bc4f..be9345d7 100644 --- a/ZeroTier One/NetworkInfoCell.h +++ b/ZeroTier One/NetworkInfoCell.h @@ -1,10 +1,20 @@ -// -// NetworkInfoCell.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/NetworkInfoCell.m b/ZeroTier One/NetworkInfoCell.m index b37fa8a8..dc75cab3 100644 --- a/ZeroTier One/NetworkInfoCell.m +++ b/ZeroTier One/NetworkInfoCell.m @@ -1,10 +1,20 @@ -// -// NetworkInfoCell.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "NetworkInfoCell.h" #import "ServiceCom.h" diff --git a/ZeroTier One/NetworkMonitor.h b/ZeroTier One/NetworkMonitor.h index 0bd94814..8cdec4ed 100644 --- a/ZeroTier One/NetworkMonitor.h +++ b/ZeroTier One/NetworkMonitor.h @@ -1,10 +1,20 @@ -// -// NetworkMonitor.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/NetworkMonitor.m b/ZeroTier One/NetworkMonitor.m index e219e762..7ed22c4a 100644 --- a/ZeroTier One/NetworkMonitor.m +++ b/ZeroTier One/NetworkMonitor.m @@ -1,10 +1,20 @@ -// -// NetworkMonitor.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "NetworkMonitor.h" #import "Network.h" @@ -240,4 +250,4 @@ NSString * const StatusUpdateKey = @"com.zerotier.one.status"; } } -@end \ No newline at end of file +@end diff --git a/ZeroTier One/NodeStatus.h b/ZeroTier One/NodeStatus.h index 074928b4..eab5bfe4 100644 --- a/ZeroTier One/NodeStatus.h +++ b/ZeroTier One/NodeStatus.h @@ -1,10 +1,20 @@ -// -// NodeStatus.h -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/NodeStatus.m b/ZeroTier One/NodeStatus.m index 5a368491..3bae3c7d 100644 --- a/ZeroTier One/NodeStatus.m +++ b/ZeroTier One/NodeStatus.m @@ -1,11 +1,20 @@ -// -// NodeStatus.m -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// - +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "NodeStatus.h" @implementation NodeStatus diff --git a/ZeroTier One/PreferencesViewController.h b/ZeroTier One/PreferencesViewController.h index e9e4e4b1..56d0fdb8 100644 --- a/ZeroTier One/PreferencesViewController.h +++ b/ZeroTier One/PreferencesViewController.h @@ -1,10 +1,20 @@ -// -// PreferencesViewController.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/PreferencesViewController.m b/ZeroTier One/PreferencesViewController.m index 2292367d..13927fba 100644 --- a/ZeroTier One/PreferencesViewController.m +++ b/ZeroTier One/PreferencesViewController.m @@ -1,10 +1,20 @@ -// -// PreferencesViewController.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "PreferencesViewController.h" diff --git a/ZeroTier One/ServiceCom.h b/ZeroTier One/ServiceCom.h index b7ef8dda..74ab2b35 100644 --- a/ZeroTier One/ServiceCom.h +++ b/ZeroTier One/ServiceCom.h @@ -1,10 +1,20 @@ -// -// ServiceCom.h -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/ServiceCom.m b/ZeroTier One/ServiceCom.m index 7c1b38be..4982d40e 100644 --- a/ZeroTier One/ServiceCom.m +++ b/ZeroTier One/ServiceCom.m @@ -1,10 +1,20 @@ -// -// ServiceCom.m -// ZeroTier One -// -// Created by Grant Limberg on 8/4/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "ServiceCom.h" #import "AuthtokenCopy.h" diff --git a/ZeroTier One/ShowNetworksViewController.h b/ZeroTier One/ShowNetworksViewController.h index 5722d3f4..5c251674 100644 --- a/ZeroTier One/ShowNetworksViewController.h +++ b/ZeroTier One/ShowNetworksViewController.h @@ -1,10 +1,20 @@ -// -// ShowNetworksViewController.h -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import diff --git a/ZeroTier One/ShowNetworksViewController.m b/ZeroTier One/ShowNetworksViewController.m index 64e06197..e3a1e52c 100644 --- a/ZeroTier One/ShowNetworksViewController.m +++ b/ZeroTier One/ShowNetworksViewController.m @@ -1,10 +1,20 @@ -// -// ShowNetworksViewController.m -// ZeroTier One -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import "ShowNetworksViewController.h" #import "NetworkMonitor.h" diff --git a/ZeroTier One/main.m b/ZeroTier One/main.m index 399c483d..108a6bd1 100644 --- a/ZeroTier One/main.m +++ b/ZeroTier One/main.m @@ -1,10 +1,20 @@ -// -// main.m -// testapp -// -// Created by Grant Limberg on 8/7/16. -// Copyright © 2016 ZeroTier, Inc. All rights reserved. -// +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #import -- cgit v1.2.3 From 7b7ec133496db4fef867d9100285a02cd3f1aed6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 17 Oct 2016 14:44:32 -0700 Subject: Prepare for merging into main ZeroTier repo --- ZeroTier One.xcodeproj/project.pbxproj | 382 ------------ .../project.xcworkspace/contents.xcworkspacedata | 7 - ZeroTier One/AboutViewController.h | 33 - ZeroTier One/AboutViewController.m | 56 -- ZeroTier One/AboutViewController.xib | 31 - ZeroTier One/AppDelegate.h | 61 -- ZeroTier One/AppDelegate.m | 339 ---------- .../AppIcon.appiconset/Contents.json | 59 -- .../AppIcon.appiconset/ZeroTierIcon512x512.png | Bin 51309 -> 0 bytes ZeroTier One/Assets.xcassets/Contents.json | 6 - .../MenuBarIconMac.imageset/Contents.json | 21 - .../MenuBarIconMac.imageset/MenuBar@2x.png | Bin 22973 -> 0 bytes .../MenuBarIconMac.imageset/Menubar.png | Bin 17234 -> 0 bytes .../MenuBarIconMacWhite.imageset/Contents.json | 21 - .../MenuBarIconMacWhite.imageset/MenubarWhite.png | Bin 17234 -> 0 bytes .../MenubarWhite@2x.png | Bin 22973 -> 0 bytes ZeroTier One/AuthtokenCopy.h | 26 - ZeroTier One/AuthtokenCopy.m | 97 --- ZeroTier One/Base.lproj/MainMenu.xib | 680 --------------------- ZeroTier One/Info.plist | 41 -- ZeroTier One/JoinNetworkViewController.h | 40 -- ZeroTier One/JoinNetworkViewController.m | 184 ------ ZeroTier One/JoinNetworkViewController.xib | 74 --- ZeroTier One/Network.h | 62 -- ZeroTier One/Network.m | 278 --------- ZeroTier One/NetworkInfoCell.h | 50 -- ZeroTier One/NetworkInfoCell.m | 85 --- ZeroTier One/NetworkMonitor.h | 45 -- ZeroTier One/NetworkMonitor.m | 253 -------- ZeroTier One/NodeStatus.h | 35 -- ZeroTier One/NodeStatus.m | 40 -- ZeroTier One/PreferencesViewController.h | 31 - ZeroTier One/PreferencesViewController.m | 112 ---- ZeroTier One/PreferencesViewController.xib | 33 - ZeroTier One/ServiceCom.h | 39 -- ZeroTier One/ServiceCom.m | 464 -------------- ZeroTier One/ShowNetworksViewController.h | 36 -- ZeroTier One/ShowNetworksViewController.m | 119 ---- ZeroTier One/ShowNetworksViewController.xib | 370 ----------- ZeroTier One/ZeroTierIcon.icns | Bin 125598 -> 0 bytes ZeroTier One/about.html | 65 -- ZeroTier One/main.m | 23 - macui/ZeroTier One.xcodeproj/project.pbxproj | 382 ++++++++++++ .../project.xcworkspace/contents.xcworkspacedata | 7 + macui/ZeroTier One/AboutViewController.h | 33 + macui/ZeroTier One/AboutViewController.m | 56 ++ macui/ZeroTier One/AboutViewController.xib | 31 + macui/ZeroTier One/AppDelegate.h | 61 ++ macui/ZeroTier One/AppDelegate.m | 339 ++++++++++ .../AppIcon.appiconset/Contents.json | 59 ++ .../AppIcon.appiconset/ZeroTierIcon512x512.png | Bin 0 -> 51309 bytes macui/ZeroTier One/Assets.xcassets/Contents.json | 6 + .../MenuBarIconMac.imageset/Contents.json | 21 + .../MenuBarIconMac.imageset/MenuBar@2x.png | Bin 0 -> 22973 bytes .../MenuBarIconMac.imageset/Menubar.png | Bin 0 -> 17234 bytes .../MenuBarIconMacWhite.imageset/Contents.json | 21 + .../MenuBarIconMacWhite.imageset/MenubarWhite.png | Bin 0 -> 17234 bytes .../MenubarWhite@2x.png | Bin 0 -> 22973 bytes macui/ZeroTier One/AuthtokenCopy.h | 26 + macui/ZeroTier One/AuthtokenCopy.m | 97 +++ macui/ZeroTier One/Base.lproj/MainMenu.xib | 680 +++++++++++++++++++++ macui/ZeroTier One/Info.plist | 41 ++ macui/ZeroTier One/JoinNetworkViewController.h | 40 ++ macui/ZeroTier One/JoinNetworkViewController.m | 184 ++++++ macui/ZeroTier One/JoinNetworkViewController.xib | 74 +++ macui/ZeroTier One/Network.h | 62 ++ macui/ZeroTier One/Network.m | 278 +++++++++ macui/ZeroTier One/NetworkInfoCell.h | 50 ++ macui/ZeroTier One/NetworkInfoCell.m | 85 +++ macui/ZeroTier One/NetworkMonitor.h | 45 ++ macui/ZeroTier One/NetworkMonitor.m | 253 ++++++++ macui/ZeroTier One/NodeStatus.h | 35 ++ macui/ZeroTier One/NodeStatus.m | 40 ++ macui/ZeroTier One/PreferencesViewController.h | 31 + macui/ZeroTier One/PreferencesViewController.m | 112 ++++ macui/ZeroTier One/PreferencesViewController.xib | 33 + macui/ZeroTier One/ServiceCom.h | 39 ++ macui/ZeroTier One/ServiceCom.m | 464 ++++++++++++++ macui/ZeroTier One/ShowNetworksViewController.h | 36 ++ macui/ZeroTier One/ShowNetworksViewController.m | 119 ++++ macui/ZeroTier One/ShowNetworksViewController.xib | 370 +++++++++++ macui/ZeroTier One/ZeroTierIcon.icns | Bin 0 -> 125598 bytes macui/ZeroTier One/about.html | 65 ++ macui/ZeroTier One/main.m | 23 + 84 files changed, 4298 insertions(+), 4298 deletions(-) delete mode 100644 ZeroTier One.xcodeproj/project.pbxproj delete mode 100644 ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 ZeroTier One/AboutViewController.h delete mode 100644 ZeroTier One/AboutViewController.m delete mode 100644 ZeroTier One/AboutViewController.xib delete mode 100644 ZeroTier One/AppDelegate.h delete mode 100644 ZeroTier One/AppDelegate.m delete mode 100644 ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png delete mode 100644 ZeroTier One/Assets.xcassets/Contents.json delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png delete mode 100644 ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png delete mode 100644 ZeroTier One/AuthtokenCopy.h delete mode 100644 ZeroTier One/AuthtokenCopy.m delete mode 100644 ZeroTier One/Base.lproj/MainMenu.xib delete mode 100644 ZeroTier One/Info.plist delete mode 100644 ZeroTier One/JoinNetworkViewController.h delete mode 100644 ZeroTier One/JoinNetworkViewController.m delete mode 100644 ZeroTier One/JoinNetworkViewController.xib delete mode 100644 ZeroTier One/Network.h delete mode 100644 ZeroTier One/Network.m delete mode 100644 ZeroTier One/NetworkInfoCell.h delete mode 100644 ZeroTier One/NetworkInfoCell.m delete mode 100644 ZeroTier One/NetworkMonitor.h delete mode 100644 ZeroTier One/NetworkMonitor.m delete mode 100644 ZeroTier One/NodeStatus.h delete mode 100644 ZeroTier One/NodeStatus.m delete mode 100644 ZeroTier One/PreferencesViewController.h delete mode 100644 ZeroTier One/PreferencesViewController.m delete mode 100644 ZeroTier One/PreferencesViewController.xib delete mode 100644 ZeroTier One/ServiceCom.h delete mode 100644 ZeroTier One/ServiceCom.m delete mode 100644 ZeroTier One/ShowNetworksViewController.h delete mode 100644 ZeroTier One/ShowNetworksViewController.m delete mode 100644 ZeroTier One/ShowNetworksViewController.xib delete mode 100644 ZeroTier One/ZeroTierIcon.icns delete mode 100644 ZeroTier One/about.html delete mode 100644 ZeroTier One/main.m create mode 100644 macui/ZeroTier One.xcodeproj/project.pbxproj create mode 100644 macui/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 macui/ZeroTier One/AboutViewController.h create mode 100644 macui/ZeroTier One/AboutViewController.m create mode 100644 macui/ZeroTier One/AboutViewController.xib create mode 100644 macui/ZeroTier One/AppDelegate.h create mode 100644 macui/ZeroTier One/AppDelegate.m create mode 100644 macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png create mode 100644 macui/ZeroTier One/Assets.xcassets/Contents.json create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png create mode 100644 macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png create mode 100644 macui/ZeroTier One/AuthtokenCopy.h create mode 100644 macui/ZeroTier One/AuthtokenCopy.m create mode 100644 macui/ZeroTier One/Base.lproj/MainMenu.xib create mode 100644 macui/ZeroTier One/Info.plist create mode 100644 macui/ZeroTier One/JoinNetworkViewController.h create mode 100644 macui/ZeroTier One/JoinNetworkViewController.m create mode 100644 macui/ZeroTier One/JoinNetworkViewController.xib create mode 100644 macui/ZeroTier One/Network.h create mode 100644 macui/ZeroTier One/Network.m create mode 100644 macui/ZeroTier One/NetworkInfoCell.h create mode 100644 macui/ZeroTier One/NetworkInfoCell.m create mode 100644 macui/ZeroTier One/NetworkMonitor.h create mode 100644 macui/ZeroTier One/NetworkMonitor.m create mode 100644 macui/ZeroTier One/NodeStatus.h create mode 100644 macui/ZeroTier One/NodeStatus.m create mode 100644 macui/ZeroTier One/PreferencesViewController.h create mode 100644 macui/ZeroTier One/PreferencesViewController.m create mode 100644 macui/ZeroTier One/PreferencesViewController.xib create mode 100644 macui/ZeroTier One/ServiceCom.h create mode 100644 macui/ZeroTier One/ServiceCom.m create mode 100644 macui/ZeroTier One/ShowNetworksViewController.h create mode 100644 macui/ZeroTier One/ShowNetworksViewController.m create mode 100644 macui/ZeroTier One/ShowNetworksViewController.xib create mode 100644 macui/ZeroTier One/ZeroTierIcon.icns create mode 100644 macui/ZeroTier One/about.html create mode 100644 macui/ZeroTier One/main.m diff --git a/ZeroTier One.xcodeproj/project.pbxproj b/ZeroTier One.xcodeproj/project.pbxproj deleted file mode 100644 index 900daacb..00000000 --- a/ZeroTier One.xcodeproj/project.pbxproj +++ /dev/null @@ -1,382 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; }; - 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; }; - 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */; }; - 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; - 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; - 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */; }; - 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */; }; - 93D1675F1D54191C00330C99 /* NodeStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1675E1D54191C00330C99 /* NodeStatus.m */; }; - 93D167621D541BC200330C99 /* ServiceCom.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167611D541BC200330C99 /* ServiceCom.m */; }; - 93D167661D54308200330C99 /* Network.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167651D54308200330C99 /* Network.m */; }; - 93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167681D57E7EA00330C99 /* AboutViewController.m */; }; - 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */; }; - 93D167701D57FD3800330C99 /* NetworkMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */; }; - 93D167731D58093C00330C99 /* NetworkInfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167721D58093C00330C99 /* NetworkInfoCell.m */; }; - 93D167761D580C3500330C99 /* ShowNetworksViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167751D580C3500330C99 /* ShowNetworksViewController.m */; }; - 93D167791D5815E600330C99 /* JoinNetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167781D5815E600330C99 /* JoinNetworkViewController.m */; }; - 93D1677C1D58228A00330C99 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1677B1D58228A00330C99 /* AppDelegate.m */; }; - 93D1679B1D58300F00330C99 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1679A1D58300F00330C99 /* main.m */; }; - 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D1679C1D595F0000330C99 /* WebKit.framework */; }; - 93DAFB271D3F0BEE004D5417 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = 93DAFB261D3F0BEE004D5417 /* about.html */; }; - 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = ""; }; - 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = ""; }; - 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AboutViewController.xib; sourceTree = ""; }; - 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 93326BE01CE7C816005CA2AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 93326BE21CE7C816005CA2AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JoinNetworkViewController.xib; sourceTree = ""; }; - 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowNetworksViewController.xib; sourceTree = ""; }; - 93D1675D1D54191C00330C99 /* NodeStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeStatus.h; sourceTree = ""; }; - 93D1675E1D54191C00330C99 /* NodeStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NodeStatus.m; sourceTree = ""; }; - 93D167601D541BC200330C99 /* ServiceCom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceCom.h; sourceTree = ""; }; - 93D167611D541BC200330C99 /* ServiceCom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ServiceCom.m; sourceTree = ""; }; - 93D167641D54308200330C99 /* Network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Network.h; sourceTree = ""; }; - 93D167651D54308200330C99 /* Network.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Network.m; sourceTree = ""; }; - 93D167671D57E7EA00330C99 /* AboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutViewController.h; sourceTree = ""; }; - 93D167681D57E7EA00330C99 /* AboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutViewController.m; sourceTree = ""; }; - 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesViewController.h; sourceTree = ""; }; - 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesViewController.m; sourceTree = ""; }; - 93D1676E1D57FD3800330C99 /* NetworkMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkMonitor.h; sourceTree = ""; }; - 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkMonitor.m; sourceTree = ""; }; - 93D167711D58093C00330C99 /* NetworkInfoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkInfoCell.h; sourceTree = ""; }; - 93D167721D58093C00330C99 /* NetworkInfoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkInfoCell.m; sourceTree = ""; }; - 93D167741D580C3500330C99 /* ShowNetworksViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShowNetworksViewController.h; sourceTree = ""; }; - 93D167751D580C3500330C99 /* ShowNetworksViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShowNetworksViewController.m; sourceTree = ""; }; - 93D167771D5815E600330C99 /* JoinNetworkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoinNetworkViewController.h; sourceTree = ""; }; - 93D167781D5815E600330C99 /* JoinNetworkViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JoinNetworkViewController.m; sourceTree = ""; }; - 93D1677A1D58228A00330C99 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 93D1677B1D58228A00330C99 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 93D1679A1D58300F00330C99 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 93D1679C1D595F0000330C99 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; - 93DAFB261D3F0BEE004D5417 /* about.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = about.html; sourceTree = ""; }; - 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthtokenCopy.m; sourceTree = ""; }; - 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthtokenCopy.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 93326BD51CE7C816005CA2AC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 93326BCF1CE7C816005CA2AC = { - isa = PBXGroup; - children = ( - 93D1679C1D595F0000330C99 /* WebKit.framework */, - 93326BDA1CE7C816005CA2AC /* ZeroTier One */, - 93326BD91CE7C816005CA2AC /* Products */, - ); - sourceTree = ""; - }; - 93326BD91CE7C816005CA2AC /* Products */ = { - isa = PBXGroup; - children = ( - 93326BD81CE7C816005CA2AC /* ZeroTier One.app */, - ); - name = Products; - sourceTree = ""; - }; - 93326BDA1CE7C816005CA2AC /* ZeroTier One */ = { - isa = PBXGroup; - children = ( - 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */, - 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, - 93326BDF1CE7C816005CA2AC /* MainMenu.xib */, - 93326BE21CE7C816005CA2AC /* Info.plist */, - 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */, - 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */, - 93D1676E1D57FD3800330C99 /* NetworkMonitor.h */, - 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */, - 93DAFB261D3F0BEE004D5417 /* about.html */, - 93D1675D1D54191C00330C99 /* NodeStatus.h */, - 93D1675E1D54191C00330C99 /* NodeStatus.m */, - 93D167601D541BC200330C99 /* ServiceCom.h */, - 93D167611D541BC200330C99 /* ServiceCom.m */, - 93D167641D54308200330C99 /* Network.h */, - 93D167651D54308200330C99 /* Network.m */, - 93D167671D57E7EA00330C99 /* AboutViewController.h */, - 93D167681D57E7EA00330C99 /* AboutViewController.m */, - 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */, - 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */, - 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */, - 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */, - 93D167711D58093C00330C99 /* NetworkInfoCell.h */, - 93D167721D58093C00330C99 /* NetworkInfoCell.m */, - 93D167741D580C3500330C99 /* ShowNetworksViewController.h */, - 93D167751D580C3500330C99 /* ShowNetworksViewController.m */, - 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */, - 93D167771D5815E600330C99 /* JoinNetworkViewController.h */, - 93D167781D5815E600330C99 /* JoinNetworkViewController.m */, - 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */, - 93D1677A1D58228A00330C99 /* AppDelegate.h */, - 93D1677B1D58228A00330C99 /* AppDelegate.m */, - 93D1679A1D58300F00330C99 /* main.m */, - ); - path = "ZeroTier One"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 93326BD71CE7C816005CA2AC /* ZeroTier One */ = { - isa = PBXNativeTarget; - buildConfigurationList = 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */; - buildPhases = ( - 93326BD41CE7C816005CA2AC /* Sources */, - 93326BD51CE7C816005CA2AC /* Frameworks */, - 93326BD61CE7C816005CA2AC /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "ZeroTier One"; - productName = "ZeroTier One"; - productReference = 93326BD81CE7C816005CA2AC /* ZeroTier One.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 93326BD01CE7C816005CA2AC /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; - ORGANIZATIONNAME = "ZeroTier, Inc"; - TargetAttributes = { - 93326BD71CE7C816005CA2AC = { - CreatedOnToolsVersion = 7.3; - }; - }; - }; - buildConfigurationList = 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 93326BCF1CE7C816005CA2AC; - productRefGroup = 93326BD91CE7C816005CA2AC /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 93326BD71CE7C816005CA2AC /* ZeroTier One */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 93326BD61CE7C816005CA2AC /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 93DAFB271D3F0BEE004D5417 /* about.html in Resources */, - 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */, - 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */, - 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */, - 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, - 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, - 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */, - 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 93326BD41CE7C816005CA2AC /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 93D1679B1D58300F00330C99 /* main.m in Sources */, - 93D167621D541BC200330C99 /* ServiceCom.m in Sources */, - 93D167761D580C3500330C99 /* ShowNetworksViewController.m in Sources */, - 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */, - 93D167701D57FD3800330C99 /* NetworkMonitor.m in Sources */, - 93D1675F1D54191C00330C99 /* NodeStatus.m in Sources */, - 93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */, - 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */, - 93D1677C1D58228A00330C99 /* AppDelegate.m in Sources */, - 93D167731D58093C00330C99 /* NetworkInfoCell.m in Sources */, - 93D167661D54308200330C99 /* Network.m in Sources */, - 93D167791D5815E600330C99 /* JoinNetworkViewController.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 93326BDF1CE7C816005CA2AC /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 93326BE01CE7C816005CA2AC /* Base */, - ); - name = MainMenu.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 93326BE31CE7C816005CA2AC /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 93326BE41CE7C816005CA2AC /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - }; - name = Release; - }; - 93326BE61CE7C816005CA2AC /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = "ZeroTier One/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 93326BE71CE7C816005CA2AC /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = "ZeroTier One/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.7; - PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 93326BE31CE7C816005CA2AC /* Debug */, - 93326BE41CE7C816005CA2AC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 93326BE61CE7C816005CA2AC /* Debug */, - 93326BE71CE7C816005CA2AC /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 93326BD01CE7C816005CA2AC /* Project object */; -} diff --git a/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index fd60338e..00000000 --- a/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ZeroTier One/AboutViewController.h b/ZeroTier One/AboutViewController.h deleted file mode 100644 index d3d5bc14..00000000 --- a/ZeroTier One/AboutViewController.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import -#import - -@interface AboutViewController : NSViewController - -@property (nonatomic, weak) IBOutlet WebView *webView; - -- (void)viewDidLoad; - -- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation - request:(NSURLRequest *)request - frame:(WebFrame *)frame -decisionListener:(id)listener; - -@end diff --git a/ZeroTier One/AboutViewController.m b/ZeroTier One/AboutViewController.m deleted file mode 100644 index 21dceae1..00000000 --- a/ZeroTier One/AboutViewController.m +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "AboutViewController.h" - -@interface AboutViewController () - -@end - -@implementation AboutViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self.webView setWantsLayer:YES]; - self.webView.layer.borderWidth = 1.0f; - [self.webView.layer setCornerRadius:1.0f]; - self.webView.layer.masksToBounds = YES; - [self.webView.layer setBorderColor:[[NSColor darkGrayColor] CGColor]]; - - NSBundle *bundle = [NSBundle mainBundle]; - NSURL *path = [bundle URLForResource:@"about" withExtension:@"html"]; - if(path) { - [self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:path]]; - } -} - -- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation - request:(NSURLRequest *)request - frame:(WebFrame *)frame -decisionListener:(id)listener -{ - if(request.URL != nil && request.URL.host != nil) { - [[NSWorkspace sharedWorkspace] openURL:request.URL]; - } - else { - [listener use]; - } -} - -@end diff --git a/ZeroTier One/AboutViewController.xib b/ZeroTier One/AboutViewController.xib deleted file mode 100644 index a0df0fcf..00000000 --- a/ZeroTier One/AboutViewController.xib +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One/AppDelegate.h b/ZeroTier One/AppDelegate.h deleted file mode 100644 index a00cfba9..00000000 --- a/ZeroTier One/AppDelegate.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@class NetworkMonitor; -@class Network; -@class NodeStatus; - -@interface AppDelegate : NSObject - -@property (weak, nonatomic) IBOutlet NSWindow *window; - -@property (nonatomic) NSStatusItem *statusItem; - -@property (nonatomic) NSPopover *networkListPopover; -@property (nonatomic) NSPopover *joinNetworkPopover; -@property (nonatomic) NSPopover *preferencesPopover; -@property (nonatomic) NSPopover *aboutPopover; - -@property (nonatomic) id transientMonitor; - -@property (nonatomic) NetworkMonitor *monitor; - -@property (nonatomic) NSMutableArray *networks; - -@property (nonatomic) NodeStatus *status; - -- (void)buildMenu; - -- (void)onNetworkListUpdated:(NSNotification*)note; -- (void)onNodeStatusUpdated:(NSNotification*)note; - -- (void)showNetworks; -- (void)joinNetwork; -- (void)showPreferences; -- (void)showAbout; -- (void)quit; -- (void)toggleNetwork:(NSMenuItem*)sender; -- (void)copyNodeID; - -- (void)closeJoinNetworkPopover; - -- (void)darkModeChanged:(NSNotification*)note; - -@end diff --git a/ZeroTier One/AppDelegate.m b/ZeroTier One/AppDelegate.m deleted file mode 100644 index 5da6b354..00000000 --- a/ZeroTier One/AppDelegate.m +++ /dev/null @@ -1,339 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "AppDelegate.h" -#import "NetworkMonitor.h" -#import "Network.h" -#import "NodeStatus.h" -#import "JoinNetworkViewController.h" -#import "ShowNetworksViewController.h" -#import "PreferencesViewController.h" -#import "AboutViewController.h" -#import "ServiceCom.h" - -@implementation AppDelegate - -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:-2.0f]; - self.networkListPopover = [[NSPopover alloc] init]; - self.joinNetworkPopover = [[NSPopover alloc] init]; - self.preferencesPopover = [[NSPopover alloc] init]; - self.aboutPopover = [[NSPopover alloc] init]; - self.transientMonitor = nil; - self.monitor = [[NetworkMonitor alloc] init]; - self.networks = [NSMutableArray array]; - self.status = nil; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"firstRun"]; - [defaults registerDefaults:defaultsDict]; - - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - [nc addObserver:self - selector:@selector(onNetworkListUpdated:) - name:NetworkUpdateKey - object:nil]; - [nc addObserver:self - selector:@selector(onNodeStatusUpdated:) - name:StatusUpdateKey - object:nil]; - - NSString *osxMode = [defaults stringForKey:@"AppleInterfaceStyle"]; - - if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; - } - else { - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; - } - - [[NSDistributedNotificationCenter defaultCenter] addObserver:self - selector:@selector(darkModeChanged:) - name:@"AppleInterfaceThemeChangedNotification" - object:nil]; - - [self buildMenu]; - JoinNetworkViewController *jnvc = [[JoinNetworkViewController alloc] initWithNibName:@"JoinNetworkViewController" bundle:nil]; - jnvc.appDelegate = self; - self.joinNetworkPopover.contentViewController = jnvc; - self.joinNetworkPopover.behavior = NSPopoverBehaviorTransient; - - ShowNetworksViewController *showNetworksView = [[ShowNetworksViewController alloc] initWithNibName:@"ShowNetworksViewController" bundle:nil]; - showNetworksView.netMonitor = self.monitor; - self.networkListPopover.contentViewController = showNetworksView; - self.networkListPopover.behavior = NSPopoverBehaviorTransient; - - PreferencesViewController *prefsView = [[PreferencesViewController alloc] initWithNibName:@"PreferencesViewController" bundle:nil]; - self.preferencesPopover.contentViewController = prefsView; - self.preferencesPopover.behavior = NSPopoverBehaviorTransient; - - self.aboutPopover.contentViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil]; - self.aboutPopover.behavior = NSPopoverBehaviorTransient; - - BOOL firstRun = [defaults boolForKey:@"firstRun"]; - - if(firstRun) { - [defaults setBool:NO forKey:@"firstRun"]; - [defaults synchronize]; - - [prefsView setLaunchAtLoginEnabled:YES]; - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - sleep(2); - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - [self showAbout]; - }]; - }); - } - - [self.monitor updateNetworkInfo]; - [self.monitor start]; -} - -- (void)applicationWillTerminate:(NSNotification *)aNotification { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - [[NSDistributedNotificationCenter defaultCenter] removeObserver:self - name:@"AppleInterfaceThemeChangedNotification" - object:nil]; -} - -- (void)showNetworks { - if(self.statusItem.button != nil) { - NSStatusBarButton *button = self.statusItem.button; - [self.networkListPopover showRelativeToRect:button.bounds - ofView:button - preferredEdge:NSMinYEdge]; - - if(self.transientMonitor == nil) { - self.transientMonitor = - [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) - handler:^(NSEvent * _Nonnull e) { - [NSEvent removeMonitor:self.transientMonitor]; - self.transientMonitor = nil; - [self.networkListPopover close]; - }]; - } - } -} - -- (void)joinNetwork { - if(self.statusItem.button != nil) { - NSStatusBarButton *button = self.statusItem.button; - [self.joinNetworkPopover showRelativeToRect:button.bounds - ofView:button - preferredEdge:NSMinYEdge]; - if(self.transientMonitor == nil) { - self.transientMonitor = - [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) - handler:^(NSEvent * _Nonnull e) { - [NSEvent removeMonitor:self.transientMonitor]; - self.transientMonitor = nil; - [self.joinNetworkPopover close]; - }]; - } - } -} - -- (void)showPreferences { - if(self.statusItem.button != nil) { - NSStatusBarButton *button = self.statusItem.button; - [self.preferencesPopover showRelativeToRect:button.bounds - ofView:button - preferredEdge:NSMinYEdge]; - if(self.transientMonitor == nil) { - [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) - handler:^(NSEvent * _Nonnull e) { - [NSEvent removeMonitor:self.transientMonitor]; - self.transientMonitor = nil; - [self.preferencesPopover close]; - }]; - } - } -} - -- (void)showAbout { - if(self.statusItem.button != nil) { - NSStatusBarButton *button = self.statusItem.button; - [self.aboutPopover showRelativeToRect:button.bounds - ofView:button - preferredEdge:NSMinYEdge]; - if(self.transientMonitor == nil) { - [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) - handler:^(NSEvent * _Nonnull e) { - [NSEvent removeMonitor:self.transientMonitor]; - self.transientMonitor = nil; - [self.aboutPopover close]; - }]; - } - } - -} - -- (void)quit { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; -} - -- (void)onNetworkListUpdated:(NSNotification*)note { - NSArray *netList = [note.userInfo objectForKey:@"networks"]; - [(ShowNetworksViewController*)self.networkListPopover.contentViewController setNetworks:netList]; - self.networks = [netList mutableCopy]; - - [self buildMenu]; -} - -- (void)onNodeStatusUpdated:(NSNotification*)note { - NodeStatus *status = [note.userInfo objectForKey:@"status"]; - self.status = status; - - [self buildMenu]; -} - -- (void)buildMenu { - NSMenu *menu = [[NSMenu alloc] init]; - - if(self.status != nil) { - NSString *nodeId = @"Node ID: "; - nodeId = [nodeId stringByAppendingString:self.status.address]; - [menu addItem:[[NSMenuItem alloc] initWithTitle:nodeId - action:@selector(copyNodeID) - keyEquivalent:@""]]; - [menu addItem:[NSMenuItem separatorItem]]; - } - - [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Network Details..." - action:@selector(showNetworks) - keyEquivalent:@"n"]]; - [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Join Network..." - action:@selector(joinNetwork) - keyEquivalent:@"j"]]; - - [menu addItem:[NSMenuItem separatorItem]]; - - if([self.networks count] > 0) { - for(Network *net in self.networks) { - NSString *nwid = [NSString stringWithFormat:@"%10llx", net.nwid]; - NSString *networkName = @""; - if([net.name lengthOfBytesUsingEncoding:NSUTF8StringEncoding] == 0) { - networkName = nwid; - } - else { - networkName = [NSString stringWithFormat:@"%@ (%@)", nwid, net.name]; - } - - if(net.allowDefault && net.connected) { - networkName = [networkName stringByAppendingString:@" [default]"]; - } - - NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:networkName - action:@selector(toggleNetwork:) - keyEquivalent:@""]; - if(net.connected) { - item.state = NSOnState; - } - else { - item.state = NSOffState; - } - - item.representedObject = net; - - [menu addItem:item]; - } - - [menu addItem:[NSMenuItem separatorItem]]; - } - - [menu addItem:[[NSMenuItem alloc] initWithTitle:@"About ZeroTier One..." - action:@selector(showAbout) - keyEquivalent:@""]]; - [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Preferences..." - action:@selector(showPreferences) - keyEquivalent:@""]]; - - [menu addItem:[NSMenuItem separatorItem]]; - - [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Quit" - action:@selector(quit) - keyEquivalent:@"q"]]; - - self.statusItem.menu = menu; -} - -- (void)toggleNetwork:(NSMenuItem*)sender { - Network *network = sender.representedObject; - NSString *nwid = [NSString stringWithFormat:@"%10llx", network.nwid]; - - if(network.connected) { - NSError *error = nil; - - [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; - - if (error) { - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Ok"]; - - [alert runModal]; - } - } - else { - NSError *error = nil; - [[ServiceCom sharedInstance] joinNetwork:nwid - allowManaged:network.allowManaged - allowGlobal:network.allowGlobal - allowDefault:(network.allowDefault && ![Network defaultRouteExists:self.networks]) - error:&error]; - - if (error) { - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Ok"]; - - [alert runModal]; - } - } -} - -- (void)copyNodeID { - if(self.status != nil) { - NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; - [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; - [pasteboard setString:self.status.address forType:NSPasteboardTypeString]; - } -} - -- (void)darkModeChanged:(NSNotification*)note { - NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; - - if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; - } - else { - self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; - } -} - -- (void)closeJoinNetworkPopover { - if (self.transientMonitor) { - [NSEvent removeMonitor:self.transientMonitor]; - self.transientMonitor = nil; - } - [self.joinNetworkPopover close]; -} - -@end diff --git a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 24c81d35..00000000 --- a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "size" : "16x16", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "16x16", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "32x32", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "32x32", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "128x128", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "128x128", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "2x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "ZeroTierIcon512x512.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "512x512", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png b/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png deleted file mode 100644 index d225c2e3..00000000 Binary files a/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/Contents.json b/ZeroTier One/Assets.xcassets/Contents.json deleted file mode 100644 index da4a164c..00000000 --- a/ZeroTier One/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json deleted file mode 100644 index a680b58b..00000000 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "filename" : "Menubar.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "filename" : "MenuBar@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" - } -} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png deleted file mode 100644 index 9fd3d3de..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png b/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png deleted file mode 100644 index ee0d7e3f..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json deleted file mode 100644 index 61737760..00000000 --- a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "filename" : "MenubarWhite.png", - "scale" : "1x" - }, - { - "idiom" : "mac", - "filename" : "MenubarWhite@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - }, - "properties" : { - "template-rendering-intent" : "template" - } -} \ No newline at end of file diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png deleted file mode 100644 index 7049ae55..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png and /dev/null differ diff --git a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png b/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png deleted file mode 100644 index 8c20e36f..00000000 Binary files a/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png and /dev/null differ diff --git a/ZeroTier One/AuthtokenCopy.h b/ZeroTier One/AuthtokenCopy.h deleted file mode 100644 index f0497cc6..00000000 --- a/ZeroTier One/AuthtokenCopy.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef AuthtokenCopy_h -#define AuthtokenCopy_h - -#import - -NSString* getAdminAuthToken(AuthorizationRef authRef); - -#endif /* AuthtokenCopy_h */ diff --git a/ZeroTier One/AuthtokenCopy.m b/ZeroTier One/AuthtokenCopy.m deleted file mode 100644 index a10350f7..00000000 --- a/ZeroTier One/AuthtokenCopy.m +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -#import "AuthtokenCopy.h" - - -NSString* getAdminAuthToken(AuthorizationRef authRef) { - char *tool = "/bin/cat"; - char *args[] = { "/Library/Application Support/ZeroTier/One/authtoken.secret", NULL}; - FILE *pipe = nil; - char token[25]; - memset(token, 0, sizeof(char)*25); - - - OSStatus status = AuthorizationExecuteWithPrivileges(authRef, tool, kAuthorizationFlagDefaults, args, &pipe); - - if (status != errAuthorizationSuccess) { - NSLog(@"Reading authtoken failed!"); - - - switch(status) { - case errAuthorizationDenied: - NSLog(@"Autorization Denied"); - break; - case errAuthorizationCanceled: - NSLog(@"Authorization Canceled"); - break; - case errAuthorizationInternal: - NSLog(@"Authorization Internal"); - break; - case errAuthorizationBadAddress: - NSLog(@"Bad Address"); - break; - case errAuthorizationInvalidRef: - NSLog(@"Invalid Ref"); - break; - case errAuthorizationInvalidSet: - NSLog(@"Invalid Set"); - break; - case errAuthorizationInvalidTag: - NSLog(@"Invalid Tag"); - break; - case errAuthorizationInvalidFlags: - NSLog(@"Invalid Flags"); - break; - case errAuthorizationInvalidPointer: - NSLog(@"Invalid Pointer"); - break; - case errAuthorizationToolExecuteFailure: - NSLog(@"Tool Execute Failure"); - break; - case errAuthorizationToolEnvironmentError: - NSLog(@"Tool Environment Failure"); - break; - case errAuthorizationExternalizeNotAllowed: - NSLog(@"Externalize Not Allowed"); - break; - case errAuthorizationInteractionNotAllowed: - NSLog(@"Interaction Not Allowed"); - break; - case errAuthorizationInternalizeNotAllowed: - NSLog(@"Internalize Not Allowed"); - break; - default: - NSLog(@"Unknown Error"); - break; - } - - return @""; - } - - if(pipe != nil) { - fread(&token, sizeof(char), 24, pipe); - fclose(pipe); - - return [NSString stringWithUTF8String:token]; - } - - return @""; -} diff --git a/ZeroTier One/Base.lproj/MainMenu.xib b/ZeroTier One/Base.lproj/MainMenu.xib deleted file mode 100644 index 6b6da2a6..00000000 --- a/ZeroTier One/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,680 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One/Info.plist b/ZeroTier One/Info.plist deleted file mode 100644 index e04b5f28..00000000 --- a/ZeroTier One/Info.plist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - ZeroTierIcon.icns - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 15 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - LSUIElement - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSHumanReadableCopyright - Copyright © 2016 ZeroTier, Inc. All rights reserved. - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/ZeroTier One/JoinNetworkViewController.h b/ZeroTier One/JoinNetworkViewController.h deleted file mode 100644 index 428959fb..00000000 --- a/ZeroTier One/JoinNetworkViewController.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - - -extern NSString * const JoinedNetworksKey; - -@class AppDelegate; - -@interface JoinNetworkViewController : NSViewController - -@property (nonatomic, weak) IBOutlet NSComboBox *network; -@property (nonatomic, weak) IBOutlet NSButton *joinButton; -@property (nonatomic, weak) IBOutlet NSButton *allowManagedCheckBox; -@property (nonatomic, weak) IBOutlet NSButton *allowGlobalCheckBox; -@property (nonatomic, weak) IBOutlet NSButton *allowDefaultCheckBox; -@property (nonatomic, weak) IBOutlet AppDelegate *appDelegate; - -@property (nonatomic) NSMutableArray *values; - -- (IBAction)onJoinClicked:(id)sender; - - -@end diff --git a/ZeroTier One/JoinNetworkViewController.m b/ZeroTier One/JoinNetworkViewController.m deleted file mode 100644 index cae26541..00000000 --- a/ZeroTier One/JoinNetworkViewController.m +++ /dev/null @@ -1,184 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "JoinNetworkViewController.h" -#import "ServiceCom.h" -#import "AppDelegate.h" - - -NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; - -@interface NSString (extra) - -- (BOOL)contains:(NSString*)find; - -@end - -@implementation NSString (extra) - -- (BOOL)contains:(NSString*)find { - NSRange range = [self rangeOfString:find]; - return range.location != NSNotFound; -} - -@end - - -@implementation JoinNetworkViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do view setup here. - [self.network setDelegate:self]; - [self.network setDataSource:self]; -} - -- (void)viewWillAppear { - [super viewWillAppear]; - - self.allowManagedCheckBox.state = NSOnState; - self.allowGlobalCheckBox.state = NSOffState; - self.allowDefaultCheckBox.state = NSOffState; - - self.network.stringValue = @""; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - NSMutableArray *vals = [[defaults stringArrayForKey:JoinedNetworksKey] mutableCopy]; - - if(vals) { - self.values = vals; - } -} - -- (void)viewWillDisappear { - [super viewWillDisappear]; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - [defaults setObject:self.values forKey:JoinedNetworksKey]; -} - -- (IBAction)onJoinClicked:(id)sender { - NSString *networkId = self.network.stringValue; - - NSError *error = nil; - [[ServiceCom sharedInstance] joinNetwork:networkId - allowManaged:(self.allowManagedCheckBox.state == NSOnState) - allowGlobal:(self.allowGlobalCheckBox.state == NSOnState) - allowDefault:(self.allowDefaultCheckBox.state == NSOnState) - error:&error]; - - if(error) { - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Ok"]; - - [alert runModal]; - return; - } - - self.network.stringValue = @""; - - if(![self.values containsObject:networkId]) { - [self.values insertObject:networkId atIndex:0]; - - while([self.values count] > 20) { - [self.values removeLastObject]; - } - } - - [self.appDelegate closeJoinNetworkPopover]; -} - -// NSComboBoxDelegate methods - -- (void)controlTextDidChange:(NSNotification *)obj { - NSComboBox *cb = (NSComboBox*)obj.object; - NSString *value = cb.stringValue; - - NSString *allowedCharacters = @"abcdefABCDEF0123456789"; - - NSString *outValue = @""; - - for(int i = 0; i < [value length]; ++i) { - if(![allowedCharacters contains:[NSString stringWithFormat:@"%C", [value characterAtIndex:i]]]) { - NSBeep(); - } - else { - outValue = [outValue stringByAppendingString:[NSString stringWithFormat:@"%C", [value characterAtIndex:i]]]; - } - } - - if([outValue lengthOfBytesUsingEncoding:NSUTF8StringEncoding] == 16) { - self.joinButton.enabled = YES; - } - else { - if([outValue lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 16) { - NSRange range = {0, 16}; - range = [outValue rangeOfComposedCharacterSequencesForRange:range]; - outValue = [outValue substringWithRange:range]; - NSBeep(); - self.joinButton.enabled = YES; - } - else { - self.joinButton.enabled = NO; - } - } - - cb.stringValue = outValue; -} - -// end NSComboBoxDelegate methods - -// NSComboBoxDataSource methods - -- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox { - return [self.values count]; -} - -- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index { - return [self.values objectAtIndex:index]; -} - -- (NSUInteger)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)string { - NSUInteger counter = 0; - - for(NSString *val in self.values) { - if([val isEqualToString:string]) { - return counter; - } - - counter += 1; - } - - return NSNotFound; -} - -- (NSString*)comboBox:(NSComboBox *)aComboBox completedString:(NSString *)string { - for(NSString *val in self.values) { - if([val hasPrefix:string]) { - return val; - } - } - return nil; -} - -// end NSComboBoxDataSource methods - -@end diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib deleted file mode 100644 index 2ef43442..00000000 --- a/ZeroTier One/JoinNetworkViewController.xib +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One/Network.h b/ZeroTier One/Network.h deleted file mode 100644 index 0f3c4964..00000000 --- a/ZeroTier One/Network.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -enum NetworkStatus { - REQUESTING_CONFIGURATION, - OK, - ACCESS_DENIED, - NOT_FOUND, - PORT_ERROR, - CLIENT_TOO_OLD, -}; - -enum NetworkType { - PUBLIC, - PRIVATE, -}; - -@interface Network : NSObject - -@property (readonly) NSArray *assignedAddresses; -@property (readonly) BOOL bridge; -@property (readonly) BOOL broadcastEnabled; -@property (readonly) BOOL dhcp; -@property (readonly) NSString *mac; -@property (readonly) int mtu; -@property (readonly) int netconfRevision; -@property (readonly) NSString *name; -@property (readonly) UInt64 nwid; -@property (readonly) NSString *portDeviceName; -@property (readonly) int portError; -@property (readonly) enum NetworkStatus status; -@property (readonly) enum NetworkType type; -@property (readonly) BOOL allowManaged; -@property (readonly) BOOL allowGlobal; -@property (readonly) BOOL allowDefault; -@property (readonly) BOOL connected; // not persisted. set to YES if loaded via json - -- (id)initWithJsonData:(NSDictionary*)jsonData; -- (id)initWithCoder:(NSCoder *)aDecoder; -- (void)encodeWithCoder:(NSCoder *)aCoder; -+ (BOOL)defaultRouteExists:(NSArray*)netList; -- (NSString*)statusString; -- (NSString*)typeString; - -@end diff --git a/ZeroTier One/Network.m b/ZeroTier One/Network.m deleted file mode 100644 index 16efc6e3..00000000 --- a/ZeroTier One/Network.m +++ /dev/null @@ -1,278 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "Network.h" - -NSString *NetworkAddressesKey = @"addresses"; -NSString *NetworkBridgeKey = @"bridge"; -NSString *NetworkBroadcastKey = @"broadcast"; -NSString *NetworkDhcpKey = @"dhcp"; -NSString *NetworkMacKey = @"mac"; -NSString *NetworkMtuKey = @"mtu"; -NSString *NetworkMulticastKey = @"multicast"; -NSString *NetworkNameKey = @"name"; -NSString *NetworkNetconfKey = @"netconf"; -NSString *NetworkNwidKey = @"nwid"; -NSString *NetworkPortNameKey = @"port"; -NSString *NetworkPortErrorKey = @"portError"; -NSString *NetworkStatusKey = @"status"; -NSString *NetworkTypeKey = @"type"; -NSString *NetworkAllowManagedKey = @"allowManaged"; -NSString *NetworkAllowGlobalKey = @"allowGlobal"; -NSString *NetworkAllowDefaultKey = @"allowDefault"; - -@implementation Network - -- (id)initWithJsonData:(NSDictionary*)jsonData -{ - self = [super init]; - - if(self) { - if([jsonData objectForKey:@"assignedAddresses"]) { - _assignedAddresses = (NSArray*)[jsonData objectForKey:@"assignedAddresses"]; - } - - if([jsonData objectForKey:@"bridge"]) { - _bridge = [(NSNumber*)[jsonData objectForKey:@"bridge"] boolValue]; - } - - if([jsonData objectForKey:@"broadcastEnabled"]) { - _broadcastEnabled = [(NSNumber*)[jsonData objectForKey:@"broadcastEnabled"] boolValue]; - } - - if([jsonData objectForKey:@"dhcp"]) { - _dhcp = [(NSNumber*)[jsonData objectForKey:@"dhcp"] boolValue]; - } - - if([jsonData objectForKey:@"mac"]) { - _mac = (NSString*)[jsonData objectForKey:@"mac"]; - } - - if([jsonData objectForKey:@"mtu"]) { - _mtu = [(NSNumber*)[jsonData objectForKey:@"mtu"] intValue]; - } - - if([jsonData objectForKey:@"name"]) { - _name = (NSString*)[jsonData objectForKey:@"name"]; - } - - if([jsonData objectForKey:@"netconfRevision"]) { - _netconfRevision = [(NSNumber*)[jsonData objectForKey:@"netconfRevision"] intValue]; - } - - if([jsonData objectForKey:@"nwid"]) { - NSString *networkid = (NSString*)[jsonData objectForKey:@"nwid"]; - - NSScanner *scanner = [NSScanner scannerWithString:networkid]; - [scanner scanHexLongLong:&_nwid]; - } - - if([jsonData objectForKey:@"portDeviceName"]) { - _portDeviceName = (NSString*)[jsonData objectForKey:@"portDeviceName"]; - } - - if([jsonData objectForKey:@"portError"]) { - _portError = [(NSNumber*)[jsonData objectForKey:@"portError"] intValue]; - } - - if([jsonData objectForKey:@"allowManaged"]) { - _allowManaged = [(NSNumber*)[jsonData objectForKey:@"allowManaged"] boolValue]; - } - - if([jsonData objectForKey:@"allowGlobal"]) { - _allowGlobal = [(NSNumber*)[jsonData objectForKey:@"allowGlobal"] boolValue]; - } - - if([jsonData objectForKey:@"allowDefault"]) { - _allowDefault = [(NSNumber*)[jsonData objectForKey:@"allowDefault"] boolValue]; - } - - if([jsonData objectForKey:@"status"]) { - NSString *statusStr = (NSString*)[jsonData objectForKey:@"status"]; - if([statusStr isEqualToString:@"REQUESTING_CONFIGURATION"]) { - _status = REQUESTING_CONFIGURATION; - } - else if([statusStr isEqualToString:@"OK"]) { - _status = OK; - } - else if([statusStr isEqualToString:@"ACCESS_DENIED"]) { - _status = ACCESS_DENIED; - } - else if([statusStr isEqualToString:@"NOT_FOUND"]) { - _status = NOT_FOUND; - } - else if([statusStr isEqualToString:@"PORT_ERROR"]) { - _status = PORT_ERROR; - } - else if([statusStr isEqualToString:@"CLIENT_TOO_OLD"]) { - _status = CLIENT_TOO_OLD; - } - } - - if([jsonData objectForKey:@"type"]) { - NSString *typeStr = (NSString*)[jsonData objectForKey:@"type"]; - if([typeStr isEqualToString:@"PRIVATE"]) { - _type = PRIVATE; - } - else if([typeStr isEqualToString:@"PUBLIC"]) { - _type = PUBLIC; - } - } - - _connected = YES; - } - - return self; -} -- (id)initWithCoder:(NSCoder *)aDecoder -{ - self = [super init]; - - if(self) { - if([aDecoder containsValueForKey:NetworkAddressesKey]) { - _assignedAddresses = (NSArray*)[aDecoder decodeObjectForKey:NetworkAddressesKey]; - } - - if([aDecoder containsValueForKey:NetworkBridgeKey]) { - _bridge = [aDecoder decodeBoolForKey:NetworkBridgeKey]; - } - - if([aDecoder containsValueForKey:NetworkBroadcastKey]) { - _broadcastEnabled = [aDecoder decodeBoolForKey:NetworkBroadcastKey]; - } - - if([aDecoder containsValueForKey:NetworkDhcpKey]) { - _dhcp = [aDecoder decodeBoolForKey:NetworkDhcpKey]; - } - - if([aDecoder containsValueForKey:NetworkMacKey]) { - _mac = (NSString*)[aDecoder decodeObjectForKey:NetworkMacKey]; - } - - if([aDecoder containsValueForKey:NetworkMtuKey]) { - _mtu = (int)[aDecoder decodeIntegerForKey:NetworkMtuKey]; - } - - if([aDecoder containsValueForKey:NetworkNameKey]) { - _name = (NSString*)[aDecoder decodeObjectForKey:NetworkNameKey]; - } - - if([aDecoder containsValueForKey:NetworkNetconfKey]) { - _netconfRevision = (int)[aDecoder decodeIntegerForKey:NetworkNetconfKey]; - } - - if([aDecoder containsValueForKey:NetworkNwidKey]) { - _nwid = [(NSNumber*)[aDecoder decodeObjectForKey:NetworkNwidKey] unsignedLongLongValue]; - } - - if([aDecoder containsValueForKey:NetworkPortNameKey]) { - _portDeviceName = (NSString*)[aDecoder decodeObjectForKey:NetworkPortNameKey]; - } - - if([aDecoder containsValueForKey:NetworkPortErrorKey]) { - _portError = (int)[aDecoder decodeIntegerForKey:NetworkPortErrorKey]; - } - - if([aDecoder containsValueForKey:NetworkStatusKey]) { - _status = (enum NetworkStatus)[aDecoder decodeIntegerForKey:NetworkStatusKey]; - } - - if([aDecoder containsValueForKey:NetworkTypeKey]) { - _type = (enum NetworkType)[aDecoder decodeIntegerForKey:NetworkTypeKey]; - } - - if([aDecoder containsValueForKey:NetworkAllowManagedKey]) { - _allowManaged = [aDecoder decodeBoolForKey:NetworkAllowManagedKey]; - } - - if([aDecoder containsValueForKey:NetworkAllowGlobalKey]) { - _allowGlobal = [aDecoder decodeBoolForKey:NetworkAllowGlobalKey]; - } - - if([aDecoder containsValueForKey:NetworkAllowDefaultKey]) { - _allowDefault = [aDecoder decodeBoolForKey:NetworkAllowDefaultKey]; - } - - _connected = NO; - } - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)aCoder -{ - [aCoder encodeObject:_assignedAddresses forKey:NetworkAddressesKey]; - [aCoder encodeBool:_bridge forKey:NetworkBridgeKey]; - [aCoder encodeBool:_broadcastEnabled forKey:NetworkBroadcastKey]; - [aCoder encodeBool:_dhcp forKey:NetworkDhcpKey]; - [aCoder encodeObject:_mac forKey:NetworkMacKey]; - [aCoder encodeInteger:_mtu forKey:NetworkMtuKey]; - [aCoder encodeObject:_name forKey:NetworkNameKey]; - [aCoder encodeInteger:_netconfRevision forKey:NetworkNetconfKey]; - [aCoder encodeObject:[NSNumber numberWithUnsignedLongLong:_nwid] - forKey:NetworkNwidKey]; - [aCoder encodeObject:_portDeviceName forKey:NetworkPortNameKey]; - [aCoder encodeInteger:_portError forKey:NetworkPortErrorKey]; - [aCoder encodeInteger:_status forKey:NetworkStatusKey]; - [aCoder encodeInteger:_type forKey:NetworkTypeKey]; - [aCoder encodeBool:_allowManaged forKey:NetworkAllowManagedKey]; - [aCoder encodeBool:_allowGlobal forKey:NetworkAllowGlobalKey]; - [aCoder encodeBool:_allowDefault forKey:NetworkAllowDefaultKey]; -} - -+ (BOOL)defaultRouteExists:(NSArray*)netList -{ - for(Network *net in netList) { - if (net.allowDefault && net.connected) { - return YES; - } - } - return NO; -} - -- (NSString*)statusString { - switch(_status) { - case REQUESTING_CONFIGURATION: - return @"REQUESTING_CONFIGURATION"; - case OK: - return @"OK"; - case ACCESS_DENIED: - return @"ACCESS_DENIED"; - case NOT_FOUND: - return @"NOT_FOUND"; - case PORT_ERROR: - return @"PORT_ERROR"; - case CLIENT_TOO_OLD: - return @"CLIENT_TOO_OLD"; - default: - return @""; - } -} - -- (NSString*)typeString { - switch(_type) { - case PUBLIC: - return @"PUBLIC"; - case PRIVATE: - return @"PRIVATE"; - default: - return @""; - } -} - -@end diff --git a/ZeroTier One/NetworkInfoCell.h b/ZeroTier One/NetworkInfoCell.h deleted file mode 100644 index be9345d7..00000000 --- a/ZeroTier One/NetworkInfoCell.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@class ShowNetworksViewController; - -@interface NetworkInfoCell : NSTableCellView - -@property (weak, nonatomic) ShowNetworksViewController *parent; - -@property (weak, nonatomic) IBOutlet NSTextField *networkIdField; -@property (weak, nonatomic) IBOutlet NSTextField *networkNameField; -@property (weak, nonatomic) IBOutlet NSTextField *statusField; -@property (weak, nonatomic) IBOutlet NSTextField *typeField; -@property (weak, nonatomic) IBOutlet NSTextField *macField; -@property (weak, nonatomic) IBOutlet NSTextField *mtuField; -@property (weak, nonatomic) IBOutlet NSTextField *broadcastField; -@property (weak, nonatomic) IBOutlet NSTextField *bridgingField; -@property (weak, nonatomic) IBOutlet NSTextField *deviceField; -@property (weak, nonatomic) IBOutlet NSTextField *addressesField; -@property (weak, nonatomic) IBOutlet NSButton *allowManaged; -@property (weak, nonatomic) IBOutlet NSButton *allowGlobal; -@property (weak, nonatomic) IBOutlet NSButton *allowDefault; -@property (weak, nonatomic) IBOutlet NSButton *connectedCheckbox; -@property (weak, nonatomic) IBOutlet NSButton *deleteButton; - -- (IBAction)onConnectCheckStateChanged:(NSButton*)sender; -- (IBAction)deleteNetwork:(NSButton*)sender; -- (IBAction)onAllowStatusChanged:(NSButton*)sender; - -- (void)joinNetwork:(NSString*)nwid; -- (void)leaveNetwork:(NSString*)nwid; - -@end diff --git a/ZeroTier One/NetworkInfoCell.m b/ZeroTier One/NetworkInfoCell.m deleted file mode 100644 index dc75cab3..00000000 --- a/ZeroTier One/NetworkInfoCell.m +++ /dev/null @@ -1,85 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "NetworkInfoCell.h" -#import "ServiceCom.h" -#import "ShowNetworksViewController.h" -#import "Network.h" - -@implementation NetworkInfoCell - -- (void)drawRect:(NSRect)dirtyRect { - [super drawRect:dirtyRect]; - - // Drawing code here. -} - -- (IBAction)onConnectCheckStateChanged:(NSButton*)sender -{ - if(sender.state == NSOnState) { - [self joinNetwork:self.networkIdField.stringValue]; - } - else { - [self leaveNetwork:self.networkIdField.stringValue]; - } -} - -- (IBAction)deleteNetwork:(NSButton*)sender; -{ - [self leaveNetwork:self.networkIdField.stringValue]; - [self.parent deleteNetworkFromList:self.networkIdField.stringValue]; -} - -- (IBAction)onAllowStatusChanged:(NSButton*)sender -{ - [self joinNetwork:self.networkIdField.stringValue]; -} - -- (void)joinNetwork:(NSString*)nwid -{ - NSError *error = nil; - [[ServiceCom sharedInstance] joinNetwork:nwid - allowManaged:(self.allowManaged.state == NSOnState) - allowGlobal:(self.allowGlobal.state == NSOnState) - allowDefault:![Network defaultRouteExists:_parent.networkList] && (self.allowDefault.state == NSOnState) - error:&error]; - - if (error) { - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Ok"]; - - [alert runModal]; - } -} - -- (void)leaveNetwork:(NSString*)nwid -{ - NSError *error = nil; - [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; - - if (error) { - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Ok"]; - - [alert runModal]; - } -} - -@end diff --git a/ZeroTier One/NetworkMonitor.h b/ZeroTier One/NetworkMonitor.h deleted file mode 100644 index 8cdec4ed..00000000 --- a/ZeroTier One/NetworkMonitor.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -extern NSString * const NetworkUpdateKey; -extern NSString * const StatusUpdateKey; - -@class Network; - -@interface NetworkMonitor : NSObject -{ - NSMutableArray *_savedNetworks; - NSArray *_receivedNetworks; - NSMutableArray *_allNetworks; - - NSTimer *_timer; -} - -- (id)init; -- (void)dealloc; - -- (void)start; -- (void)stop; - -- (void)updateNetworkInfo; - -- (void)deleteSavedNetwork:(NSString*)networkId; - -@end diff --git a/ZeroTier One/NetworkMonitor.m b/ZeroTier One/NetworkMonitor.m deleted file mode 100644 index 7ed22c4a..00000000 --- a/ZeroTier One/NetworkMonitor.m +++ /dev/null @@ -1,253 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "NetworkMonitor.h" -#import "Network.h" -#import "ServiceCom.h" -#import "NodeStatus.h" - -@import AppKit; - - -NSString * const NetworkUpdateKey = @"com.zerotier.one.network-list"; -NSString * const StatusUpdateKey = @"com.zerotier.one.status"; - -@interface NetworkMonitor (private) - -- (NSString*)dataFile; -- (void)internal_updateNetworkInfo; -- (NSInteger)findNetworkWithID:(UInt64)networkId; -- (NSInteger)findSavedNetworkWithID:(UInt64)networkId; -- (void)saveNetworks; - -@end - -@implementation NetworkMonitor - -- (id)init -{ - self = [super init]; - if(self) - { - _savedNetworks = [NSMutableArray array]; - _receivedNetworks = [NSArray array]; - _allNetworks = [NSMutableArray array]; - _timer = nil; - } - - return self; -} - -- (void)dealloc -{ - [_timer invalidate]; -} - -- (void)start -{ - NSLog(@"ZeroTier monitor started"); - _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f - target:self - selector:@selector(updateNetworkInfo) - userInfo:nil - repeats:YES]; -} - -- (void)stop -{ - NSLog(@"ZeroTier monitor stopped"); - [_timer invalidate]; - _timer = nil; -} - -- (void)updateNetworkInfo -{ - NSString *filePath = [self dataFile]; - - if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { - NSArray *networks = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; - - if(networks != nil) { - _savedNetworks = [networks mutableCopy]; - } - } - - NSError *error = nil; - - [[ServiceCom sharedInstance] getNetworklist:^(NSArray *networkList) { - _receivedNetworks = networkList; - - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - [self internal_updateNetworkInfo]; - } ]; - } error:&error]; - - if(error) { - [self stop]; - - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res = [alert runModal]; - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - } - else if(res == NSAlertSecondButtonReturn) { - [self start]; - return; - } - } - - [[ServiceCom sharedInstance] getNodeStatus:^(NodeStatus *status) { - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:status forKey:@"status"]; - - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - [[NSNotificationCenter defaultCenter] postNotificationName:StatusUpdateKey - object:nil - userInfo:userInfo]; - }]; - } error:&error]; - - if (error) { - [self stop]; - - NSAlert *alert = [NSAlert alertWithError:error]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res = [alert runModal]; - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - } - else if(res == NSAlertSecondButtonReturn) { - [self start]; - return; - } - } -} - -- (void)deleteSavedNetwork:(NSString*)networkId -{ - UInt64 nwid = 0; - NSScanner *scanner = [NSScanner scannerWithString:networkId]; - [scanner scanHexLongLong:&nwid]; - - NSInteger index = [self findNetworkWithID:nwid]; - - if(index != NSNotFound) { - [_allNetworks removeObjectAtIndex:index]; - } - - index = [self findSavedNetworkWithID:nwid]; - - if(index != NSNotFound) { - [_savedNetworks removeObjectAtIndex:index]; - } - - [self saveNetworks]; -} - -@end - -@implementation NetworkMonitor (private) -- (NSString*)dataFile -{ - NSURL *appSupport = [[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory - inDomains:NSUserDomainMask] objectAtIndex:0]; - - appSupport = [[[appSupport URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"] URLByAppendingPathComponent:@"networkinfo.dat"]; - return appSupport.path; -} - -- (void)internal_updateNetworkInfo -{ - NSMutableArray *networks = [_savedNetworks mutableCopy]; - - for(Network *nw in _receivedNetworks) { - NSInteger index = [self findSavedNetworkWithID:nw.nwid]; - - if(index != NSNotFound) { - [networks setObject:nw atIndexedSubscript:index]; - } - else { - [networks addObject:nw]; - } - } - - [networks sortUsingComparator:^NSComparisonResult(Network *obj1, Network *obj2) { - if(obj1.nwid > obj2.nwid) { - return true; - } - return false; - }]; - - @synchronized(_allNetworks) { - _allNetworks = networks; - } - - [self saveNetworks]; - - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:networks forKey:@"networks"]; - - [[NSNotificationCenter defaultCenter] postNotificationName:NetworkUpdateKey - object:nil - userInfo:userInfo]; -} - -- (NSInteger)findNetworkWithID:(UInt64)networkId -{ - for(int i = 0; i < [_allNetworks count]; ++i) { - Network *nw = [_allNetworks objectAtIndex:i]; - - if(nw.nwid == networkId) { - return i; - } - } - - return NSNotFound; -} - - -- (NSInteger)findSavedNetworkWithID:(UInt64)networkId -{ - for(int i = 0; i < [_savedNetworks count]; ++i) { - Network *nw = [_savedNetworks objectAtIndex:i]; - - if(nw.nwid == networkId) { - return i; - } - } - - return NSNotFound; -} - -- (void)saveNetworks -{ - NSString *filePath = [self dataFile]; - - @synchronized(_allNetworks) { - [NSKeyedArchiver archiveRootObject:_allNetworks toFile:filePath]; - } -} - -@end diff --git a/ZeroTier One/NodeStatus.h b/ZeroTier One/NodeStatus.h deleted file mode 100644 index eab5bfe4..00000000 --- a/ZeroTier One/NodeStatus.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@interface NodeStatus : NSObject - -@property (readonly) NSString *address; -@property (readonly) NSString *publicIdentity; -@property (readonly) BOOL online; -@property (readonly) BOOL tcpFallbackActive; -@property (readonly) int versionMajor; -@property (readonly) int versionMinor; -@property (readonly) int versionRev; -@property (readonly) NSString *version; -@property (readonly) UInt64 clock; - -- (id)initWithJsonData:(NSDictionary*)jsonData; - -@end diff --git a/ZeroTier One/NodeStatus.m b/ZeroTier One/NodeStatus.m deleted file mode 100644 index 3bae3c7d..00000000 --- a/ZeroTier One/NodeStatus.m +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#import "NodeStatus.h" - -@implementation NodeStatus - -- (id)initWithJsonData:(NSDictionary*)jsonData -{ - self = [super init]; - - if(self) { - _address = (NSString*)[jsonData objectForKey:@"address"]; - _publicIdentity = (NSString*)[jsonData objectForKey:@"publicIdentity"]; - _online = [(NSNumber*)[jsonData objectForKey:@"online"] boolValue]; - _tcpFallbackActive = [(NSNumber*)[jsonData objectForKey:@"tcpFallbackActive"] boolValue]; - _versionMajor = [(NSNumber*)[jsonData objectForKey:@"versionMajor"] intValue]; - _versionMinor = [(NSNumber*)[jsonData objectForKey:@"versionMinor"] intValue]; - _versionRev = [(NSNumber*)[jsonData objectForKey:@"versionRev"] intValue]; - _version = (NSString*)[jsonData objectForKey:@"version"]; - _clock = [(NSNumber*)[jsonData objectForKey:@"clock"] unsignedLongLongValue]; - } - - return self; -} -@end diff --git a/ZeroTier One/PreferencesViewController.h b/ZeroTier One/PreferencesViewController.h deleted file mode 100644 index 56d0fdb8..00000000 --- a/ZeroTier One/PreferencesViewController.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@interface PreferencesViewController : NSViewController - -@property (nonatomic, weak) IBOutlet NSButton *startupCheckBox; - -- (IBAction)onStartupCheckBoxChanged:(NSButton*)sender; - -- (BOOL)isLaunchAtStartup; -- (LSSharedFileListItemRef)itemRefInLoginItems; -- (void)setLaunchAtLoginEnabled:(BOOL)enabled; - -@end diff --git a/ZeroTier One/PreferencesViewController.m b/ZeroTier One/PreferencesViewController.m deleted file mode 100644 index 13927fba..00000000 --- a/ZeroTier One/PreferencesViewController.m +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "PreferencesViewController.h" - -@interface PreferencesViewController () - -@end - -@implementation PreferencesViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - if([self isLaunchAtStartup]) { - self.startupCheckBox.state = NSOnState; - } - else { - self.startupCheckBox.state = NSOffState; - } -} - -- (IBAction)onStartupCheckBoxChanged:(NSButton *)sender -{ - if(sender.state == NSOnState) { - [self setLaunchAtLoginEnabled:YES]; - } - else { - [self setLaunchAtLoginEnabled:NO]; - } - -} - -- (void)setLaunchAtLoginEnabled:(BOOL)enabled -{ - LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); - - if (enabled) { - // Add the app to the LoginItems list. - CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; - LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL); - if (itemRef) CFRelease(itemRef); - } - else { - // Remove the app from the LoginItems list. - LSSharedFileListItemRef itemRef = [self itemRefInLoginItems]; - LSSharedFileListItemRemove(loginItemsRef,itemRef); - if (itemRef != nil) CFRelease(itemRef); - } -} - - -- (BOOL)isLaunchAtStartup { - // See if the app is currently in LoginItems. - LSSharedFileListItemRef itemRef = [self itemRefInLoginItems]; - // Store away that boolean. - BOOL isInList = itemRef != nil; - // Release the reference if it exists. - if (itemRef != nil) CFRelease(itemRef); - - return isInList; -} - -- (LSSharedFileListItemRef)itemRefInLoginItems { - LSSharedFileListItemRef itemRef = nil; - - NSString * appPath = [[NSBundle mainBundle] bundlePath]; - - // This will retrieve the path for the application - // For example, /Applications/test.app - CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:appPath]; - - // Create a reference to the shared file list. - LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); - - if (loginItems) { - UInt32 seedValue; - //Retrieve the list of Login Items and cast them to - // a NSArray so that it will be easier to iterate. - NSArray *loginItemsArray = (__bridge NSArray *)LSSharedFileListCopySnapshot(loginItems, &seedValue); - for(int i = 0; i< [loginItemsArray count]; i++){ - LSSharedFileListItemRef currentItemRef = (__bridge LSSharedFileListItemRef)[loginItemsArray - objectAtIndex:i]; - //Resolve the item with URL - if (LSSharedFileListItemResolve(currentItemRef, 0, (CFURLRef*) &url, NULL) == noErr) { - NSString * urlPath = [(__bridge NSURL*)url path]; - if ([urlPath compare:appPath] == NSOrderedSame){ - itemRef = currentItemRef; - } - } - } - } - CFRelease(loginItems); - return itemRef; -} - -@end diff --git a/ZeroTier One/PreferencesViewController.xib b/ZeroTier One/PreferencesViewController.xib deleted file mode 100644 index 62aef4c0..00000000 --- a/ZeroTier One/PreferencesViewController.xib +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One/ServiceCom.h b/ZeroTier One/ServiceCom.h deleted file mode 100644 index 74ab2b35..00000000 --- a/ZeroTier One/ServiceCom.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@class NodeStatus; -@class Network; - -@interface ServiceCom : NSObject -{ - NSString *baseURL; - NSURLSession *session; - BOOL _isQuitting; -} -+ (ServiceCom*)sharedInstance; - -- (id)init; - -- (void)getNetworklist:(void (^)(NSArray*))completionHandler error:(NSError* __autoreleasing *)error; -- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error; -- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError*__autoreleasing*)error; -- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error; - -@end diff --git a/ZeroTier One/ServiceCom.m b/ZeroTier One/ServiceCom.m deleted file mode 100644 index 4982d40e..00000000 --- a/ZeroTier One/ServiceCom.m +++ /dev/null @@ -1,464 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "ServiceCom.h" -#import "AuthtokenCopy.h" -#import "Network.h" -#import "NodeStatus.h" -@import AppKit; - -@interface ServiceCom (Private) - -- (NSString*)key; - -@end - -@implementation ServiceCom - -+ (ServiceCom*)sharedInstance { - static ServiceCom *sc = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sc = [[ServiceCom alloc] init]; - }); - return sc; -} - -- (id)init -{ - self = [super init]; - if(self) { - baseURL = @"http://localhost:9993"; - session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]]; - _isQuitting = NO; - } - - return self; -} - -- (NSString*)key:(NSError* __autoreleasing *)err -{ - static NSString *k = nil; - - if (k == nil) { - NSError *error = nil; - NSURL *appSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:false error:&error]; - - if (error) { - NSLog(@"Error: %@", error); - return @""; - } - - appSupportDir = [[appSupportDir URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"]; - NSURL *authtokenURL = [appSupportDir URLByAppendingPathComponent:@"authtoken.secret"]; - - if ([[NSFileManager defaultManager] fileExistsAtPath:[authtokenURL path]]) { - k = [NSString stringWithContentsOfURL:authtokenURL - encoding:NSUTF8StringEncoding - error:&error]; - - if (error) { - NSLog(@"Error: %@", error); - k = nil; - *err = error; - return @""; - } - } - else { - NSURL *sysAppSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:false error:nil]; - - sysAppSupportDir = [[sysAppSupportDir URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"]; - NSURL *sysAuthtokenURL = [sysAppSupportDir URLByAppendingPathComponent:@"authtoken.secret"]; - - if(![[NSFileManager defaultManager] fileExistsAtPath:[sysAuthtokenURL path]]) { - - } - - [[NSFileManager defaultManager] createDirectoryAtURL:appSupportDir - withIntermediateDirectories:YES - attributes:nil - error:&error]; - - if (error) { - NSLog(@"Error: %@", error); - *err = error; - k = nil; - return @""; - } - - AuthorizationRef authRef; - OSStatus status = AuthorizationCreate(nil, nil, kAuthorizationFlagDefaults, &authRef); - - if (status != errAuthorizationSuccess) { - NSLog(@"Authorization Failed! %d", status); - - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't create AuthorizationRef", nil), - }; - *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; - - return @""; - } - - AuthorizationItem authItem; - authItem.name = kAuthorizationRightExecute; - authItem.valueLength = 0; - authItem.flags = 0; - - AuthorizationRights authRights; - authRights.count = 1; - authRights.items = &authItem; - - AuthorizationFlags authFlags = kAuthorizationFlagDefaults | - kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagPreAuthorize | - kAuthorizationFlagExtendRights; - - status = AuthorizationCopyRights(authRef, &authRights, nil, authFlags, nil); - - if (status != errAuthorizationSuccess) { - NSLog(@"Authorization Failed! %d", status); - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't copy authorization rights", nil), - }; - *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; - return @""; - } - - NSString *localKey = getAdminAuthToken(authRef); - AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); - - if (localKey != nil && [localKey lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 0) { - k = localKey; - - [localKey writeToURL:authtokenURL - atomically:YES - encoding:NSUTF8StringEncoding - error:&error]; - - if (error) { - NSLog(@"Error writing token to disk: %@", error); - *err = error; - } - } - } - } - - if (k == nil) { - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: NSLocalizedString(@"Unknown error finding authorization key", nil), - }; - *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; - - return @""; - } - - return k; -} - -- (void)getNetworklist:(void (^)(NSArray *))completionHandler error:(NSError *__autoreleasing*)error -{ - NSString* key = [self key:error]; - if(*error) { - return; - } - - NSString *urlString = [[baseURL stringByAppendingString:@"/network?auth="] stringByAppendingString:key]; - - NSURL *url = [NSURL URLWithString:urlString]; - NSURLSessionDataTask *task = - [session dataTaskWithURL:url - completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - - if (err) { - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - _isQuitting = YES; - } - }]; - return; - } - - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; - NSInteger status = [httpResponse statusCode]; - - NSError *err2; - - if (status == 200) { - NSArray *json = [NSJSONSerialization JSONObjectWithData:data - options:0 - error:&err2]; - if (err) { - NSLog(@"Error fetching network list: %@", err2); - - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err2]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - _isQuitting = YES; - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - } - }]; - return; - } - - NSMutableArray *networks = [[NSMutableArray alloc] init]; - for(NSDictionary *dict in json) { - [networks addObject:[[Network alloc] initWithJsonData:dict]]; - } - - completionHandler(networks); - } - }]; - [task resume]; -} - -- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error -{ - NSString *key = [self key:error]; - if(*error) { - return; - } - - NSString *urlString = [[baseURL stringByAppendingString:@"/status?auth="] stringByAppendingString:key]; - - NSURL *url = [NSURL URLWithString:urlString]; - NSURLSessionDataTask *task = - [session dataTaskWithURL:url - completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - - if(err) { - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - _isQuitting = YES; - } - }]; - return; - } - - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; - NSInteger status = [httpResponse statusCode]; - - NSError *err2; - if(status == 200) { - NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data - options:0 - error:&err2]; - - if(err2) { - NSLog(@"Error fetching node status: %@", err2); - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err2]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - _isQuitting = YES; - } - }]; - return; - } - - NodeStatus *status = [[NodeStatus alloc] initWithJsonData:json]; - - completionHandler(status); - } - }]; - [task resume]; -} - -- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError *__autoreleasing*)error -{ - NSString *key = [self key:error]; - if(*error) { - return; - } - - NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] - stringByAppendingString:networkId] - stringByAppendingString:@"?auth="] - stringByAppendingString:key]; - - NSURL *url = [NSURL URLWithString:urlString]; - - NSMutableDictionary *jsonDict = [NSMutableDictionary dictionary]; - [jsonDict setObject:[NSNumber numberWithBool:allowManaged] forKey:@"allowManaged"]; - [jsonDict setObject:[NSNumber numberWithBool:allowGlobal] forKey:@"allowGlobal"]; - [jsonDict setObject:[NSNumber numberWithBool:allowDefault] forKey:@"allowDefault"]; - - NSError *err = nil; - - NSData *json = [NSJSONSerialization dataWithJSONObject:jsonDict - options:0 - error:&err]; - - if(err) { - NSLog(@"Error creating json data: %@", err); - *error = err; - return; - } - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - request.HTTPMethod = @"POST"; - request.HTTPBody = json; - [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - - NSURLSessionDataTask *task = - [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - if(err) { - NSLog(@"Error posting join request: %@", err); - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - _isQuitting = YES; - } - }]; - } - - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; - NSInteger status = [httpResponse statusCode]; - - if(status == 200) { - NSLog(@"join ok"); - } - else { - NSLog(@"join error: %ld", (long)status); - } - }]; - [task resume]; -} - -- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error -{ - NSString *key = [self key:error]; - if(*error) { - return; - } - - NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] - stringByAppendingString:networkId] - stringByAppendingString:@"?auth="] - stringByAppendingString:key]; - - NSURL *url = [NSURL URLWithString:urlString]; - - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - request.HTTPMethod = @"DELETE"; - - NSURLSessionDataTask *task = - [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { - if(err) { - NSLog(@"Error posting delete request: %@", err); - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - NSAlert *alert = [NSAlert alertWithError:err]; - alert.alertStyle = NSCriticalAlertStyle; - [alert addButtonWithTitle:@"Quit"]; - [alert addButtonWithTitle:@"Retry"]; - - NSModalResponse res; - if (!_isQuitting) { - res = [alert runModal]; - } - else { - return; - } - - if(res == NSAlertFirstButtonReturn) { - [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; - _isQuitting = YES; - } - }]; - return; - } - - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; - NSInteger status = httpResponse.statusCode; - - if(status == 200) { - NSLog(@"leave ok"); - } - else { - NSLog(@"leave error: %ld", status); - } - }]; - [task resume]; -} - -@end diff --git a/ZeroTier One/ShowNetworksViewController.h b/ZeroTier One/ShowNetworksViewController.h deleted file mode 100644 index 5c251674..00000000 --- a/ZeroTier One/ShowNetworksViewController.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -@class NetworkMonitor; -@class Network; - -@interface ShowNetworksViewController : NSViewController - -@property (nonatomic) NSArray *networkList; -@property (nonatomic) NetworkMonitor *netMonitor; -@property (nonatomic) BOOL visible; - -@property (weak, nonatomic) IBOutlet NSTableView *tableView; - -- (void)deleteNetworkFromList:(NSString*)nwid; -- (void)setNetworks:(NSArray*)list; - - -@end diff --git a/ZeroTier One/ShowNetworksViewController.m b/ZeroTier One/ShowNetworksViewController.m deleted file mode 100644 index e3a1e52c..00000000 --- a/ZeroTier One/ShowNetworksViewController.m +++ /dev/null @@ -1,119 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import "ShowNetworksViewController.h" -#import "NetworkMonitor.h" -#import "NetworkInfoCell.h" -#import "Network.h" - -@interface ShowNetworksViewController () - -@end - -@implementation ShowNetworksViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self.tableView setDelegate:self]; - [self.tableView setDataSource:self]; - [self.tableView setBackgroundColor:[NSColor clearColor]]; -} - -- (void)viewWillAppear { - [super viewWillAppear]; - self.visible = YES; -} - -- (void)viewWillDisappear { - [super viewWillDisappear]; - self.visible = NO; -} - -- (void)deleteNetworkFromList:(NSString *)nwid { - [self.netMonitor deleteSavedNetwork:nwid]; -} - -- (void)setNetworks:(NSArray *)list { - _networkList = list; - if(_visible) { - [_tableView reloadData]; - } -} - -- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { - return [_networkList count]; -} - -- (NSView*)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row -{ - NetworkInfoCell *cell = (NetworkInfoCell*)[tableView makeViewWithIdentifier:@"NetworkInfoCell" - owner:nil]; - Network *network = [_networkList objectAtIndex:row]; - cell.parent = self; - cell.networkIdField.stringValue = [NSString stringWithFormat:@"%10llx", network.nwid]; - cell.networkNameField.stringValue = network.name; - cell.statusField.stringValue = [network statusString]; - cell.typeField.stringValue = [network typeString]; - cell.mtuField.stringValue = [NSString stringWithFormat:@"%d", network.mtu]; - cell.macField.stringValue = network.mac; - cell.broadcastField.stringValue = network.broadcastEnabled ? @"ENABLED" : @"DISABLED"; - cell.bridgingField.stringValue = network.bridge ? @"ENABLED" : @"DISABLED"; - cell.deviceField.stringValue = network.portDeviceName; - - if(network.connected) { - cell.connectedCheckbox.state = NSOnState; - - if(network.allowDefault) { - cell.allowDefault.enabled = YES; - cell.allowDefault.state = NSOnState; - } - else { - cell.allowDefault.state = NSOffState; - - if([Network defaultRouteExists:_networkList]) { - cell.allowDefault.enabled = NO; - } - else { - cell.allowDefault.enabled = YES; - } - } - - cell.allowGlobal.enabled = YES; - cell.allowManaged.enabled = YES; - } - else { - cell.connectedCheckbox.state = NSOffState; - cell.allowDefault.enabled = NO; - cell.allowGlobal.enabled = NO; - cell.allowManaged.enabled = NO; - } - - cell.allowGlobal.state = network.allowGlobal ? NSOnState : NSOffState; - cell.allowManaged.state = network.allowManaged ? NSOnState : NSOffState; - - cell.addressesField.stringValue = @""; - - for(NSString *addr in network.assignedAddresses) { - cell.addressesField.stringValue = [[cell.addressesField.stringValue stringByAppendingString:addr] stringByAppendingString:@"\n"]; - } - - return cell; -} - -@end diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib deleted file mode 100644 index f26cb446..00000000 --- a/ZeroTier One/ShowNetworksViewController.xib +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ZeroTier One/ZeroTierIcon.icns b/ZeroTier One/ZeroTierIcon.icns deleted file mode 100644 index 17e60d58..00000000 Binary files a/ZeroTier One/ZeroTierIcon.icns and /dev/null differ diff --git a/ZeroTier One/about.html b/ZeroTier One/about.html deleted file mode 100644 index 4fa41d7b..00000000 --- a/ZeroTier One/about.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -
-
-
-
-
- -
-

Getting Started

- -

Getting started is simple. Simply click Join Network from the ZeroTier status bar menu. To join the public network "Earth", enter 8056c2e21c000001 and click the Join button. Once connected, you'll be able to navigate to earth.zerotier.net.

- -

Create a Network

-

Visit my.zerotier.com to create and manage your own virtual networks.

- -

For more information, visit zerotier.com.

- -
- - \ No newline at end of file diff --git a/ZeroTier One/main.m b/ZeroTier One/main.m deleted file mode 100644 index 108a6bd1..00000000 --- a/ZeroTier One/main.m +++ /dev/null @@ -1,23 +0,0 @@ -/* - * ZeroTier One - Network Virtualization Everywhere - * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#import - -int main(int argc, const char * argv[]) { - return NSApplicationMain(argc, argv); -} diff --git a/macui/ZeroTier One.xcodeproj/project.pbxproj b/macui/ZeroTier One.xcodeproj/project.pbxproj new file mode 100644 index 00000000..900daacb --- /dev/null +++ b/macui/ZeroTier One.xcodeproj/project.pbxproj @@ -0,0 +1,382 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; }; + 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; }; + 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */; }; + 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDD1CE7C816005CA2AC /* Assets.xcassets */; }; + 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BDF1CE7C816005CA2AC /* MainMenu.xib */; }; + 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */; }; + 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */; }; + 93D1675F1D54191C00330C99 /* NodeStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1675E1D54191C00330C99 /* NodeStatus.m */; }; + 93D167621D541BC200330C99 /* ServiceCom.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167611D541BC200330C99 /* ServiceCom.m */; }; + 93D167661D54308200330C99 /* Network.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167651D54308200330C99 /* Network.m */; }; + 93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167681D57E7EA00330C99 /* AboutViewController.m */; }; + 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */; }; + 93D167701D57FD3800330C99 /* NetworkMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */; }; + 93D167731D58093C00330C99 /* NetworkInfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167721D58093C00330C99 /* NetworkInfoCell.m */; }; + 93D167761D580C3500330C99 /* ShowNetworksViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167751D580C3500330C99 /* ShowNetworksViewController.m */; }; + 93D167791D5815E600330C99 /* JoinNetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D167781D5815E600330C99 /* JoinNetworkViewController.m */; }; + 93D1677C1D58228A00330C99 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1677B1D58228A00330C99 /* AppDelegate.m */; }; + 93D1679B1D58300F00330C99 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D1679A1D58300F00330C99 /* main.m */; }; + 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D1679C1D595F0000330C99 /* WebKit.framework */; }; + 93DAFB271D3F0BEE004D5417 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = 93DAFB261D3F0BEE004D5417 /* about.html */; }; + 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = ""; }; + 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = ""; }; + 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AboutViewController.xib; sourceTree = ""; }; + 93326BD81CE7C816005CA2AC /* ZeroTier One.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ZeroTier One.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 93326BDD1CE7C816005CA2AC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 93326BE01CE7C816005CA2AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 93326BE21CE7C816005CA2AC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = JoinNetworkViewController.xib; sourceTree = ""; }; + 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShowNetworksViewController.xib; sourceTree = ""; }; + 93D1675D1D54191C00330C99 /* NodeStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeStatus.h; sourceTree = ""; }; + 93D1675E1D54191C00330C99 /* NodeStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NodeStatus.m; sourceTree = ""; }; + 93D167601D541BC200330C99 /* ServiceCom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceCom.h; sourceTree = ""; }; + 93D167611D541BC200330C99 /* ServiceCom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ServiceCom.m; sourceTree = ""; }; + 93D167641D54308200330C99 /* Network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Network.h; sourceTree = ""; }; + 93D167651D54308200330C99 /* Network.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Network.m; sourceTree = ""; }; + 93D167671D57E7EA00330C99 /* AboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutViewController.h; sourceTree = ""; }; + 93D167681D57E7EA00330C99 /* AboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutViewController.m; sourceTree = ""; }; + 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesViewController.h; sourceTree = ""; }; + 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesViewController.m; sourceTree = ""; }; + 93D1676E1D57FD3800330C99 /* NetworkMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkMonitor.h; sourceTree = ""; }; + 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkMonitor.m; sourceTree = ""; }; + 93D167711D58093C00330C99 /* NetworkInfoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkInfoCell.h; sourceTree = ""; }; + 93D167721D58093C00330C99 /* NetworkInfoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkInfoCell.m; sourceTree = ""; }; + 93D167741D580C3500330C99 /* ShowNetworksViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShowNetworksViewController.h; sourceTree = ""; }; + 93D167751D580C3500330C99 /* ShowNetworksViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShowNetworksViewController.m; sourceTree = ""; }; + 93D167771D5815E600330C99 /* JoinNetworkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoinNetworkViewController.h; sourceTree = ""; }; + 93D167781D5815E600330C99 /* JoinNetworkViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JoinNetworkViewController.m; sourceTree = ""; }; + 93D1677A1D58228A00330C99 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 93D1677B1D58228A00330C99 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 93D1679A1D58300F00330C99 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 93D1679C1D595F0000330C99 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 93DAFB261D3F0BEE004D5417 /* about.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = about.html; sourceTree = ""; }; + 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthtokenCopy.m; sourceTree = ""; }; + 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthtokenCopy.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 93326BD51CE7C816005CA2AC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 93D1679D1D595F0000330C99 /* WebKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 93326BCF1CE7C816005CA2AC = { + isa = PBXGroup; + children = ( + 93D1679C1D595F0000330C99 /* WebKit.framework */, + 93326BDA1CE7C816005CA2AC /* ZeroTier One */, + 93326BD91CE7C816005CA2AC /* Products */, + ); + sourceTree = ""; + }; + 93326BD91CE7C816005CA2AC /* Products */ = { + isa = PBXGroup; + children = ( + 93326BD81CE7C816005CA2AC /* ZeroTier One.app */, + ); + name = Products; + sourceTree = ""; + }; + 93326BDA1CE7C816005CA2AC /* ZeroTier One */ = { + isa = PBXGroup; + children = ( + 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */, + 93326BDD1CE7C816005CA2AC /* Assets.xcassets */, + 93326BDF1CE7C816005CA2AC /* MainMenu.xib */, + 93326BE21CE7C816005CA2AC /* Info.plist */, + 93DAFE4A1CFE53CA00547CC4 /* AuthtokenCopy.m */, + 93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */, + 93D1676E1D57FD3800330C99 /* NetworkMonitor.h */, + 93D1676F1D57FD3800330C99 /* NetworkMonitor.m */, + 93DAFB261D3F0BEE004D5417 /* about.html */, + 93D1675D1D54191C00330C99 /* NodeStatus.h */, + 93D1675E1D54191C00330C99 /* NodeStatus.m */, + 93D167601D541BC200330C99 /* ServiceCom.h */, + 93D167611D541BC200330C99 /* ServiceCom.m */, + 93D167641D54308200330C99 /* Network.h */, + 93D167651D54308200330C99 /* Network.m */, + 93D167671D57E7EA00330C99 /* AboutViewController.h */, + 93D167681D57E7EA00330C99 /* AboutViewController.m */, + 932D47351D1CDC9B004BCFE2 /* AboutViewController.xib */, + 93D1676B1D57EB8400330C99 /* PreferencesViewController.h */, + 93D1676C1D57EB8400330C99 /* PreferencesViewController.m */, + 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */, + 93D167711D58093C00330C99 /* NetworkInfoCell.h */, + 93D167721D58093C00330C99 /* NetworkInfoCell.m */, + 93D167741D580C3500330C99 /* ShowNetworksViewController.h */, + 93D167751D580C3500330C99 /* ShowNetworksViewController.m */, + 93326BED1CE7DA30005CA2AC /* ShowNetworksViewController.xib */, + 93D167771D5815E600330C99 /* JoinNetworkViewController.h */, + 93D167781D5815E600330C99 /* JoinNetworkViewController.m */, + 93326BE91CE7D9B9005CA2AC /* JoinNetworkViewController.xib */, + 93D1677A1D58228A00330C99 /* AppDelegate.h */, + 93D1677B1D58228A00330C99 /* AppDelegate.m */, + 93D1679A1D58300F00330C99 /* main.m */, + ); + path = "ZeroTier One"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 93326BD71CE7C816005CA2AC /* ZeroTier One */ = { + isa = PBXNativeTarget; + buildConfigurationList = 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */; + buildPhases = ( + 93326BD41CE7C816005CA2AC /* Sources */, + 93326BD51CE7C816005CA2AC /* Frameworks */, + 93326BD61CE7C816005CA2AC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ZeroTier One"; + productName = "ZeroTier One"; + productReference = 93326BD81CE7C816005CA2AC /* ZeroTier One.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 93326BD01CE7C816005CA2AC /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = "ZeroTier, Inc"; + TargetAttributes = { + 93326BD71CE7C816005CA2AC = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 93326BCF1CE7C816005CA2AC; + productRefGroup = 93326BD91CE7C816005CA2AC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 93326BD71CE7C816005CA2AC /* ZeroTier One */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 93326BD61CE7C816005CA2AC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 93DAFB271D3F0BEE004D5417 /* about.html in Resources */, + 93326BEF1CE7DA30005CA2AC /* ShowNetworksViewController.xib in Resources */, + 932D47371D1CDC9B004BCFE2 /* AboutViewController.xib in Resources */, + 93326BEB1CE7D9B9005CA2AC /* JoinNetworkViewController.xib in Resources */, + 93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */, + 93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */, + 932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */, + 932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 93326BD41CE7C816005CA2AC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 93D1679B1D58300F00330C99 /* main.m in Sources */, + 93D167621D541BC200330C99 /* ServiceCom.m in Sources */, + 93D167761D580C3500330C99 /* ShowNetworksViewController.m in Sources */, + 93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */, + 93D167701D57FD3800330C99 /* NetworkMonitor.m in Sources */, + 93D1675F1D54191C00330C99 /* NodeStatus.m in Sources */, + 93D167691D57E7EA00330C99 /* AboutViewController.m in Sources */, + 93D1676D1D57EB8400330C99 /* PreferencesViewController.m in Sources */, + 93D1677C1D58228A00330C99 /* AppDelegate.m in Sources */, + 93D167731D58093C00330C99 /* NetworkInfoCell.m in Sources */, + 93D167661D54308200330C99 /* Network.m in Sources */, + 93D167791D5815E600330C99 /* JoinNetworkViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 93326BDF1CE7C816005CA2AC /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 93326BE01CE7C816005CA2AC /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 93326BE31CE7C816005CA2AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 93326BE41CE7C816005CA2AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 93326BE61CE7C816005CA2AC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "ZeroTier One/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 93326BE71CE7C816005CA2AC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = "ZeroTier One/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.ZeroTier-One"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "ZeroTier One/ZeroTier One-Bridging-Header.h"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 93326BD31CE7C816005CA2AC /* Build configuration list for PBXProject "ZeroTier One" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 93326BE31CE7C816005CA2AC /* Debug */, + 93326BE41CE7C816005CA2AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 93326BE51CE7C816005CA2AC /* Build configuration list for PBXNativeTarget "ZeroTier One" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 93326BE61CE7C816005CA2AC /* Debug */, + 93326BE71CE7C816005CA2AC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 93326BD01CE7C816005CA2AC /* Project object */; +} diff --git a/macui/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/macui/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..fd60338e --- /dev/null +++ b/macui/ZeroTier One.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macui/ZeroTier One/AboutViewController.h b/macui/ZeroTier One/AboutViewController.h new file mode 100644 index 00000000..d3d5bc14 --- /dev/null +++ b/macui/ZeroTier One/AboutViewController.h @@ -0,0 +1,33 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import +#import + +@interface AboutViewController : NSViewController + +@property (nonatomic, weak) IBOutlet WebView *webView; + +- (void)viewDidLoad; + +- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation + request:(NSURLRequest *)request + frame:(WebFrame *)frame +decisionListener:(id)listener; + +@end diff --git a/macui/ZeroTier One/AboutViewController.m b/macui/ZeroTier One/AboutViewController.m new file mode 100644 index 00000000..21dceae1 --- /dev/null +++ b/macui/ZeroTier One/AboutViewController.m @@ -0,0 +1,56 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "AboutViewController.h" + +@interface AboutViewController () + +@end + +@implementation AboutViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self.webView setWantsLayer:YES]; + self.webView.layer.borderWidth = 1.0f; + [self.webView.layer setCornerRadius:1.0f]; + self.webView.layer.masksToBounds = YES; + [self.webView.layer setBorderColor:[[NSColor darkGrayColor] CGColor]]; + + NSBundle *bundle = [NSBundle mainBundle]; + NSURL *path = [bundle URLForResource:@"about" withExtension:@"html"]; + if(path) { + [self.webView.mainFrame loadRequest:[NSURLRequest requestWithURL:path]]; + } +} + +- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation + request:(NSURLRequest *)request + frame:(WebFrame *)frame +decisionListener:(id)listener +{ + if(request.URL != nil && request.URL.host != nil) { + [[NSWorkspace sharedWorkspace] openURL:request.URL]; + } + else { + [listener use]; + } +} + +@end diff --git a/macui/ZeroTier One/AboutViewController.xib b/macui/ZeroTier One/AboutViewController.xib new file mode 100644 index 00000000..a0df0fcf --- /dev/null +++ b/macui/ZeroTier One/AboutViewController.xib @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macui/ZeroTier One/AppDelegate.h b/macui/ZeroTier One/AppDelegate.h new file mode 100644 index 00000000..a00cfba9 --- /dev/null +++ b/macui/ZeroTier One/AppDelegate.h @@ -0,0 +1,61 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@class NetworkMonitor; +@class Network; +@class NodeStatus; + +@interface AppDelegate : NSObject + +@property (weak, nonatomic) IBOutlet NSWindow *window; + +@property (nonatomic) NSStatusItem *statusItem; + +@property (nonatomic) NSPopover *networkListPopover; +@property (nonatomic) NSPopover *joinNetworkPopover; +@property (nonatomic) NSPopover *preferencesPopover; +@property (nonatomic) NSPopover *aboutPopover; + +@property (nonatomic) id transientMonitor; + +@property (nonatomic) NetworkMonitor *monitor; + +@property (nonatomic) NSMutableArray *networks; + +@property (nonatomic) NodeStatus *status; + +- (void)buildMenu; + +- (void)onNetworkListUpdated:(NSNotification*)note; +- (void)onNodeStatusUpdated:(NSNotification*)note; + +- (void)showNetworks; +- (void)joinNetwork; +- (void)showPreferences; +- (void)showAbout; +- (void)quit; +- (void)toggleNetwork:(NSMenuItem*)sender; +- (void)copyNodeID; + +- (void)closeJoinNetworkPopover; + +- (void)darkModeChanged:(NSNotification*)note; + +@end diff --git a/macui/ZeroTier One/AppDelegate.m b/macui/ZeroTier One/AppDelegate.m new file mode 100644 index 00000000..5da6b354 --- /dev/null +++ b/macui/ZeroTier One/AppDelegate.m @@ -0,0 +1,339 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "AppDelegate.h" +#import "NetworkMonitor.h" +#import "Network.h" +#import "NodeStatus.h" +#import "JoinNetworkViewController.h" +#import "ShowNetworksViewController.h" +#import "PreferencesViewController.h" +#import "AboutViewController.h" +#import "ServiceCom.h" + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:-2.0f]; + self.networkListPopover = [[NSPopover alloc] init]; + self.joinNetworkPopover = [[NSPopover alloc] init]; + self.preferencesPopover = [[NSPopover alloc] init]; + self.aboutPopover = [[NSPopover alloc] init]; + self.transientMonitor = nil; + self.monitor = [[NetworkMonitor alloc] init]; + self.networks = [NSMutableArray array]; + self.status = nil; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSDictionary *defaultsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:@"firstRun"]; + [defaults registerDefaults:defaultsDict]; + + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + [nc addObserver:self + selector:@selector(onNetworkListUpdated:) + name:NetworkUpdateKey + object:nil]; + [nc addObserver:self + selector:@selector(onNodeStatusUpdated:) + name:StatusUpdateKey + object:nil]; + + NSString *osxMode = [defaults stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(darkModeChanged:) + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; + + [self buildMenu]; + JoinNetworkViewController *jnvc = [[JoinNetworkViewController alloc] initWithNibName:@"JoinNetworkViewController" bundle:nil]; + jnvc.appDelegate = self; + self.joinNetworkPopover.contentViewController = jnvc; + self.joinNetworkPopover.behavior = NSPopoverBehaviorTransient; + + ShowNetworksViewController *showNetworksView = [[ShowNetworksViewController alloc] initWithNibName:@"ShowNetworksViewController" bundle:nil]; + showNetworksView.netMonitor = self.monitor; + self.networkListPopover.contentViewController = showNetworksView; + self.networkListPopover.behavior = NSPopoverBehaviorTransient; + + PreferencesViewController *prefsView = [[PreferencesViewController alloc] initWithNibName:@"PreferencesViewController" bundle:nil]; + self.preferencesPopover.contentViewController = prefsView; + self.preferencesPopover.behavior = NSPopoverBehaviorTransient; + + self.aboutPopover.contentViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil]; + self.aboutPopover.behavior = NSPopoverBehaviorTransient; + + BOOL firstRun = [defaults boolForKey:@"firstRun"]; + + if(firstRun) { + [defaults setBool:NO forKey:@"firstRun"]; + [defaults synchronize]; + + [prefsView setLaunchAtLoginEnabled:YES]; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + sleep(2); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + [self showAbout]; + }]; + }); + } + + [self.monitor updateNetworkInfo]; + [self.monitor start]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [[NSDistributedNotificationCenter defaultCenter] removeObserver:self + name:@"AppleInterfaceThemeChangedNotification" + object:nil]; +} + +- (void)showNetworks { + if(self.statusItem.button != nil) { + NSStatusBarButton *button = self.statusItem.button; + [self.networkListPopover showRelativeToRect:button.bounds + ofView:button + preferredEdge:NSMinYEdge]; + + if(self.transientMonitor == nil) { + self.transientMonitor = + [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) + handler:^(NSEvent * _Nonnull e) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + [self.networkListPopover close]; + }]; + } + } +} + +- (void)joinNetwork { + if(self.statusItem.button != nil) { + NSStatusBarButton *button = self.statusItem.button; + [self.joinNetworkPopover showRelativeToRect:button.bounds + ofView:button + preferredEdge:NSMinYEdge]; + if(self.transientMonitor == nil) { + self.transientMonitor = + [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) + handler:^(NSEvent * _Nonnull e) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + [self.joinNetworkPopover close]; + }]; + } + } +} + +- (void)showPreferences { + if(self.statusItem.button != nil) { + NSStatusBarButton *button = self.statusItem.button; + [self.preferencesPopover showRelativeToRect:button.bounds + ofView:button + preferredEdge:NSMinYEdge]; + if(self.transientMonitor == nil) { + [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) + handler:^(NSEvent * _Nonnull e) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + [self.preferencesPopover close]; + }]; + } + } +} + +- (void)showAbout { + if(self.statusItem.button != nil) { + NSStatusBarButton *button = self.statusItem.button; + [self.aboutPopover showRelativeToRect:button.bounds + ofView:button + preferredEdge:NSMinYEdge]; + if(self.transientMonitor == nil) { + [NSEvent addGlobalMonitorForEventsMatchingMask:(NSLeftMouseDown|NSRightMouseDown|NSOtherMouseDown) + handler:^(NSEvent * _Nonnull e) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + [self.aboutPopover close]; + }]; + } + } + +} + +- (void)quit { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; +} + +- (void)onNetworkListUpdated:(NSNotification*)note { + NSArray *netList = [note.userInfo objectForKey:@"networks"]; + [(ShowNetworksViewController*)self.networkListPopover.contentViewController setNetworks:netList]; + self.networks = [netList mutableCopy]; + + [self buildMenu]; +} + +- (void)onNodeStatusUpdated:(NSNotification*)note { + NodeStatus *status = [note.userInfo objectForKey:@"status"]; + self.status = status; + + [self buildMenu]; +} + +- (void)buildMenu { + NSMenu *menu = [[NSMenu alloc] init]; + + if(self.status != nil) { + NSString *nodeId = @"Node ID: "; + nodeId = [nodeId stringByAppendingString:self.status.address]; + [menu addItem:[[NSMenuItem alloc] initWithTitle:nodeId + action:@selector(copyNodeID) + keyEquivalent:@""]]; + [menu addItem:[NSMenuItem separatorItem]]; + } + + [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Network Details..." + action:@selector(showNetworks) + keyEquivalent:@"n"]]; + [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Join Network..." + action:@selector(joinNetwork) + keyEquivalent:@"j"]]; + + [menu addItem:[NSMenuItem separatorItem]]; + + if([self.networks count] > 0) { + for(Network *net in self.networks) { + NSString *nwid = [NSString stringWithFormat:@"%10llx", net.nwid]; + NSString *networkName = @""; + if([net.name lengthOfBytesUsingEncoding:NSUTF8StringEncoding] == 0) { + networkName = nwid; + } + else { + networkName = [NSString stringWithFormat:@"%@ (%@)", nwid, net.name]; + } + + if(net.allowDefault && net.connected) { + networkName = [networkName stringByAppendingString:@" [default]"]; + } + + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:networkName + action:@selector(toggleNetwork:) + keyEquivalent:@""]; + if(net.connected) { + item.state = NSOnState; + } + else { + item.state = NSOffState; + } + + item.representedObject = net; + + [menu addItem:item]; + } + + [menu addItem:[NSMenuItem separatorItem]]; + } + + [menu addItem:[[NSMenuItem alloc] initWithTitle:@"About ZeroTier One..." + action:@selector(showAbout) + keyEquivalent:@""]]; + [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Preferences..." + action:@selector(showPreferences) + keyEquivalent:@""]]; + + [menu addItem:[NSMenuItem separatorItem]]; + + [menu addItem:[[NSMenuItem alloc] initWithTitle:@"Quit" + action:@selector(quit) + keyEquivalent:@"q"]]; + + self.statusItem.menu = menu; +} + +- (void)toggleNetwork:(NSMenuItem*)sender { + Network *network = sender.representedObject; + NSString *nwid = [NSString stringWithFormat:@"%10llx", network.nwid]; + + if(network.connected) { + NSError *error = nil; + + [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; + + if (error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + } + } + else { + NSError *error = nil; + [[ServiceCom sharedInstance] joinNetwork:nwid + allowManaged:network.allowManaged + allowGlobal:network.allowGlobal + allowDefault:(network.allowDefault && ![Network defaultRouteExists:self.networks]) + error:&error]; + + if (error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + } + } +} + +- (void)copyNodeID { + if(self.status != nil) { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; + [pasteboard setString:self.status.address forType:NSPasteboardTypeString]; + } +} + +- (void)darkModeChanged:(NSNotification*)note { + NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + + if(osxMode != nil && [osxMode isEqualToString:@"Dark"]) { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMacWhite"]; + } + else { + self.statusItem.image = [NSImage imageNamed:@"MenuBarIconMac"]; + } +} + +- (void)closeJoinNetworkPopover { + if (self.transientMonitor) { + [NSEvent removeMonitor:self.transientMonitor]; + self.transientMonitor = nil; + } + [self.joinNetworkPopover close]; +} + +@end diff --git a/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json b/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..24c81d35 --- /dev/null +++ b/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,59 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "ZeroTierIcon512x512.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png b/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png new file mode 100644 index 00000000..d225c2e3 Binary files /dev/null and b/macui/ZeroTier One/Assets.xcassets/AppIcon.appiconset/ZeroTierIcon512x512.png differ diff --git a/macui/ZeroTier One/Assets.xcassets/Contents.json b/macui/ZeroTier One/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/macui/ZeroTier One/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json new file mode 100644 index 00000000..a680b58b --- /dev/null +++ b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "mac", + "filename" : "Menubar.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "filename" : "MenuBar@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png new file mode 100644 index 00000000..9fd3d3de Binary files /dev/null and b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/MenuBar@2x.png differ diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png new file mode 100644 index 00000000..ee0d7e3f Binary files /dev/null and b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMac.imageset/Menubar.png differ diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json new file mode 100644 index 00000000..61737760 --- /dev/null +++ b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "mac", + "filename" : "MenubarWhite.png", + "scale" : "1x" + }, + { + "idiom" : "mac", + "filename" : "MenubarWhite@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png new file mode 100644 index 00000000..7049ae55 Binary files /dev/null and b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite.png differ diff --git a/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png new file mode 100644 index 00000000..8c20e36f Binary files /dev/null and b/macui/ZeroTier One/Assets.xcassets/MenuBarIconMacWhite.imageset/MenubarWhite@2x.png differ diff --git a/macui/ZeroTier One/AuthtokenCopy.h b/macui/ZeroTier One/AuthtokenCopy.h new file mode 100644 index 00000000..f0497cc6 --- /dev/null +++ b/macui/ZeroTier One/AuthtokenCopy.h @@ -0,0 +1,26 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef AuthtokenCopy_h +#define AuthtokenCopy_h + +#import + +NSString* getAdminAuthToken(AuthorizationRef authRef); + +#endif /* AuthtokenCopy_h */ diff --git a/macui/ZeroTier One/AuthtokenCopy.m b/macui/ZeroTier One/AuthtokenCopy.m new file mode 100644 index 00000000..a10350f7 --- /dev/null +++ b/macui/ZeroTier One/AuthtokenCopy.m @@ -0,0 +1,97 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +#import "AuthtokenCopy.h" + + +NSString* getAdminAuthToken(AuthorizationRef authRef) { + char *tool = "/bin/cat"; + char *args[] = { "/Library/Application Support/ZeroTier/One/authtoken.secret", NULL}; + FILE *pipe = nil; + char token[25]; + memset(token, 0, sizeof(char)*25); + + + OSStatus status = AuthorizationExecuteWithPrivileges(authRef, tool, kAuthorizationFlagDefaults, args, &pipe); + + if (status != errAuthorizationSuccess) { + NSLog(@"Reading authtoken failed!"); + + + switch(status) { + case errAuthorizationDenied: + NSLog(@"Autorization Denied"); + break; + case errAuthorizationCanceled: + NSLog(@"Authorization Canceled"); + break; + case errAuthorizationInternal: + NSLog(@"Authorization Internal"); + break; + case errAuthorizationBadAddress: + NSLog(@"Bad Address"); + break; + case errAuthorizationInvalidRef: + NSLog(@"Invalid Ref"); + break; + case errAuthorizationInvalidSet: + NSLog(@"Invalid Set"); + break; + case errAuthorizationInvalidTag: + NSLog(@"Invalid Tag"); + break; + case errAuthorizationInvalidFlags: + NSLog(@"Invalid Flags"); + break; + case errAuthorizationInvalidPointer: + NSLog(@"Invalid Pointer"); + break; + case errAuthorizationToolExecuteFailure: + NSLog(@"Tool Execute Failure"); + break; + case errAuthorizationToolEnvironmentError: + NSLog(@"Tool Environment Failure"); + break; + case errAuthorizationExternalizeNotAllowed: + NSLog(@"Externalize Not Allowed"); + break; + case errAuthorizationInteractionNotAllowed: + NSLog(@"Interaction Not Allowed"); + break; + case errAuthorizationInternalizeNotAllowed: + NSLog(@"Internalize Not Allowed"); + break; + default: + NSLog(@"Unknown Error"); + break; + } + + return @""; + } + + if(pipe != nil) { + fread(&token, sizeof(char), 24, pipe); + fclose(pipe); + + return [NSString stringWithUTF8String:token]; + } + + return @""; +} diff --git a/macui/ZeroTier One/Base.lproj/MainMenu.xib b/macui/ZeroTier One/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..6b6da2a6 --- /dev/null +++ b/macui/ZeroTier One/Base.lproj/MainMenu.xib @@ -0,0 +1,680 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macui/ZeroTier One/Info.plist b/macui/ZeroTier One/Info.plist new file mode 100644 index 00000000..e04b5f28 --- /dev/null +++ b/macui/ZeroTier One/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + ZeroTierIcon.icns + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 15 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSHumanReadableCopyright + Copyright © 2016 ZeroTier, Inc. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macui/ZeroTier One/JoinNetworkViewController.h b/macui/ZeroTier One/JoinNetworkViewController.h new file mode 100644 index 00000000..428959fb --- /dev/null +++ b/macui/ZeroTier One/JoinNetworkViewController.h @@ -0,0 +1,40 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + + +extern NSString * const JoinedNetworksKey; + +@class AppDelegate; + +@interface JoinNetworkViewController : NSViewController + +@property (nonatomic, weak) IBOutlet NSComboBox *network; +@property (nonatomic, weak) IBOutlet NSButton *joinButton; +@property (nonatomic, weak) IBOutlet NSButton *allowManagedCheckBox; +@property (nonatomic, weak) IBOutlet NSButton *allowGlobalCheckBox; +@property (nonatomic, weak) IBOutlet NSButton *allowDefaultCheckBox; +@property (nonatomic, weak) IBOutlet AppDelegate *appDelegate; + +@property (nonatomic) NSMutableArray *values; + +- (IBAction)onJoinClicked:(id)sender; + + +@end diff --git a/macui/ZeroTier One/JoinNetworkViewController.m b/macui/ZeroTier One/JoinNetworkViewController.m new file mode 100644 index 00000000..cae26541 --- /dev/null +++ b/macui/ZeroTier One/JoinNetworkViewController.m @@ -0,0 +1,184 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "JoinNetworkViewController.h" +#import "ServiceCom.h" +#import "AppDelegate.h" + + +NSString * const JoinedNetworksKey = @"com.zerotier.one.joined-networks"; + +@interface NSString (extra) + +- (BOOL)contains:(NSString*)find; + +@end + +@implementation NSString (extra) + +- (BOOL)contains:(NSString*)find { + NSRange range = [self rangeOfString:find]; + return range.location != NSNotFound; +} + +@end + + +@implementation JoinNetworkViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do view setup here. + [self.network setDelegate:self]; + [self.network setDataSource:self]; +} + +- (void)viewWillAppear { + [super viewWillAppear]; + + self.allowManagedCheckBox.state = NSOnState; + self.allowGlobalCheckBox.state = NSOffState; + self.allowDefaultCheckBox.state = NSOffState; + + self.network.stringValue = @""; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + NSMutableArray *vals = [[defaults stringArrayForKey:JoinedNetworksKey] mutableCopy]; + + if(vals) { + self.values = vals; + } +} + +- (void)viewWillDisappear { + [super viewWillDisappear]; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + [defaults setObject:self.values forKey:JoinedNetworksKey]; +} + +- (IBAction)onJoinClicked:(id)sender { + NSString *networkId = self.network.stringValue; + + NSError *error = nil; + [[ServiceCom sharedInstance] joinNetwork:networkId + allowManaged:(self.allowManagedCheckBox.state == NSOnState) + allowGlobal:(self.allowGlobalCheckBox.state == NSOnState) + allowDefault:(self.allowDefaultCheckBox.state == NSOnState) + error:&error]; + + if(error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + return; + } + + self.network.stringValue = @""; + + if(![self.values containsObject:networkId]) { + [self.values insertObject:networkId atIndex:0]; + + while([self.values count] > 20) { + [self.values removeLastObject]; + } + } + + [self.appDelegate closeJoinNetworkPopover]; +} + +// NSComboBoxDelegate methods + +- (void)controlTextDidChange:(NSNotification *)obj { + NSComboBox *cb = (NSComboBox*)obj.object; + NSString *value = cb.stringValue; + + NSString *allowedCharacters = @"abcdefABCDEF0123456789"; + + NSString *outValue = @""; + + for(int i = 0; i < [value length]; ++i) { + if(![allowedCharacters contains:[NSString stringWithFormat:@"%C", [value characterAtIndex:i]]]) { + NSBeep(); + } + else { + outValue = [outValue stringByAppendingString:[NSString stringWithFormat:@"%C", [value characterAtIndex:i]]]; + } + } + + if([outValue lengthOfBytesUsingEncoding:NSUTF8StringEncoding] == 16) { + self.joinButton.enabled = YES; + } + else { + if([outValue lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 16) { + NSRange range = {0, 16}; + range = [outValue rangeOfComposedCharacterSequencesForRange:range]; + outValue = [outValue substringWithRange:range]; + NSBeep(); + self.joinButton.enabled = YES; + } + else { + self.joinButton.enabled = NO; + } + } + + cb.stringValue = outValue; +} + +// end NSComboBoxDelegate methods + +// NSComboBoxDataSource methods + +- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox { + return [self.values count]; +} + +- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index { + return [self.values objectAtIndex:index]; +} + +- (NSUInteger)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)string { + NSUInteger counter = 0; + + for(NSString *val in self.values) { + if([val isEqualToString:string]) { + return counter; + } + + counter += 1; + } + + return NSNotFound; +} + +- (NSString*)comboBox:(NSComboBox *)aComboBox completedString:(NSString *)string { + for(NSString *val in self.values) { + if([val hasPrefix:string]) { + return val; + } + } + return nil; +} + +// end NSComboBoxDataSource methods + +@end diff --git a/macui/ZeroTier One/JoinNetworkViewController.xib b/macui/ZeroTier One/JoinNetworkViewController.xib new file mode 100644 index 00000000..2ef43442 --- /dev/null +++ b/macui/ZeroTier One/JoinNetworkViewController.xib @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macui/ZeroTier One/Network.h b/macui/ZeroTier One/Network.h new file mode 100644 index 00000000..0f3c4964 --- /dev/null +++ b/macui/ZeroTier One/Network.h @@ -0,0 +1,62 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +enum NetworkStatus { + REQUESTING_CONFIGURATION, + OK, + ACCESS_DENIED, + NOT_FOUND, + PORT_ERROR, + CLIENT_TOO_OLD, +}; + +enum NetworkType { + PUBLIC, + PRIVATE, +}; + +@interface Network : NSObject + +@property (readonly) NSArray *assignedAddresses; +@property (readonly) BOOL bridge; +@property (readonly) BOOL broadcastEnabled; +@property (readonly) BOOL dhcp; +@property (readonly) NSString *mac; +@property (readonly) int mtu; +@property (readonly) int netconfRevision; +@property (readonly) NSString *name; +@property (readonly) UInt64 nwid; +@property (readonly) NSString *portDeviceName; +@property (readonly) int portError; +@property (readonly) enum NetworkStatus status; +@property (readonly) enum NetworkType type; +@property (readonly) BOOL allowManaged; +@property (readonly) BOOL allowGlobal; +@property (readonly) BOOL allowDefault; +@property (readonly) BOOL connected; // not persisted. set to YES if loaded via json + +- (id)initWithJsonData:(NSDictionary*)jsonData; +- (id)initWithCoder:(NSCoder *)aDecoder; +- (void)encodeWithCoder:(NSCoder *)aCoder; ++ (BOOL)defaultRouteExists:(NSArray*)netList; +- (NSString*)statusString; +- (NSString*)typeString; + +@end diff --git a/macui/ZeroTier One/Network.m b/macui/ZeroTier One/Network.m new file mode 100644 index 00000000..16efc6e3 --- /dev/null +++ b/macui/ZeroTier One/Network.m @@ -0,0 +1,278 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "Network.h" + +NSString *NetworkAddressesKey = @"addresses"; +NSString *NetworkBridgeKey = @"bridge"; +NSString *NetworkBroadcastKey = @"broadcast"; +NSString *NetworkDhcpKey = @"dhcp"; +NSString *NetworkMacKey = @"mac"; +NSString *NetworkMtuKey = @"mtu"; +NSString *NetworkMulticastKey = @"multicast"; +NSString *NetworkNameKey = @"name"; +NSString *NetworkNetconfKey = @"netconf"; +NSString *NetworkNwidKey = @"nwid"; +NSString *NetworkPortNameKey = @"port"; +NSString *NetworkPortErrorKey = @"portError"; +NSString *NetworkStatusKey = @"status"; +NSString *NetworkTypeKey = @"type"; +NSString *NetworkAllowManagedKey = @"allowManaged"; +NSString *NetworkAllowGlobalKey = @"allowGlobal"; +NSString *NetworkAllowDefaultKey = @"allowDefault"; + +@implementation Network + +- (id)initWithJsonData:(NSDictionary*)jsonData +{ + self = [super init]; + + if(self) { + if([jsonData objectForKey:@"assignedAddresses"]) { + _assignedAddresses = (NSArray*)[jsonData objectForKey:@"assignedAddresses"]; + } + + if([jsonData objectForKey:@"bridge"]) { + _bridge = [(NSNumber*)[jsonData objectForKey:@"bridge"] boolValue]; + } + + if([jsonData objectForKey:@"broadcastEnabled"]) { + _broadcastEnabled = [(NSNumber*)[jsonData objectForKey:@"broadcastEnabled"] boolValue]; + } + + if([jsonData objectForKey:@"dhcp"]) { + _dhcp = [(NSNumber*)[jsonData objectForKey:@"dhcp"] boolValue]; + } + + if([jsonData objectForKey:@"mac"]) { + _mac = (NSString*)[jsonData objectForKey:@"mac"]; + } + + if([jsonData objectForKey:@"mtu"]) { + _mtu = [(NSNumber*)[jsonData objectForKey:@"mtu"] intValue]; + } + + if([jsonData objectForKey:@"name"]) { + _name = (NSString*)[jsonData objectForKey:@"name"]; + } + + if([jsonData objectForKey:@"netconfRevision"]) { + _netconfRevision = [(NSNumber*)[jsonData objectForKey:@"netconfRevision"] intValue]; + } + + if([jsonData objectForKey:@"nwid"]) { + NSString *networkid = (NSString*)[jsonData objectForKey:@"nwid"]; + + NSScanner *scanner = [NSScanner scannerWithString:networkid]; + [scanner scanHexLongLong:&_nwid]; + } + + if([jsonData objectForKey:@"portDeviceName"]) { + _portDeviceName = (NSString*)[jsonData objectForKey:@"portDeviceName"]; + } + + if([jsonData objectForKey:@"portError"]) { + _portError = [(NSNumber*)[jsonData objectForKey:@"portError"] intValue]; + } + + if([jsonData objectForKey:@"allowManaged"]) { + _allowManaged = [(NSNumber*)[jsonData objectForKey:@"allowManaged"] boolValue]; + } + + if([jsonData objectForKey:@"allowGlobal"]) { + _allowGlobal = [(NSNumber*)[jsonData objectForKey:@"allowGlobal"] boolValue]; + } + + if([jsonData objectForKey:@"allowDefault"]) { + _allowDefault = [(NSNumber*)[jsonData objectForKey:@"allowDefault"] boolValue]; + } + + if([jsonData objectForKey:@"status"]) { + NSString *statusStr = (NSString*)[jsonData objectForKey:@"status"]; + if([statusStr isEqualToString:@"REQUESTING_CONFIGURATION"]) { + _status = REQUESTING_CONFIGURATION; + } + else if([statusStr isEqualToString:@"OK"]) { + _status = OK; + } + else if([statusStr isEqualToString:@"ACCESS_DENIED"]) { + _status = ACCESS_DENIED; + } + else if([statusStr isEqualToString:@"NOT_FOUND"]) { + _status = NOT_FOUND; + } + else if([statusStr isEqualToString:@"PORT_ERROR"]) { + _status = PORT_ERROR; + } + else if([statusStr isEqualToString:@"CLIENT_TOO_OLD"]) { + _status = CLIENT_TOO_OLD; + } + } + + if([jsonData objectForKey:@"type"]) { + NSString *typeStr = (NSString*)[jsonData objectForKey:@"type"]; + if([typeStr isEqualToString:@"PRIVATE"]) { + _type = PRIVATE; + } + else if([typeStr isEqualToString:@"PUBLIC"]) { + _type = PUBLIC; + } + } + + _connected = YES; + } + + return self; +} +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super init]; + + if(self) { + if([aDecoder containsValueForKey:NetworkAddressesKey]) { + _assignedAddresses = (NSArray*)[aDecoder decodeObjectForKey:NetworkAddressesKey]; + } + + if([aDecoder containsValueForKey:NetworkBridgeKey]) { + _bridge = [aDecoder decodeBoolForKey:NetworkBridgeKey]; + } + + if([aDecoder containsValueForKey:NetworkBroadcastKey]) { + _broadcastEnabled = [aDecoder decodeBoolForKey:NetworkBroadcastKey]; + } + + if([aDecoder containsValueForKey:NetworkDhcpKey]) { + _dhcp = [aDecoder decodeBoolForKey:NetworkDhcpKey]; + } + + if([aDecoder containsValueForKey:NetworkMacKey]) { + _mac = (NSString*)[aDecoder decodeObjectForKey:NetworkMacKey]; + } + + if([aDecoder containsValueForKey:NetworkMtuKey]) { + _mtu = (int)[aDecoder decodeIntegerForKey:NetworkMtuKey]; + } + + if([aDecoder containsValueForKey:NetworkNameKey]) { + _name = (NSString*)[aDecoder decodeObjectForKey:NetworkNameKey]; + } + + if([aDecoder containsValueForKey:NetworkNetconfKey]) { + _netconfRevision = (int)[aDecoder decodeIntegerForKey:NetworkNetconfKey]; + } + + if([aDecoder containsValueForKey:NetworkNwidKey]) { + _nwid = [(NSNumber*)[aDecoder decodeObjectForKey:NetworkNwidKey] unsignedLongLongValue]; + } + + if([aDecoder containsValueForKey:NetworkPortNameKey]) { + _portDeviceName = (NSString*)[aDecoder decodeObjectForKey:NetworkPortNameKey]; + } + + if([aDecoder containsValueForKey:NetworkPortErrorKey]) { + _portError = (int)[aDecoder decodeIntegerForKey:NetworkPortErrorKey]; + } + + if([aDecoder containsValueForKey:NetworkStatusKey]) { + _status = (enum NetworkStatus)[aDecoder decodeIntegerForKey:NetworkStatusKey]; + } + + if([aDecoder containsValueForKey:NetworkTypeKey]) { + _type = (enum NetworkType)[aDecoder decodeIntegerForKey:NetworkTypeKey]; + } + + if([aDecoder containsValueForKey:NetworkAllowManagedKey]) { + _allowManaged = [aDecoder decodeBoolForKey:NetworkAllowManagedKey]; + } + + if([aDecoder containsValueForKey:NetworkAllowGlobalKey]) { + _allowGlobal = [aDecoder decodeBoolForKey:NetworkAllowGlobalKey]; + } + + if([aDecoder containsValueForKey:NetworkAllowDefaultKey]) { + _allowDefault = [aDecoder decodeBoolForKey:NetworkAllowDefaultKey]; + } + + _connected = NO; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + [aCoder encodeObject:_assignedAddresses forKey:NetworkAddressesKey]; + [aCoder encodeBool:_bridge forKey:NetworkBridgeKey]; + [aCoder encodeBool:_broadcastEnabled forKey:NetworkBroadcastKey]; + [aCoder encodeBool:_dhcp forKey:NetworkDhcpKey]; + [aCoder encodeObject:_mac forKey:NetworkMacKey]; + [aCoder encodeInteger:_mtu forKey:NetworkMtuKey]; + [aCoder encodeObject:_name forKey:NetworkNameKey]; + [aCoder encodeInteger:_netconfRevision forKey:NetworkNetconfKey]; + [aCoder encodeObject:[NSNumber numberWithUnsignedLongLong:_nwid] + forKey:NetworkNwidKey]; + [aCoder encodeObject:_portDeviceName forKey:NetworkPortNameKey]; + [aCoder encodeInteger:_portError forKey:NetworkPortErrorKey]; + [aCoder encodeInteger:_status forKey:NetworkStatusKey]; + [aCoder encodeInteger:_type forKey:NetworkTypeKey]; + [aCoder encodeBool:_allowManaged forKey:NetworkAllowManagedKey]; + [aCoder encodeBool:_allowGlobal forKey:NetworkAllowGlobalKey]; + [aCoder encodeBool:_allowDefault forKey:NetworkAllowDefaultKey]; +} + ++ (BOOL)defaultRouteExists:(NSArray*)netList +{ + for(Network *net in netList) { + if (net.allowDefault && net.connected) { + return YES; + } + } + return NO; +} + +- (NSString*)statusString { + switch(_status) { + case REQUESTING_CONFIGURATION: + return @"REQUESTING_CONFIGURATION"; + case OK: + return @"OK"; + case ACCESS_DENIED: + return @"ACCESS_DENIED"; + case NOT_FOUND: + return @"NOT_FOUND"; + case PORT_ERROR: + return @"PORT_ERROR"; + case CLIENT_TOO_OLD: + return @"CLIENT_TOO_OLD"; + default: + return @""; + } +} + +- (NSString*)typeString { + switch(_type) { + case PUBLIC: + return @"PUBLIC"; + case PRIVATE: + return @"PRIVATE"; + default: + return @""; + } +} + +@end diff --git a/macui/ZeroTier One/NetworkInfoCell.h b/macui/ZeroTier One/NetworkInfoCell.h new file mode 100644 index 00000000..be9345d7 --- /dev/null +++ b/macui/ZeroTier One/NetworkInfoCell.h @@ -0,0 +1,50 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@class ShowNetworksViewController; + +@interface NetworkInfoCell : NSTableCellView + +@property (weak, nonatomic) ShowNetworksViewController *parent; + +@property (weak, nonatomic) IBOutlet NSTextField *networkIdField; +@property (weak, nonatomic) IBOutlet NSTextField *networkNameField; +@property (weak, nonatomic) IBOutlet NSTextField *statusField; +@property (weak, nonatomic) IBOutlet NSTextField *typeField; +@property (weak, nonatomic) IBOutlet NSTextField *macField; +@property (weak, nonatomic) IBOutlet NSTextField *mtuField; +@property (weak, nonatomic) IBOutlet NSTextField *broadcastField; +@property (weak, nonatomic) IBOutlet NSTextField *bridgingField; +@property (weak, nonatomic) IBOutlet NSTextField *deviceField; +@property (weak, nonatomic) IBOutlet NSTextField *addressesField; +@property (weak, nonatomic) IBOutlet NSButton *allowManaged; +@property (weak, nonatomic) IBOutlet NSButton *allowGlobal; +@property (weak, nonatomic) IBOutlet NSButton *allowDefault; +@property (weak, nonatomic) IBOutlet NSButton *connectedCheckbox; +@property (weak, nonatomic) IBOutlet NSButton *deleteButton; + +- (IBAction)onConnectCheckStateChanged:(NSButton*)sender; +- (IBAction)deleteNetwork:(NSButton*)sender; +- (IBAction)onAllowStatusChanged:(NSButton*)sender; + +- (void)joinNetwork:(NSString*)nwid; +- (void)leaveNetwork:(NSString*)nwid; + +@end diff --git a/macui/ZeroTier One/NetworkInfoCell.m b/macui/ZeroTier One/NetworkInfoCell.m new file mode 100644 index 00000000..dc75cab3 --- /dev/null +++ b/macui/ZeroTier One/NetworkInfoCell.m @@ -0,0 +1,85 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "NetworkInfoCell.h" +#import "ServiceCom.h" +#import "ShowNetworksViewController.h" +#import "Network.h" + +@implementation NetworkInfoCell + +- (void)drawRect:(NSRect)dirtyRect { + [super drawRect:dirtyRect]; + + // Drawing code here. +} + +- (IBAction)onConnectCheckStateChanged:(NSButton*)sender +{ + if(sender.state == NSOnState) { + [self joinNetwork:self.networkIdField.stringValue]; + } + else { + [self leaveNetwork:self.networkIdField.stringValue]; + } +} + +- (IBAction)deleteNetwork:(NSButton*)sender; +{ + [self leaveNetwork:self.networkIdField.stringValue]; + [self.parent deleteNetworkFromList:self.networkIdField.stringValue]; +} + +- (IBAction)onAllowStatusChanged:(NSButton*)sender +{ + [self joinNetwork:self.networkIdField.stringValue]; +} + +- (void)joinNetwork:(NSString*)nwid +{ + NSError *error = nil; + [[ServiceCom sharedInstance] joinNetwork:nwid + allowManaged:(self.allowManaged.state == NSOnState) + allowGlobal:(self.allowGlobal.state == NSOnState) + allowDefault:![Network defaultRouteExists:_parent.networkList] && (self.allowDefault.state == NSOnState) + error:&error]; + + if (error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + } +} + +- (void)leaveNetwork:(NSString*)nwid +{ + NSError *error = nil; + [[ServiceCom sharedInstance] leaveNetwork:nwid error:&error]; + + if (error) { + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Ok"]; + + [alert runModal]; + } +} + +@end diff --git a/macui/ZeroTier One/NetworkMonitor.h b/macui/ZeroTier One/NetworkMonitor.h new file mode 100644 index 00000000..8cdec4ed --- /dev/null +++ b/macui/ZeroTier One/NetworkMonitor.h @@ -0,0 +1,45 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +extern NSString * const NetworkUpdateKey; +extern NSString * const StatusUpdateKey; + +@class Network; + +@interface NetworkMonitor : NSObject +{ + NSMutableArray *_savedNetworks; + NSArray *_receivedNetworks; + NSMutableArray *_allNetworks; + + NSTimer *_timer; +} + +- (id)init; +- (void)dealloc; + +- (void)start; +- (void)stop; + +- (void)updateNetworkInfo; + +- (void)deleteSavedNetwork:(NSString*)networkId; + +@end diff --git a/macui/ZeroTier One/NetworkMonitor.m b/macui/ZeroTier One/NetworkMonitor.m new file mode 100644 index 00000000..7ed22c4a --- /dev/null +++ b/macui/ZeroTier One/NetworkMonitor.m @@ -0,0 +1,253 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "NetworkMonitor.h" +#import "Network.h" +#import "ServiceCom.h" +#import "NodeStatus.h" + +@import AppKit; + + +NSString * const NetworkUpdateKey = @"com.zerotier.one.network-list"; +NSString * const StatusUpdateKey = @"com.zerotier.one.status"; + +@interface NetworkMonitor (private) + +- (NSString*)dataFile; +- (void)internal_updateNetworkInfo; +- (NSInteger)findNetworkWithID:(UInt64)networkId; +- (NSInteger)findSavedNetworkWithID:(UInt64)networkId; +- (void)saveNetworks; + +@end + +@implementation NetworkMonitor + +- (id)init +{ + self = [super init]; + if(self) + { + _savedNetworks = [NSMutableArray array]; + _receivedNetworks = [NSArray array]; + _allNetworks = [NSMutableArray array]; + _timer = nil; + } + + return self; +} + +- (void)dealloc +{ + [_timer invalidate]; +} + +- (void)start +{ + NSLog(@"ZeroTier monitor started"); + _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f + target:self + selector:@selector(updateNetworkInfo) + userInfo:nil + repeats:YES]; +} + +- (void)stop +{ + NSLog(@"ZeroTier monitor stopped"); + [_timer invalidate]; + _timer = nil; +} + +- (void)updateNetworkInfo +{ + NSString *filePath = [self dataFile]; + + if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { + NSArray *networks = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; + + if(networks != nil) { + _savedNetworks = [networks mutableCopy]; + } + } + + NSError *error = nil; + + [[ServiceCom sharedInstance] getNetworklist:^(NSArray *networkList) { + _receivedNetworks = networkList; + + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + [self internal_updateNetworkInfo]; + } ]; + } error:&error]; + + if(error) { + [self stop]; + + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res = [alert runModal]; + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + else if(res == NSAlertSecondButtonReturn) { + [self start]; + return; + } + } + + [[ServiceCom sharedInstance] getNodeStatus:^(NodeStatus *status) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:status forKey:@"status"]; + + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + [[NSNotificationCenter defaultCenter] postNotificationName:StatusUpdateKey + object:nil + userInfo:userInfo]; + }]; + } error:&error]; + + if (error) { + [self stop]; + + NSAlert *alert = [NSAlert alertWithError:error]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res = [alert runModal]; + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + else if(res == NSAlertSecondButtonReturn) { + [self start]; + return; + } + } +} + +- (void)deleteSavedNetwork:(NSString*)networkId +{ + UInt64 nwid = 0; + NSScanner *scanner = [NSScanner scannerWithString:networkId]; + [scanner scanHexLongLong:&nwid]; + + NSInteger index = [self findNetworkWithID:nwid]; + + if(index != NSNotFound) { + [_allNetworks removeObjectAtIndex:index]; + } + + index = [self findSavedNetworkWithID:nwid]; + + if(index != NSNotFound) { + [_savedNetworks removeObjectAtIndex:index]; + } + + [self saveNetworks]; +} + +@end + +@implementation NetworkMonitor (private) +- (NSString*)dataFile +{ + NSURL *appSupport = [[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory + inDomains:NSUserDomainMask] objectAtIndex:0]; + + appSupport = [[[appSupport URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"] URLByAppendingPathComponent:@"networkinfo.dat"]; + return appSupport.path; +} + +- (void)internal_updateNetworkInfo +{ + NSMutableArray *networks = [_savedNetworks mutableCopy]; + + for(Network *nw in _receivedNetworks) { + NSInteger index = [self findSavedNetworkWithID:nw.nwid]; + + if(index != NSNotFound) { + [networks setObject:nw atIndexedSubscript:index]; + } + else { + [networks addObject:nw]; + } + } + + [networks sortUsingComparator:^NSComparisonResult(Network *obj1, Network *obj2) { + if(obj1.nwid > obj2.nwid) { + return true; + } + return false; + }]; + + @synchronized(_allNetworks) { + _allNetworks = networks; + } + + [self saveNetworks]; + + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:networks forKey:@"networks"]; + + [[NSNotificationCenter defaultCenter] postNotificationName:NetworkUpdateKey + object:nil + userInfo:userInfo]; +} + +- (NSInteger)findNetworkWithID:(UInt64)networkId +{ + for(int i = 0; i < [_allNetworks count]; ++i) { + Network *nw = [_allNetworks objectAtIndex:i]; + + if(nw.nwid == networkId) { + return i; + } + } + + return NSNotFound; +} + + +- (NSInteger)findSavedNetworkWithID:(UInt64)networkId +{ + for(int i = 0; i < [_savedNetworks count]; ++i) { + Network *nw = [_savedNetworks objectAtIndex:i]; + + if(nw.nwid == networkId) { + return i; + } + } + + return NSNotFound; +} + +- (void)saveNetworks +{ + NSString *filePath = [self dataFile]; + + @synchronized(_allNetworks) { + [NSKeyedArchiver archiveRootObject:_allNetworks toFile:filePath]; + } +} + +@end diff --git a/macui/ZeroTier One/NodeStatus.h b/macui/ZeroTier One/NodeStatus.h new file mode 100644 index 00000000..eab5bfe4 --- /dev/null +++ b/macui/ZeroTier One/NodeStatus.h @@ -0,0 +1,35 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@interface NodeStatus : NSObject + +@property (readonly) NSString *address; +@property (readonly) NSString *publicIdentity; +@property (readonly) BOOL online; +@property (readonly) BOOL tcpFallbackActive; +@property (readonly) int versionMajor; +@property (readonly) int versionMinor; +@property (readonly) int versionRev; +@property (readonly) NSString *version; +@property (readonly) UInt64 clock; + +- (id)initWithJsonData:(NSDictionary*)jsonData; + +@end diff --git a/macui/ZeroTier One/NodeStatus.m b/macui/ZeroTier One/NodeStatus.m new file mode 100644 index 00000000..3bae3c7d --- /dev/null +++ b/macui/ZeroTier One/NodeStatus.m @@ -0,0 +1,40 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#import "NodeStatus.h" + +@implementation NodeStatus + +- (id)initWithJsonData:(NSDictionary*)jsonData +{ + self = [super init]; + + if(self) { + _address = (NSString*)[jsonData objectForKey:@"address"]; + _publicIdentity = (NSString*)[jsonData objectForKey:@"publicIdentity"]; + _online = [(NSNumber*)[jsonData objectForKey:@"online"] boolValue]; + _tcpFallbackActive = [(NSNumber*)[jsonData objectForKey:@"tcpFallbackActive"] boolValue]; + _versionMajor = [(NSNumber*)[jsonData objectForKey:@"versionMajor"] intValue]; + _versionMinor = [(NSNumber*)[jsonData objectForKey:@"versionMinor"] intValue]; + _versionRev = [(NSNumber*)[jsonData objectForKey:@"versionRev"] intValue]; + _version = (NSString*)[jsonData objectForKey:@"version"]; + _clock = [(NSNumber*)[jsonData objectForKey:@"clock"] unsignedLongLongValue]; + } + + return self; +} +@end diff --git a/macui/ZeroTier One/PreferencesViewController.h b/macui/ZeroTier One/PreferencesViewController.h new file mode 100644 index 00000000..56d0fdb8 --- /dev/null +++ b/macui/ZeroTier One/PreferencesViewController.h @@ -0,0 +1,31 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@interface PreferencesViewController : NSViewController + +@property (nonatomic, weak) IBOutlet NSButton *startupCheckBox; + +- (IBAction)onStartupCheckBoxChanged:(NSButton*)sender; + +- (BOOL)isLaunchAtStartup; +- (LSSharedFileListItemRef)itemRefInLoginItems; +- (void)setLaunchAtLoginEnabled:(BOOL)enabled; + +@end diff --git a/macui/ZeroTier One/PreferencesViewController.m b/macui/ZeroTier One/PreferencesViewController.m new file mode 100644 index 00000000..13927fba --- /dev/null +++ b/macui/ZeroTier One/PreferencesViewController.m @@ -0,0 +1,112 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "PreferencesViewController.h" + +@interface PreferencesViewController () + +@end + +@implementation PreferencesViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + if([self isLaunchAtStartup]) { + self.startupCheckBox.state = NSOnState; + } + else { + self.startupCheckBox.state = NSOffState; + } +} + +- (IBAction)onStartupCheckBoxChanged:(NSButton *)sender +{ + if(sender.state == NSOnState) { + [self setLaunchAtLoginEnabled:YES]; + } + else { + [self setLaunchAtLoginEnabled:NO]; + } + +} + +- (void)setLaunchAtLoginEnabled:(BOOL)enabled +{ + LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + + if (enabled) { + // Add the app to the LoginItems list. + CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; + LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL); + if (itemRef) CFRelease(itemRef); + } + else { + // Remove the app from the LoginItems list. + LSSharedFileListItemRef itemRef = [self itemRefInLoginItems]; + LSSharedFileListItemRemove(loginItemsRef,itemRef); + if (itemRef != nil) CFRelease(itemRef); + } +} + + +- (BOOL)isLaunchAtStartup { + // See if the app is currently in LoginItems. + LSSharedFileListItemRef itemRef = [self itemRefInLoginItems]; + // Store away that boolean. + BOOL isInList = itemRef != nil; + // Release the reference if it exists. + if (itemRef != nil) CFRelease(itemRef); + + return isInList; +} + +- (LSSharedFileListItemRef)itemRefInLoginItems { + LSSharedFileListItemRef itemRef = nil; + + NSString * appPath = [[NSBundle mainBundle] bundlePath]; + + // This will retrieve the path for the application + // For example, /Applications/test.app + CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:appPath]; + + // Create a reference to the shared file list. + LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + + if (loginItems) { + UInt32 seedValue; + //Retrieve the list of Login Items and cast them to + // a NSArray so that it will be easier to iterate. + NSArray *loginItemsArray = (__bridge NSArray *)LSSharedFileListCopySnapshot(loginItems, &seedValue); + for(int i = 0; i< [loginItemsArray count]; i++){ + LSSharedFileListItemRef currentItemRef = (__bridge LSSharedFileListItemRef)[loginItemsArray + objectAtIndex:i]; + //Resolve the item with URL + if (LSSharedFileListItemResolve(currentItemRef, 0, (CFURLRef*) &url, NULL) == noErr) { + NSString * urlPath = [(__bridge NSURL*)url path]; + if ([urlPath compare:appPath] == NSOrderedSame){ + itemRef = currentItemRef; + } + } + } + } + CFRelease(loginItems); + return itemRef; +} + +@end diff --git a/macui/ZeroTier One/PreferencesViewController.xib b/macui/ZeroTier One/PreferencesViewController.xib new file mode 100644 index 00000000..62aef4c0 --- /dev/null +++ b/macui/ZeroTier One/PreferencesViewController.xib @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macui/ZeroTier One/ServiceCom.h b/macui/ZeroTier One/ServiceCom.h new file mode 100644 index 00000000..74ab2b35 --- /dev/null +++ b/macui/ZeroTier One/ServiceCom.h @@ -0,0 +1,39 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@class NodeStatus; +@class Network; + +@interface ServiceCom : NSObject +{ + NSString *baseURL; + NSURLSession *session; + BOOL _isQuitting; +} ++ (ServiceCom*)sharedInstance; + +- (id)init; + +- (void)getNetworklist:(void (^)(NSArray*))completionHandler error:(NSError* __autoreleasing *)error; +- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error; +- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError*__autoreleasing*)error; +- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error; + +@end diff --git a/macui/ZeroTier One/ServiceCom.m b/macui/ZeroTier One/ServiceCom.m new file mode 100644 index 00000000..4982d40e --- /dev/null +++ b/macui/ZeroTier One/ServiceCom.m @@ -0,0 +1,464 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "ServiceCom.h" +#import "AuthtokenCopy.h" +#import "Network.h" +#import "NodeStatus.h" +@import AppKit; + +@interface ServiceCom (Private) + +- (NSString*)key; + +@end + +@implementation ServiceCom + ++ (ServiceCom*)sharedInstance { + static ServiceCom *sc = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sc = [[ServiceCom alloc] init]; + }); + return sc; +} + +- (id)init +{ + self = [super init]; + if(self) { + baseURL = @"http://localhost:9993"; + session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]]; + _isQuitting = NO; + } + + return self; +} + +- (NSString*)key:(NSError* __autoreleasing *)err +{ + static NSString *k = nil; + + if (k == nil) { + NSError *error = nil; + NSURL *appSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:false error:&error]; + + if (error) { + NSLog(@"Error: %@", error); + return @""; + } + + appSupportDir = [[appSupportDir URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"]; + NSURL *authtokenURL = [appSupportDir URLByAppendingPathComponent:@"authtoken.secret"]; + + if ([[NSFileManager defaultManager] fileExistsAtPath:[authtokenURL path]]) { + k = [NSString stringWithContentsOfURL:authtokenURL + encoding:NSUTF8StringEncoding + error:&error]; + + if (error) { + NSLog(@"Error: %@", error); + k = nil; + *err = error; + return @""; + } + } + else { + NSURL *sysAppSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:false error:nil]; + + sysAppSupportDir = [[sysAppSupportDir URLByAppendingPathComponent:@"ZeroTier"] URLByAppendingPathComponent:@"One"]; + NSURL *sysAuthtokenURL = [sysAppSupportDir URLByAppendingPathComponent:@"authtoken.secret"]; + + if(![[NSFileManager defaultManager] fileExistsAtPath:[sysAuthtokenURL path]]) { + + } + + [[NSFileManager defaultManager] createDirectoryAtURL:appSupportDir + withIntermediateDirectories:YES + attributes:nil + error:&error]; + + if (error) { + NSLog(@"Error: %@", error); + *err = error; + k = nil; + return @""; + } + + AuthorizationRef authRef; + OSStatus status = AuthorizationCreate(nil, nil, kAuthorizationFlagDefaults, &authRef); + + if (status != errAuthorizationSuccess) { + NSLog(@"Authorization Failed! %d", status); + + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't create AuthorizationRef", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; + + return @""; + } + + AuthorizationItem authItem; + authItem.name = kAuthorizationRightExecute; + authItem.valueLength = 0; + authItem.flags = 0; + + AuthorizationRights authRights; + authRights.count = 1; + authRights.items = &authItem; + + AuthorizationFlags authFlags = kAuthorizationFlagDefaults | + kAuthorizationFlagInteractionAllowed | + kAuthorizationFlagPreAuthorize | + kAuthorizationFlagExtendRights; + + status = AuthorizationCopyRights(authRef, &authRights, nil, authFlags, nil); + + if (status != errAuthorizationSuccess) { + NSLog(@"Authorization Failed! %d", status); + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Couldn't copy authorization rights", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; + return @""; + } + + NSString *localKey = getAdminAuthToken(authRef); + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + + if (localKey != nil && [localKey lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 0) { + k = localKey; + + [localKey writeToURL:authtokenURL + atomically:YES + encoding:NSUTF8StringEncoding + error:&error]; + + if (error) { + NSLog(@"Error writing token to disk: %@", error); + *err = error; + } + } + } + } + + if (k == nil) { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedString(@"Unknown error finding authorization key", nil), + }; + *err = [NSError errorWithDomain:@"com.zerotier.one" code:-1 userInfo:userInfo]; + + return @""; + } + + return k; +} + +- (void)getNetworklist:(void (^)(NSArray *))completionHandler error:(NSError *__autoreleasing*)error +{ + NSString* key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[baseURL stringByAppendingString:@"/network?auth="] stringByAppendingString:key]; + + NSURL *url = [NSURL URLWithString:urlString]; + NSURLSessionDataTask *task = + [session dataTaskWithURL:url + completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { + + if (err) { + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; + return; + } + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSInteger status = [httpResponse statusCode]; + + NSError *err2; + + if (status == 200) { + NSArray *json = [NSJSONSerialization JSONObjectWithData:data + options:0 + error:&err2]; + if (err) { + NSLog(@"Error fetching network list: %@", err2); + + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err2]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + _isQuitting = YES; + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + } + }]; + return; + } + + NSMutableArray *networks = [[NSMutableArray alloc] init]; + for(NSDictionary *dict in json) { + [networks addObject:[[Network alloc] initWithJsonData:dict]]; + } + + completionHandler(networks); + } + }]; + [task resume]; +} + +- (void)getNodeStatus:(void (^)(NodeStatus*))completionHandler error:(NSError*__autoreleasing*)error +{ + NSString *key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[baseURL stringByAppendingString:@"/status?auth="] stringByAppendingString:key]; + + NSURL *url = [NSURL URLWithString:urlString]; + NSURLSessionDataTask *task = + [session dataTaskWithURL:url + completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { + + if(err) { + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; + return; + } + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSInteger status = [httpResponse statusCode]; + + NSError *err2; + if(status == 200) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data + options:0 + error:&err2]; + + if(err2) { + NSLog(@"Error fetching node status: %@", err2); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err2]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; + return; + } + + NodeStatus *status = [[NodeStatus alloc] initWithJsonData:json]; + + completionHandler(status); + } + }]; + [task resume]; +} + +- (void)joinNetwork:(NSString*)networkId allowManaged:(BOOL)allowManaged allowGlobal:(BOOL)allowGlobal allowDefault:(BOOL)allowDefault error:(NSError *__autoreleasing*)error +{ + NSString *key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] + stringByAppendingString:networkId] + stringByAppendingString:@"?auth="] + stringByAppendingString:key]; + + NSURL *url = [NSURL URLWithString:urlString]; + + NSMutableDictionary *jsonDict = [NSMutableDictionary dictionary]; + [jsonDict setObject:[NSNumber numberWithBool:allowManaged] forKey:@"allowManaged"]; + [jsonDict setObject:[NSNumber numberWithBool:allowGlobal] forKey:@"allowGlobal"]; + [jsonDict setObject:[NSNumber numberWithBool:allowDefault] forKey:@"allowDefault"]; + + NSError *err = nil; + + NSData *json = [NSJSONSerialization dataWithJSONObject:jsonDict + options:0 + error:&err]; + + if(err) { + NSLog(@"Error creating json data: %@", err); + *error = err; + return; + } + + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + request.HTTPMethod = @"POST"; + request.HTTPBody = json; + [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + + NSURLSessionDataTask *task = + [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { + if(err) { + NSLog(@"Error posting join request: %@", err); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; + } + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSInteger status = [httpResponse statusCode]; + + if(status == 200) { + NSLog(@"join ok"); + } + else { + NSLog(@"join error: %ld", (long)status); + } + }]; + [task resume]; +} + +- (void)leaveNetwork:(NSString*)networkId error:(NSError*__autoreleasing*)error +{ + NSString *key = [self key:error]; + if(*error) { + return; + } + + NSString *urlString = [[[[baseURL stringByAppendingString:@"/network/"] + stringByAppendingString:networkId] + stringByAppendingString:@"?auth="] + stringByAppendingString:key]; + + NSURL *url = [NSURL URLWithString:urlString]; + + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + request.HTTPMethod = @"DELETE"; + + NSURLSessionDataTask *task = + [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable err) { + if(err) { + NSLog(@"Error posting delete request: %@", err); + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + NSAlert *alert = [NSAlert alertWithError:err]; + alert.alertStyle = NSCriticalAlertStyle; + [alert addButtonWithTitle:@"Quit"]; + [alert addButtonWithTitle:@"Retry"]; + + NSModalResponse res; + if (!_isQuitting) { + res = [alert runModal]; + } + else { + return; + } + + if(res == NSAlertFirstButtonReturn) { + [NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0]; + _isQuitting = YES; + } + }]; + return; + } + + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response; + NSInteger status = httpResponse.statusCode; + + if(status == 200) { + NSLog(@"leave ok"); + } + else { + NSLog(@"leave error: %ld", status); + } + }]; + [task resume]; +} + +@end diff --git a/macui/ZeroTier One/ShowNetworksViewController.h b/macui/ZeroTier One/ShowNetworksViewController.h new file mode 100644 index 00000000..5c251674 --- /dev/null +++ b/macui/ZeroTier One/ShowNetworksViewController.h @@ -0,0 +1,36 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +@class NetworkMonitor; +@class Network; + +@interface ShowNetworksViewController : NSViewController + +@property (nonatomic) NSArray *networkList; +@property (nonatomic) NetworkMonitor *netMonitor; +@property (nonatomic) BOOL visible; + +@property (weak, nonatomic) IBOutlet NSTableView *tableView; + +- (void)deleteNetworkFromList:(NSString*)nwid; +- (void)setNetworks:(NSArray*)list; + + +@end diff --git a/macui/ZeroTier One/ShowNetworksViewController.m b/macui/ZeroTier One/ShowNetworksViewController.m new file mode 100644 index 00000000..e3a1e52c --- /dev/null +++ b/macui/ZeroTier One/ShowNetworksViewController.m @@ -0,0 +1,119 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import "ShowNetworksViewController.h" +#import "NetworkMonitor.h" +#import "NetworkInfoCell.h" +#import "Network.h" + +@interface ShowNetworksViewController () + +@end + +@implementation ShowNetworksViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self.tableView setDelegate:self]; + [self.tableView setDataSource:self]; + [self.tableView setBackgroundColor:[NSColor clearColor]]; +} + +- (void)viewWillAppear { + [super viewWillAppear]; + self.visible = YES; +} + +- (void)viewWillDisappear { + [super viewWillDisappear]; + self.visible = NO; +} + +- (void)deleteNetworkFromList:(NSString *)nwid { + [self.netMonitor deleteSavedNetwork:nwid]; +} + +- (void)setNetworks:(NSArray *)list { + _networkList = list; + if(_visible) { + [_tableView reloadData]; + } +} + +- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { + return [_networkList count]; +} + +- (NSView*)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row +{ + NetworkInfoCell *cell = (NetworkInfoCell*)[tableView makeViewWithIdentifier:@"NetworkInfoCell" + owner:nil]; + Network *network = [_networkList objectAtIndex:row]; + cell.parent = self; + cell.networkIdField.stringValue = [NSString stringWithFormat:@"%10llx", network.nwid]; + cell.networkNameField.stringValue = network.name; + cell.statusField.stringValue = [network statusString]; + cell.typeField.stringValue = [network typeString]; + cell.mtuField.stringValue = [NSString stringWithFormat:@"%d", network.mtu]; + cell.macField.stringValue = network.mac; + cell.broadcastField.stringValue = network.broadcastEnabled ? @"ENABLED" : @"DISABLED"; + cell.bridgingField.stringValue = network.bridge ? @"ENABLED" : @"DISABLED"; + cell.deviceField.stringValue = network.portDeviceName; + + if(network.connected) { + cell.connectedCheckbox.state = NSOnState; + + if(network.allowDefault) { + cell.allowDefault.enabled = YES; + cell.allowDefault.state = NSOnState; + } + else { + cell.allowDefault.state = NSOffState; + + if([Network defaultRouteExists:_networkList]) { + cell.allowDefault.enabled = NO; + } + else { + cell.allowDefault.enabled = YES; + } + } + + cell.allowGlobal.enabled = YES; + cell.allowManaged.enabled = YES; + } + else { + cell.connectedCheckbox.state = NSOffState; + cell.allowDefault.enabled = NO; + cell.allowGlobal.enabled = NO; + cell.allowManaged.enabled = NO; + } + + cell.allowGlobal.state = network.allowGlobal ? NSOnState : NSOffState; + cell.allowManaged.state = network.allowManaged ? NSOnState : NSOffState; + + cell.addressesField.stringValue = @""; + + for(NSString *addr in network.assignedAddresses) { + cell.addressesField.stringValue = [[cell.addressesField.stringValue stringByAppendingString:addr] stringByAppendingString:@"\n"]; + } + + return cell; +} + +@end diff --git a/macui/ZeroTier One/ShowNetworksViewController.xib b/macui/ZeroTier One/ShowNetworksViewController.xib new file mode 100644 index 00000000..f26cb446 --- /dev/null +++ b/macui/ZeroTier One/ShowNetworksViewController.xib @@ -0,0 +1,370 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macui/ZeroTier One/ZeroTierIcon.icns b/macui/ZeroTier One/ZeroTierIcon.icns new file mode 100644 index 00000000..17e60d58 Binary files /dev/null and b/macui/ZeroTier One/ZeroTierIcon.icns differ diff --git a/macui/ZeroTier One/about.html b/macui/ZeroTier One/about.html new file mode 100644 index 00000000..4fa41d7b --- /dev/null +++ b/macui/ZeroTier One/about.html @@ -0,0 +1,65 @@ + + + + + + +
+
+
+
+
+ +
+

Getting Started

+ +

Getting started is simple. Simply click Join Network from the ZeroTier status bar menu. To join the public network "Earth", enter 8056c2e21c000001 and click the Join button. Once connected, you'll be able to navigate to earth.zerotier.net.

+ +

Create a Network

+

Visit my.zerotier.com to create and manage your own virtual networks.

+ +

For more information, visit zerotier.com.

+ +
+ + \ No newline at end of file diff --git a/macui/ZeroTier One/main.m b/macui/ZeroTier One/main.m new file mode 100644 index 00000000..108a6bd1 --- /dev/null +++ b/macui/ZeroTier One/main.m @@ -0,0 +1,23 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} -- cgit v1.2.3