diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-05-16 16:09:28 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-05-16 16:09:28 -0700 |
| commit | a187d290f15ed2191e994852a6778bf4aa0f083b (patch) | |
| tree | c33f5c43b6b5dec857a5b8670ed570ea56d96b74 /controller/zt1-controller-client | |
| parent | 27c5f04d68003774b9a85eb7047c683cbb64f0df (diff) | |
| download | infinitytier-a187d290f15ed2191e994852a6778bf4aa0f083b.tar.gz infinitytier-a187d290f15ed2191e994852a6778bf4aa0f083b.zip | |
Fixes to control plane, API, eliminate problematic inheritance pattern, and start on a NodeJS class for talking to the network controller.
Diffstat (limited to 'controller/zt1-controller-client')
| -rw-r--r-- | controller/zt1-controller-client/index.js | 26 | ||||
| -rw-r--r-- | controller/zt1-controller-client/package.json | 14 | ||||
| -rw-r--r-- | controller/zt1-controller-client/test-controller.js | 7 |
3 files changed, 47 insertions, 0 deletions
diff --git a/controller/zt1-controller-client/index.js b/controller/zt1-controller-client/index.js new file mode 100644 index 00000000..b1e07e81 --- /dev/null +++ b/controller/zt1-controller-client/index.js @@ -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; diff --git a/controller/zt1-controller-client/package.json b/controller/zt1-controller-client/package.json new file mode 100644 index 00000000..8eda13ad --- /dev/null +++ b/controller/zt1-controller-client/package.json @@ -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" + } +} diff --git a/controller/zt1-controller-client/test-controller.js b/controller/zt1-controller-client/test-controller.js new file mode 100644 index 00000000..d76bad8f --- /dev/null +++ b/controller/zt1-controller-client/test-controller.js @@ -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); +});
\ No newline at end of file |
