Some nodeJS work, and apply fix from GitHub issue #166 plus a small optimization to avoid repeated calls to _allMulticastGroups().

This commit is contained in:
Adam Ierymenko 2015-05-25 14:21:05 -07:00
commit 5e3c6d9e0d
3 changed files with 50 additions and 20 deletions

View file

@ -8,6 +8,25 @@ function ZT1Client(url,authToken)
this.authToken = authToken;
}
// Generate new ZeroTier identity -- mostly for testing
ZT1Client.prototype.newIdentity = function(callback)
{
request({
url: this.url + 'newIdentity',
method: 'GET',
json: false,
headers: {
'X-ZT1-Auth': this.authToken
}
},function(error,response,body) {
if (error)
return callback(error,null);
if (response.statusCode === 200)
return callback(null,body);
return callback(new Error('server responded with error: '+response.statusCode),'');
});
}
ZT1Client.prototype._jsonGet = function(getPath,callback)
{
request({
@ -134,4 +153,8 @@ ZT1Client.prototype.saveControllerNetwork = function(network,callback)
});
};
ZT1Client.prototype.getControllerNetworkMember = function(nwid,address,callback) {
this._jsonGet('controller/network/' + nwid + '/member/' + address,callback);
};
exports.ZT1Client = ZT1Client;