From 220552af62cb229d70a62851a35c6b38a0bc3345 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 16 Nov 2015 14:30:25 -0800 Subject: GitHub issue #241 -- and also some appearance updates. Eventually this might get replaced by a native Mac app. --- .../bin/ZeroTier One.app/Contents/Info.plist | 21 +- .../ZeroTier One.app/Contents/MacOS/ZeroTier One | Bin 194640 -> 152736 bytes .../Contents/Resources/en.lproj/MainMenu.nib | Bin 25733 -> 25269 bytes .../Contents/Resources/en.lproj/Window.nib | Bin 3785 -> 3723 bytes .../Contents/_CodeSignature/CodeResources | 8 +- .../src/MacGap.xcodeproj/project.pbxproj | 7 +- .../src/MacGap/AppDelegate.m | 28 +- .../src/MacGap/Classes/ContentView.m | 10 +- .../src/MacGap/MacGap-Info.plist | 11 +- .../src/MacGap/en.lproj/Window.xib | 381 +++------------------ ui/ZeroTierNetwork.jsx | 24 +- ui/ZeroTierNode.jsx | 74 +--- ui/zerotier.css | 98 +----- ui/ztui.min.js | 2 +- 14 files changed, 129 insertions(+), 535 deletions(-) diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Info.plist b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Info.plist index a11af6d9..c67923c7 100644 --- a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Info.plist +++ b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 14E46 + 15B42 CFBundleDevelopmentRegion en CFBundleExecutable @@ -22,26 +22,35 @@ 1.0 CFBundleSignature ???? + CFBundleSupportedPlatforms + + MacOSX + CFBundleVersion 1 DTCompiler com.apple.compilers.llvm.clang.1_0 DTPlatformBuild - 6E35b + 7B1005 DTPlatformVersion GM DTSDKBuild - 14D125 + 15A278 DTSDKName - macosx10.10 + macosx10.11 DTXcode - 0640 + 0711 DTXcodeBuild - 6E35b + 7B1005 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion 10.7 + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSMainNibFile MainMenu NSPrincipalClass diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One index 429efc0b..ba15bca9 100755 Binary files a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One and b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One differ diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/MainMenu.nib b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/MainMenu.nib index 4cd319b2..bac7faa7 100644 Binary files a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/MainMenu.nib and b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/MainMenu.nib differ diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib index 559409d9..69258da6 100644 Binary files a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib and b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib differ diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources index bd79b1f3..14556923 100644 --- a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources +++ b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources @@ -30,7 +30,7 @@ hash - kkFJZm0JXF9gTUF2keyMJQ9p9SY= + 8JZXf4/3df3LD+o74Y8WM0dV8io= optional @@ -39,7 +39,7 @@ hash - 42zB9+COYMmPW0WlnU1juN2B9SA= + 7dgumnPDtoIzhi9QoaFhDvCo9ys= optional @@ -73,7 +73,7 @@ hash - kkFJZm0JXF9gTUF2keyMJQ9p9SY= + 8JZXf4/3df3LD+o74Y8WM0dV8io= optional @@ -82,7 +82,7 @@ hash - 42zB9+COYMmPW0WlnU1juN2B9SA= + 7dgumnPDtoIzhi9QoaFhDvCo9ys= optional diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj b/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj index 08d72d06..775c5964 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.pbxproj @@ -269,7 +269,7 @@ FAE451B114BA79C600190544 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = Twitter; }; buildConfigurationList = FAE451B414BA79C600190544 /* Build configuration list for PBXProject "MacGap" */; @@ -374,9 +374,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -402,7 +402,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -434,6 +433,7 @@ GCC_VERSION = ""; INFOPLIST_FILE = "MacGap/MacGap-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "ZeroTier One"; SDKROOT = macosx; WRAPPER_EXTENSION = app; @@ -455,6 +455,7 @@ GCC_VERSION = ""; INFOPLIST_FILE = "MacGap/MacGap-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "com.zerotier.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "ZeroTier One"; SDKROOT = macosx; WRAPPER_EXTENSION = app; diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m b/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m index 3e25ca13..45923bb3 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/AppDelegate.m @@ -32,6 +32,7 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { char buf[16384],userAuthTokenPath[4096]; + struct stat systemAuthTokenStat,userAuthTokenStat; FILE *pf = fopen("/Library/Application Support/ZeroTier/One/zerotier-one.port","r"); long port = 9993; // default @@ -50,14 +51,27 @@ const char *homeDir = getenv("HOME"); if (homeDir) { snprintf(userAuthTokenPath,sizeof(userAuthTokenPath),"%s/Library/Application Support/ZeroTier/One/authtoken.secret",homeDir); - pf = fopen(userAuthTokenPath,"r"); - if (pf) { - long n = fread(buf,1,sizeof(buf)-1,pf); - if (n > 0) { - buf[n] = (char)0; - snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf); + + bool userAuthTokenOutOfDate = false; + memset(&systemAuthTokenStat,0,sizeof(systemAuthTokenStat)); + memset(&userAuthTokenStat,0,sizeof(userAuthTokenStat)); + if (stat("/Library/Application Support/ZeroTier/One/authtoken.secret",&systemAuthTokenStat) == 0) { + if (stat(userAuthTokenPath,&userAuthTokenStat) == 0) { + if (userAuthTokenStat.st_mtimespec.tv_sec < systemAuthTokenStat.st_mtimespec.tv_sec) + userAuthTokenOutOfDate = true; + } + } + + if (!userAuthTokenOutOfDate) { + pf = fopen(userAuthTokenPath,"r"); + if (pf) { + long n = fread(buf,1,sizeof(buf)-1,pf); + if (n > 0) { + buf[n] = (char)0; + snprintf(url,sizeof(url),"http://127.0.0.1:%ld/index.html?authToken=%s",port,buf); + } + fclose(pf); } - fclose(pf); } } diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m b/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m index 24e58cd1..6558a191 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/Classes/ContentView.m @@ -39,11 +39,11 @@ [self.webView setApplicationNameForUserAgent: @"MacGap"]; self.delegate = [[WebViewDelegate alloc] initWithMenu:[NSApp mainMenu]]; - [self.webView setFrameLoadDelegate:self.delegate]; - [self.webView setUIDelegate:self.delegate]; - [self.webView setResourceLoadDelegate:self.delegate]; - [self.webView setDownloadDelegate:self.delegate]; - [self.webView setPolicyDelegate:self.delegate]; +// [self.webView setFrameLoadDelegate:self.delegate]; +// [self.webView setUIDelegate:self.delegate]; +// [self.webView setResourceLoadDelegate:self.delegate]; +// [self.webView setDownloadDelegate:self.delegate]; +// [self.webView setPolicyDelegate:self.delegate]; [self.webView setDrawsBackground:NO]; [self.webView setShouldCloseWithWindow:NO]; diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist b/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist index 7e10a7a6..7f71ea22 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/MacGap-Info.plist @@ -2,14 +2,14 @@ - CFBundleIconFile - ZeroTierIcon CFBundleDevelopmentRegion en CFBundleExecutable ZeroTier One + CFBundleIconFile + ZeroTierIcon CFBundleIdentifier - com.zerotier.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -30,5 +30,10 @@ MainMenu NSPrincipalClass NSApplication + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib index 70d0c57b..2c46b79f 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib @@ -1,337 +1,44 @@ - - - - 1070 - 11C74 - 1938 - 1138.23 - 567.00 - - YES - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - YES - 1938 - 822 - - - - YES - NSWindowTemplate - NSView - NSCustomObject - WebView - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - PluginDependencyRecalculationVersion - - - - YES - - WindowController - - - FirstResponder - - - NSApplication - - - 15 - 2 - {{196, 240}, {758, 410}} - 544735232 - Window - NSWindow - - - - - 256 - - YES - - - 274 - - YES - - YES - Apple HTML pasteboard type - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple URL pasteboard type - Apple Web Archive pasteboard type - NSColor pasteboard type - NSFilenamesPboardType - NSStringPboardType - NeXT RTFD pasteboard type - NeXT Rich Text Format v1.0 pasteboard type - NeXT TIFF v4.0 pasteboard type - WebURLsWithTitlesPboardType - public.png - public.url - public.url-name - - - {758, 410} - - - - 2 - _NS:51 - - - - - - YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - - - YES - - - - - - - YES - YES - - - {758, 410} - - - - - {{0, 0}, {1920, 1178}} - {10000000000000, 10000000000000} - 128 - YES - - - - - YES - - - contentView - - - - 23 - - - - window - - - - 25 - - - - title: contentView.webView.mainFrameTitle - - - - - - title: contentView.webView.mainFrameTitle - title - contentView.webView.mainFrameTitle - 2 - - - 31 - - - - webView - - - - 19 - - - - - YES - - 0 - - YES - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - YES - - - - - - 2 - - - YES - - - - - - 5 - - - - - - - YES - - YES - -1.IBPluginDependency - -2.IBPluginDependency - -3.IBPluginDependency - 1.IBPluginDependency - 1.IBWindowTemplateEditedContentRect - 1.NSWindowTemplate.visibleAtLaunch - 2.CustomClassName - 2.IBPluginDependency - 5.IBPluginDependency - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{357, 418}, {480, 270}} - - ContentView - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.WebKitIBPlugin - - - - YES - - - - - - YES - - - - - 31 - - - - YES - - ContentView - NSView - - webView - WebView - - - webView - - webView - WebView - - - - IBProjectSource - ./Classes/ContentView.h - - - - WebView - - reloadFromOrigin: - id - - - reloadFromOrigin: - - reloadFromOrigin: - id - - - - IBProjectSource - ./Classes/WebView.h - - - - WindowController - NSWindowController - - contentView - ContentView - - - contentView - - contentView - ContentView - - - - IBProjectSource - ./Classes/WindowController.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - 3 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/ZeroTierNetwork.jsx b/ui/ZeroTierNetwork.jsx index 4b37d888..f842d758 100644 --- a/ui/ZeroTierNetwork.jsx +++ b/ui/ZeroTierNetwork.jsx @@ -4,19 +4,17 @@ var ZeroTierNetwork = React.createClass({ }, leaveNetwork: function(event) { - if (confirm("Are you sure you want to leave this network?")) { - Ajax.call({ - url: 'network/'+this.props.nwid+'?auth='+this.props.authToken, - cache: false, - type: 'DELETE', - success: function(data) { - if (this.props.onNetworkDeleted) - this.props.onNetworkDeleted(this.props.nwid); - }.bind(this), - error: function(error) { - }.bind(this) - }); - } + Ajax.call({ + url: 'network/'+this.props.nwid+'?auth='+this.props.authToken, + cache: false, + type: 'DELETE', + success: function(data) { + if (this.props.onNetworkDeleted) + this.props.onNetworkDeleted(this.props.nwid); + }.bind(this), + error: function(error) { + }.bind(this) + }); event.preventDefault(); }, diff --git a/ui/ZeroTierNode.jsx b/ui/ZeroTierNode.jsx index 49d73460..b4c29220 100644 --- a/ui/ZeroTierNode.jsx +++ b/ui/ZeroTierNode.jsx @@ -122,7 +122,6 @@ var ZeroTierNode = React.createClass({ }, componentDidMount: function() { - this.tabIndex = 0; this.updateAll(); this.updateIntervalId = setInterval(this.updateAll,2500); }, @@ -130,74 +129,19 @@ var ZeroTierNode = React.createClass({ clearInterval(this.updateIntervalId); }, render: function() { - /* We implement tabs in a very simple way here with a React JSX conditional. The tabIndex - * local variable indicates the tab, and switching it determines which set of things we - * render in the main middle portion. On tab switch calls forceUpdate(). */ return (
-
   - - -
- { - (this.tabIndex === 1) ? ( -
-
-
Address
-
Version
-
Latency
-
Data Paths
-
Last Unicast
-
Last Multicast
-
Role
-
- { - this.state._peers.map(function(peer) { - return ( -
-
{peer['address']}
-
{(peer['version'] === '-1.-1.-1') ? '-' : peer['version']}
-
{peer['latency']}
-
- { - (peer['paths'].length === 0) ? ( -
- ) : ( -
- { - peer['paths'].map(function(path) { - var cn = ((path.active)||(path.fixed)) ? (path.preferred ? 'peerPathPreferred' : 'peerPathActive') : 'peerPathInactive'; - return ( -
{path.address}  {this.ago(path.lastSend)}/{this.ago(path.lastReceive)}
- ); - }.bind(this)) - } -
- ) - } -
-
{this.ago(peer['lastUnicastFrame'])}
-
{this.ago(peer['lastMulticastFrame'])}
-
{peer['role']}
-
- ); - }.bind(this)) - } -
- ) : ( -
- { - this.state._networks.map(function(network) { - network['authToken'] = this.props.authToken; - network['onNetworkDeleted'] = this.handleNetworkDelete; - return React.createElement('div',{className: 'network',key: network.nwid},React.createElement(ZeroTierNetwork,network)); - }.bind(this)) - } -
- ) - } +
+ { + this.state._networks.map(function(network) { + network['authToken'] = this.props.authToken; + network['onNetworkDeleted'] = this.handleNetworkDelete; + return React.createElement('div',{className: 'network',key: network.nwid},React.createElement(ZeroTierNetwork,network)); + }.bind(this)) + } +
diff --git a/ui/zerotier.css b/ui/zerotier.css index cde5cea8..e5c58838 100644 --- a/ui/zerotier.css +++ b/ui/zerotier.css @@ -25,34 +25,6 @@ html,body { display: table; } -.zeroTierNode > .top { - width: 100%; - overflow: hidden; - display: table-row; - white-space: nowrap; - background: #234447; - color: #ffffff; - padding: 0; - margin: 0; -} -.zeroTierNode > .top button { - display: inline-block; - padding: 0.25rem 0.75rem 0.25rem 0.75rem; - color: #ffffff; - margin: 0; - border: 0; - outline: none; - background: #234447; - font-size: 12pt; - cursor: pointer; -} -.zeroTierNode > .top button:hover { - background: #91a2a3; -} -.zeroTierNode > .top button:disabled { - background: #91a2a3; -} - .zeroTierNode > .middle { width: 100%; height: 100%; @@ -65,6 +37,7 @@ html,body { width: 100%; height: 100%; display: table-cell; + border-bottom: 1px solid #000000; } .zeroTierNode > .middle > .middleCell > .middleScroll { display: block; @@ -87,76 +60,19 @@ html,body { border-collapse: collapse; } .zeroTierNode > .middle > .middleCell > .middleScroll > .networks > .network { - display: inline-block; + display: block; + border-top: 0.12rem solid #dddddd; + border-bottom: 0.12rem solid #dddddd; padding: 0.25rem; - margin: 0.25rem 0 0 1%; - min-width: 31%; - max-width: 98%; - border: 1px solid #234447; - background: #ffffff; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers { - display: table; - width: 100%; - margin: 0; - border-collapse: collapse; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer { - width: 100%; - display: table-row; background: #ffffff; } -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer:nth-child(odd) { - background: #f3f3f3; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer:nth-child(even) { -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer .peerPathActive { - font-size: 8pt; - color: #555555; - font-style: italic; - font-family: monospace; - white-space: nowrap; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer .peerPathPreferred { - font-size: 8pt; - color: #000000; - font-family: monospace; - white-space: nowrap; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer .peerPathInactive { - font-size: 8pt; - font-family: monospace; - color: #aaaaaa; - font-style: italic; - text-decoration: line-through; - white-space: nowrap; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peer > .f { - display: table-cell; - padding: 0.05rem 0.15rem 0.05rem 0.15rem; - font-size: 8pt; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peerHeader { - width: 100%; - font-size: 8pt; - display: table-row; - background: #ffffff; - border-bottom: 1px solid #000000; -} -.zeroTierNode > .middle > .middleCell > .middleScroll > .peers > .peerHeader > .f { - display: table-cell; - font-size: 8pt; - padding: 0.05rem 0.15rem 0.05rem 0.15rem; - font-weight: bold; -} .zeroTierNode > .bottom { font-size: 12pt; width: 100%; overflow: hidden; display: table-row; - background: #234447; + background: #000000; color: #ffffff; } .zeroTierNode > .bottom > .left { @@ -233,7 +149,7 @@ html,body { .zeroTierNetwork .networkInfo .networkId { font-size: 11pt; font-family: monospace; - color: #91a2a3; + color: #000000; } .zeroTierNetwork .networkInfo .networkName { padding: 0 0 0 1rem; @@ -271,7 +187,7 @@ html,body { .zeroTierNetwork .leaveNetworkButton { padding: 0.25rem 0.5rem 0.25rem 0.5rem; margin: 0.25rem 0 0 0; - font-size: 10pt; + font-size: 9pt; background: #ffffff; outline: none; background: #ffb354; diff --git a/ui/ztui.min.js b/ui/ztui.min.js index dbde7734..17982839 100644 --- a/ui/ztui.min.js +++ b/ui/ztui.min.js @@ -1 +1 @@ -var ZeroTierNetwork=React.createClass({displayName:"ZeroTierNetwork",getInitialState:function(){return{}},leaveNetwork:function(e){confirm("Are you sure you want to leave this network?")&&Ajax.call({url:"network/"+this.props.nwid+"?auth="+this.props.authToken,cache:!1,type:"DELETE",success:function(e){this.props.onNetworkDeleted&&this.props.onNetworkDeleted(this.props.nwid)}.bind(this),error:function(e){}.bind(this)}),e.preventDefault()},render:function(){return React.createElement("div",{className:"zeroTierNetwork"},React.createElement("div",{className:"networkInfo"},React.createElement("span",{className:"networkId"},this.props.nwid)," ",React.createElement("span",{className:"networkName"},this.props.name)),React.createElement("div",{className:"networkProps"},React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Status"),React.createElement("div",{className:"value"},this.props.status)),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Type"),React.createElement("div",{className:"value"},this.props.type)),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"MAC"),React.createElement("div",{className:"value zeroTierAddress"},this.props.mac)),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"MTU"),React.createElement("div",{className:"value"},this.props.mtu)),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Broadcast"),React.createElement("div",{className:"value"},this.props.broadcastEnabled?"ENABLED":"DISABLED")),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Bridging"),React.createElement("div",{className:"value"},this.props.bridge?"ACTIVE":"DISABLED")),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Device"),React.createElement("div",{className:"value"},this.props.portDeviceName?this.props.portDeviceName:"(none)")),React.createElement("div",{className:"row"},React.createElement("div",{className:"name"},"Managed IPs"),React.createElement("div",{className:"value ipList"},this.props.assignedAddresses.map(function(e){return React.createElement("div",{key:e,className:"ipAddress"},e)})))),React.createElement("button",{type:"button",className:"leaveNetworkButton",onClick:this.leaveNetwork},"Leave Network"))}}); var ZeroTierNode=React.createClass({displayName:"ZeroTierNode",getInitialState:function(){return{address:"----------",online:!1,version:"_._._",_networks:[],_peers:[]}},ago:function(e){if(e>0){var t=Math.round((Date.now()-e)/1e3);return t>0?t:0}return 0},updatePeers:function(){Ajax.call({url:"peer?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(e){var t=JSON.parse(e);Array.isArray(t)&&this.setState({_peers:t})}}.bind(this),error:function(){}.bind(this)})},updateNetworks:function(){Ajax.call({url:"network?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(e){var t=JSON.parse(e);Array.isArray(t)&&this.setState({_networks:t})}}.bind(this),error:function(){}.bind(this)})},updateAll:function(){Ajax.call({url:"status?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(this.alertedToFailure=!1,e){var t=JSON.parse(e);this.setState(t),document.title="ZeroTier One ["+t.address+"]"}this.updateNetworks(),this.updatePeers()}.bind(this),error:function(){this.setState(this.getInitialState()),this.alertedToFailure||(this.alertedToFailure=!0,alert("Authorization token invalid or ZeroTier One service not running."))}.bind(this)})},joinNetwork:function(e){e.preventDefault(),this.networkToJoin&&16===this.networkToJoin.length?Ajax.call({url:"network/"+this.networkToJoin+"?auth="+this.props.authToken,cache:!1,type:"POST",success:function(e){this.networkToJoin="",this.networkInputElement&&(this.networkInputElement.value=""),this.updateNetworks()}.bind(this),error:function(){}.bind(this)}):alert("To join a network, enter its 16-digit network ID.")},handleNetworkIdEntry:function(e){this.networkInputElement=e.target;var t=this.networkInputElement.value;if(t){t=t.toLowerCase();for(var a="",s=0;ss;++s)"0123456789abcdef".indexOf(t.charAt(s))>=0&&(a+=t.charAt(s));this.networkToJoin=a,this.networkInputElement.value=a}else this.networkToJoin="",this.networkInputElement.value=""},handleNetworkDelete:function(e){for(var t=[],a=0;a0){var t=Math.round((Date.now()-e)/1e3);return t>0?t:0}return 0},updatePeers:function(){Ajax.call({url:"peer?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(e){var t=JSON.parse(e);Array.isArray(t)&&this.setState({_peers:t})}}.bind(this),error:function(){}.bind(this)})},updateNetworks:function(){Ajax.call({url:"network?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(e){var t=JSON.parse(e);Array.isArray(t)&&this.setState({_networks:t})}}.bind(this),error:function(){}.bind(this)})},updateAll:function(){Ajax.call({url:"status?auth="+this.props.authToken,cache:!1,type:"GET",success:function(e){if(this.alertedToFailure=!1,e){var t=JSON.parse(e);this.setState(t),document.title="ZeroTier One ["+t.address+"]"}this.updateNetworks(),this.updatePeers()}.bind(this),error:function(){this.setState(this.getInitialState()),this.alertedToFailure||(this.alertedToFailure=!0,alert("Authorization token invalid or ZeroTier One service not running."))}.bind(this)})},joinNetwork:function(e){e.preventDefault(),this.networkToJoin&&16===this.networkToJoin.length?Ajax.call({url:"network/"+this.networkToJoin+"?auth="+this.props.authToken,cache:!1,type:"POST",success:function(e){this.networkToJoin="",this.networkInputElement&&(this.networkInputElement.value=""),this.updateNetworks()}.bind(this),error:function(){}.bind(this)}):alert("To join a network, enter its 16-digit network ID.")},handleNetworkIdEntry:function(e){this.networkInputElement=e.target;var t=this.networkInputElement.value;if(t){t=t.toLowerCase();for(var n="",a=0;aa;++a)"0123456789abcdef".indexOf(t.charAt(a))>=0&&(n+=t.charAt(a));this.networkToJoin=n,this.networkInputElement.value=n}else this.networkToJoin="",this.networkInputElement.value=""},handleNetworkDelete:function(e){for(var t=[],n=0;n