Socket
Socket
Sign inDemoInstall

dynect

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynect

Dynect API connector for node.js


Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

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 www.example.com (address '123.45.67.89')

	var Dynect = require('dynect');

	// open Dynect API session
	var dynect = new Dynect('customername', 'username', 'password');

	dynect.on('connected', function () {
		var zone = 'example.com';

		// add A record with 5 min TTL
		dynect.addRecord('A', zone, 'www.example.com', {
			address: '123.45.67.89'
		}, 300, function (addResponse) {
			console.log(addResponse);

			//publish zone
			dynect.publishZone(zone, function (publishResponse) {
				console.log(publishResponse);

				// close Dynect API session
				dynect.disconnect();
			});
		});
	});

	dynect.connect();

example 2 :

add CNAME record www.example.com (cname 'example.mydomain.com')

	var Dynect = require('dynect');

	// open Dynect API session and send keepalive every 5mins
	var dynect = new Dynect('customername', 'username', 'password', 300000);

	dynect.on('connected', function () {
		var zone = 'example.com';

		// add CNAME record with default TTL
		dynect.addRecord('CNAME', zone, 'www.example.com', {
			cname: 'example.mydomain.com'
		}, 0, function (addResponse) {
			console.log(addResponse);

			// publish zone
			dynect.publishZone(zone, function (publishResponse) {
				console.log(publishResponse);
			});
		});
	});

	dynect.connect();

example 3 :

get all SRV records for '_sip._tcp.example.com' and remove any record with matching target 'voip.mydomain.com'

	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

  npm install dynect

enjoy

the frisB.com team :)

Keywords

FAQs

Package last updated on 30 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc