dynect
Advanced tools
Comparing version 0.1.8 to 0.1.10
{ | ||
"name": "dynect", | ||
"description": "Dyn DNS API connector for node.js", | ||
"description": "Dynect API connector for node.js", | ||
"contributors": [ | ||
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.1.8", | ||
"version": "0.1.10", | ||
"keywords": [ | ||
@@ -18,0 +18,0 @@ "dynect", |
@@ -1,7 +0,13 @@ | ||
Dyn DNS API connector for node.js. | ||
Dynect API connector for node.js. | ||
=== | ||
the node.js Dynect module provides a simple interface for making calls to the Dynect API. | ||
it is a work in progress and further functionality and examples will be provided soon. | ||
contributions are welcome of course. | ||
### example 1 : | ||
add A record | ||
add A record www.example.com (address '123.45.67.89') | ||
@@ -31,3 +37,3 @@ ``` js | ||
}); | ||
}) | ||
}); | ||
@@ -39,3 +45,3 @@ dynect.connect(); | ||
add CNAME record | ||
add CNAME record www.example.com (cname 'example.mydomain.com') | ||
@@ -62,3 +68,3 @@ ``` js | ||
}); | ||
}) | ||
}); | ||
@@ -68,2 +74,62 @@ dynect.connect(); | ||
### example 3 : | ||
get all SRV records for '_sip._tcp.example.com' and remove any record with matching target 'voip.mydomain.com' | ||
``` js | ||
var Dynect = require('dynect'); | ||
// open Dynect API session | ||
var dynect = new Dynect('customername', 'username', 'password'); | ||
var zone = 'example.com'; | ||
dynect.on('connected', function () { | ||
var fqdn = '_sip._tcp.example.com'; | ||
dynect.getRecordSet('SRV', zone, fqdn, function (response) { | ||
console.log(response); | ||
if (response.status === 'failure' && response.msgs[0].ERR_CD === 'NOT_FOUND') { | ||
// SRV records not found | ||
// close Dynect API session | ||
dynect.disconnect(); | ||
} | ||
else { | ||
// SRV records found | ||
var uri = response.data[0]; | ||
var parts = uri.split('/'); | ||
var recordId = parts[parts.length - 1]; | ||
removeTargetIfExists(fqdn, recordId, 'voip.mydomain.com', function (isRemoved) { | ||
console.log(isRemoved ? 'removed' : 'nothing removed') | ||
// close Dynect API session | ||
dynect.disconnect(); | ||
}); | ||
} | ||
}); | ||
}); | ||
function removeTargetIfExists(fqdn, recordId, target, callback) { | ||
dynect.getRecord('SRV', zone, fqdn, recordId, function (response) { | ||
if (response.data.rdata.target === target + '.') { | ||
// SRV record for target exists so remove | ||
dynect.removeRecord('SRV', zone, fqdn, recordId, function () { | ||
callback(true); | ||
}); | ||
} | ||
else { | ||
// SRV record for target does not exist | ||
callback(false); | ||
} | ||
}); | ||
} | ||
dynect.connect(); | ||
``` | ||
## installation | ||
@@ -75,2 +141,4 @@ | ||
#### author: ashley @[frisB.com](http://www.frisb.com) | ||
## enjoy | ||
#### the [frisB.com](http://www.frisb.com) team :) |
17681
139