mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 05:43:59 -07:00
Fixes to control plane, API, eliminate problematic inheritance pattern, and start on a NodeJS class for talking to the network controller.
This commit is contained in:
parent
27c5f04d68
commit
a187d290f1
11 changed files with 109 additions and 143 deletions
26
controller/zt1-controller-client/index.js
Normal file
26
controller/zt1-controller-client/index.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict'
|
||||
|
||||
var request = require('request');
|
||||
|
||||
function ZT1ControllerClient(url,authToken)
|
||||
{
|
||||
this.url = url;
|
||||
this.authToken = authToken;
|
||||
}
|
||||
|
||||
ZT1ControllerClient.prototype.status = function(callback)
|
||||
{
|
||||
request({
|
||||
url: this.url + 'controller',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-ZT1-Auth': this.authToken
|
||||
}
|
||||
},function(error,response,body) {
|
||||
if ((error)||(response.statusCode !== 200))
|
||||
return callback(error,{});
|
||||
return callback(null,JSON.parse(body));
|
||||
});
|
||||
};
|
||||
|
||||
exports.ZT1ControllerClient = ZT1ControllerClient;
|
14
controller/zt1-controller-client/package.json
Normal file
14
controller/zt1-controller-client/package.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "zt1-controller-client",
|
||||
"version": "1.0.0",
|
||||
"description": "ZeroTier One network controller client for NodeJS",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "ZeroTier, Inc.",
|
||||
"license": "BSD",
|
||||
"dependencies": {
|
||||
"request": "^2.55.0"
|
||||
}
|
||||
}
|
7
controller/zt1-controller-client/test-controller.js
Normal file
7
controller/zt1-controller-client/test-controller.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
var ZT1ControllerClient = require('./index.js').ZT1ControllerClient;
|
||||
|
||||
var zt1c = new ZT1ControllerClient('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed');
|
||||
|
||||
zt1c.status(function(err,status) {
|
||||
console.log(status);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue