mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-21 18:06:39 +00:00
Renaming...
This commit is contained in:
parent
ba7809367a
commit
ecb1ee8e0d
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
|
||||||
function ZT1Client(url,authToken)
|
function ZT1ApiClient(url,authToken)
|
||||||
{
|
{
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.authToken = authToken;
|
this.authToken = authToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate new ZeroTier identity -- mostly for testing
|
// Generate new ZeroTier identity -- mostly for testing
|
||||||
ZT1Client.prototype.newIdentity = function(callback)
|
ZT1ApiClient.prototype.newIdentity = function(callback)
|
||||||
{
|
{
|
||||||
request({
|
request({
|
||||||
url: this.url + 'newIdentity',
|
url: this.url + 'newIdentity',
|
||||||
@ -27,7 +27,7 @@ ZT1Client.prototype.newIdentity = function(callback)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ZT1Client.prototype._jsonGet = function(getPath,callback)
|
ZT1ApiClient.prototype._jsonGet = function(getPath,callback)
|
||||||
{
|
{
|
||||||
request({
|
request({
|
||||||
url: this.url + getPath,
|
url: this.url + getPath,
|
||||||
@ -44,7 +44,7 @@ ZT1Client.prototype._jsonGet = function(getPath,callback)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.status = function(callback)
|
ZT1ApiClient.prototype.status = function(callback)
|
||||||
{
|
{
|
||||||
request({
|
request({
|
||||||
url: this.url + 'controller',
|
url: this.url + 'controller',
|
||||||
@ -77,27 +77,27 @@ ZT1Client.prototype.status = function(callback)
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.getNetworks = function(callback)
|
ZT1ApiClient.prototype.getNetworks = function(callback)
|
||||||
{
|
{
|
||||||
this._jsonGet('network',callback);
|
this._jsonGet('network',callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.getPeers = function(callback)
|
ZT1ApiClient.prototype.getPeers = function(callback)
|
||||||
{
|
{
|
||||||
this._jsonGet('peer',callback);
|
this._jsonGet('peer',callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.listControllerNetworks = function(callback)
|
ZT1ApiClient.prototype.listControllerNetworks = function(callback)
|
||||||
{
|
{
|
||||||
this._jsonGet('controller/network',callback);
|
this._jsonGet('controller/network',callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.getControllerNetwork = function(nwid,callback)
|
ZT1ApiClient.prototype.getControllerNetwork = function(nwid,callback)
|
||||||
{
|
{
|
||||||
this._jsonGet('controller/network/' + nwid,callback);
|
this._jsonGet('controller/network/' + nwid,callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.saveControllerNetwork = function(network,callback)
|
ZT1ApiClient.prototype.saveControllerNetwork = function(network,callback)
|
||||||
{
|
{
|
||||||
if ((typeof network.nwid !== 'string')||(network.nwid.length !== 16))
|
if ((typeof network.nwid !== 'string')||(network.nwid.length !== 16))
|
||||||
return callback(new Error('Missing required field: nwid'),null);
|
return callback(new Error('Missing required field: nwid'),null);
|
||||||
@ -153,8 +153,8 @@ ZT1Client.prototype.saveControllerNetwork = function(network,callback)
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ZT1Client.prototype.getControllerNetworkMember = function(nwid,address,callback) {
|
ZT1ApiClient.prototype.getControllerNetworkMember = function(nwid,address,callback) {
|
||||||
this._jsonGet('controller/network/' + nwid + '/member/' + address,callback);
|
this._jsonGet('controller/network/' + nwid + '/member/' + address,callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.ZT1Client = ZT1Client;
|
exports.ZT1ApiClient = ZT1ApiClient;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "nodejs-zt1-client",
|
"name": "zt1-api-client",
|
||||||
"version": "1.0.0",
|
"version": "0.0.1",
|
||||||
"description": "ZeroTier One Network Virtualization Service JSON API Client",
|
"description": "ZeroTier One JSON API Client",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
var ZT1Client = require('./index.js').ZT1Client;
|
var ZT1ApiClient = require('./index.js').ZT1ApiClient;
|
||||||
|
|
||||||
var zt1c = new ZT1Client('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed');
|
var zt1 = new ZT1ApiClient('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed');
|
||||||
|
|
||||||
zt1c.status(function(err,status) {
|
zt1.status(function(err,status) {
|
||||||
if (err)
|
if (err)
|
||||||
console.log(err);
|
console.log(err);
|
||||||
else console.log(status);
|
else console.log(status);
|
||||||
|
|
||||||
zt1c.getNetworks(function(err,networks) {
|
zt1.getNetworks(function(err,networks) {
|
||||||
if (err)
|
if (err)
|
||||||
console.log(err);
|
console.log(err);
|
||||||
else console.log(networks);
|
else console.log(networks);
|
||||||
|
|
||||||
zt1c.getPeers(function(err,peers) {
|
zt1.getPeers(function(err,peers) {
|
||||||
if (err)
|
if (err)
|
||||||
console.log(err);
|
console.log(err);
|
||||||
else console.log(peers);
|
else console.log(peers);
|
||||||
|
|
||||||
if (status.controller) {
|
if (status.controller) {
|
||||||
zt1c.saveControllerNetwork({
|
zt1.saveControllerNetwork({
|
||||||
nwid: status.address + 'dead01',
|
nwid: status.address + 'dead01',
|
||||||
name: 'test network',
|
name: 'test network',
|
||||||
private: true
|
private: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user