var ZeroTierNode = React.createClass({ getInitialState: function() { return { address: '----------', online: false, version: '_._._', _networks: [], _peers: [] }; }, ago: function(ms) { if (ms > 0) { var tmp = Math.round((Date.now() - ms) / 1000); return ((tmp > 0) ? tmp : 0); } else return 0; }, updatePeers: function() { Ajax.call({ url: 'peer?auth='+this.props.authToken, cache: false, type: 'GET', success: function(data) { if (data) { var pl = JSON.parse(data); if (Array.isArray(pl)) { this.setState({_peers: pl}); } } }.bind(this), error: function() { }.bind(this) }); }, updateNetworks: function() { Ajax.call({ url: 'network?auth='+this.props.authToken, cache: false, type: 'GET', success: function(data) { if (data) { var nwl = JSON.parse(data); if (Array.isArray(nwl)) { this.setState({_networks: nwl}); } } }.bind(this), error: function() { }.bind(this) }); }, updateAll: function() { Ajax.call({ url: 'status?auth='+this.props.authToken, cache: false, type: 'GET', success: function(data) { this.alertedToFailure = false; if (data) { var status = JSON.parse(data); this.setState(status); document.title = 'ZeroTier One [' + status.address + ']'; } this.updateNetworks(); this.updatePeers(); }.bind(this), error: function() { this.setState(this.getInitialState()); if (!this.alertedToFailure) { this.alertedToFailure = true; alert('Authorization token invalid or ZeroTier One service not running.'); } }.bind(this) }); }, joinNetwork: function(event) { event.preventDefault(); if ((this.networkToJoin)&&(this.networkToJoin.length === 16)) { Ajax.call({ url: 'network/'+this.networkToJoin+'?auth='+this.props.authToken, cache: false, type: 'POST', success: function(data) { this.networkToJoin = ''; if (this.networkInputElement) this.networkInputElement.value = ''; this.updateNetworks(); }.bind(this), error: function() { }.bind(this) }); } else { alert('To join a network, enter its 16-digit network ID.'); } }, handleNetworkIdEntry: function(event) { this.networkInputElement = event.target; var nid = event.target.value; if (nid) { nid = nid.toLowerCase(); var nnid = ''; for(var i=0;((i= 0) nnid += nid.charAt(i); } this.networkToJoin = nnid; event.target.value = nnid; } else { this.networkToJoin = ''; event.target.value = ''; } }, handleNetworkDelete: function(nwid) { var networks = []; for(var i=0;i
  
⏁ 
{ (this.tabIndex === 1) ? (
Address
Version
Latency
Data Paths
Last Frame
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'])}
{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'},React.createElement(ZeroTierNetwork,network)); }.bind(this)) }
) }
{this.state.address}  {this.state.online ? 'ONLINE' : 'OFFLINE'}  {this.state.version}
); } });