From 2ad6630a18eef5823582c84414406299a50701f8 Mon Sep 17 00:00:00 2001 From: stefounet Date: Mon, 18 Jul 2011 15:19:14 +0200 Subject: [PATCH 1/7] bug fix on DNSParser::parseA (response buffer not correctly read) --- lib/ndns.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ndns.js b/lib/ndns.js index 8def7b1..cbf0fbf 100644 --- a/lib/ndns.js +++ b/lib/ndns.js @@ -1367,8 +1367,8 @@ DNSParser.prototype.parseA = function () { throw new Error(); this.parseStart += 4; return [this.buf[this.parseStart-4], + this.buf[this.parseStart-3], this.buf[this.parseStart-2], - this.buf[this.parseStart-1], this.buf[this.parseStart-1]].join('.'); }; From 95fc8b4e305082f4ec44473f0ac53df33a97bf49 Mon Sep 17 00:00:00 2001 From: stefounet Date: Sun, 6 May 2012 00:44:09 +0200 Subject: [PATCH 2/7] Added compatibility with node 0.6.x (enum function => _enum) --- lib/ndns.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ndns.js b/lib/ndns.js index cbf0fbf..5d6b49f 100644 --- a/lib/ndns.js +++ b/lib/ndns.js @@ -30,14 +30,14 @@ var ns_in6addrsz = 16; // IPv6 T_AAAA var ns_cmprsflgs = 0xc0;// Flag bits indicating name compression. var ns_defaultport = 53;// For both UDP and TCP. -function enum (obj) { +function _enum (obj) { for (key in obj) { global[key] = obj[key]; } return obj; } -var ns_sect = enum({ +var ns_sect = _enum({ 'ns_s_qd': 0, // Query: Question. 'ns_s_zn': 0, // Update: Zone. 'ns_s_an': 1, // Query: Answer. @@ -48,7 +48,7 @@ var ns_sect = enum({ 'ns_s_max': 4, }); -var ns_flag = enum({ +var ns_flag = _enum({ 'ns_f_qr': 0, // Question/Response. 'ns_f_opcode': 1, // Operation code. 'ns_f_aa': 2, // Authorative Answer. @@ -63,7 +63,7 @@ var ns_flag = enum({ }); // Currently defined opcodes. -var ns_opcode = enum({ +var ns_opcode = _enum({ 'ns_o_query': 0, // Standard query. 'ns_o_iquery': 1, // Inverse query (deprecated/unsupported). 'ns_o_status': 2, // Name server status query (unsupported). @@ -73,7 +73,7 @@ var ns_opcode = enum({ }); // Currently defined response codes -var ns_rcode = enum({ +var ns_rcode = _enum({ 'ns_r_noerror': 0, // No error occured. 'ns_r_formerr': 1, // Format error. 'ns_r_servfail': 2, // Server failure. @@ -96,13 +96,13 @@ var ns_rcode = enum({ }); // BIND_UPDATE -var ns_update_operation = enum({ +var ns_update_operation = _enum({ 'ns_oup_delete': 0, 'ns_oup_add': 1, 'ns_oup_max': 2, }); -var NS_TSIG = enum({ +var NS_TSIG = _enum({ 'NS_TSIG_FUDGE': 300, 'NS_TSIG_TCP_COUNT': 100, 'NS_TSIG_ALG_HMAC_MD5': "HMAC-MD5.SIG-ALG.REG.INT", @@ -113,7 +113,7 @@ var NS_TSIG = enum({ }); // Currently defined type values for resources and queries. -var ns_type = enum({ +var ns_type = _enum({ 'ns_t_invalid': 0, // Cookie. 'ns_t_a': 1, // Host address. 'ns_t_ns': 2, // Authoritative server. @@ -182,7 +182,7 @@ var ns_type = enum({ exports.ns_type = ns_type; // Values for class field -var ns_class = enum({ +var ns_class = _enum({ 'ns_c_invalid': 0, // Cookie. 'ns_c_in': 1, // Internet. 'ns_c_2': 2, // unallocated/unsupported. @@ -196,14 +196,14 @@ var ns_class = enum({ exports.ns_class = ns_class; // DNSSEC constants. -var ns_key_types = enum({ +var ns_key_types = _enum({ 'ns_kt_rsa': 1, // key type RSA/MD5 'ns_kt_dh': 2, // Diffie Hellman 'ns_kt_dsa': 3, // Digital Signature Standard (MANDATORY) 'ns_kt_private': 4 // Private key type starts with OID }); -var ns_cert_type = enum({ +var ns_cert_type = _enum({ 'cert_t_pkix': 1, // PKIX (X.509v3) 'cert_t_spki': 2, // SPKI 'cert_t_pgp': 3, // PGP From fb3a5f1563b4c1c8a2c46e143c0026799703f637 Mon Sep 17 00:00:00 2001 From: stefounet Date: Sun, 6 May 2012 00:46:33 +0200 Subject: [PATCH 3/7] Added a package.json --- package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..74cff31 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "ndns", + "description": "dns library for node.js", + "version": "0.1.2", + "homepage": "http://github.com/stefounet/ndns", + "repository": { + "type": "git", + "url": "http://github.com/stefounet/ndns.git" + }, + "author": "tomas", + "directories": { + "lib": "lib" + }, + "engines": { + "node": "*" + } +} From 545ae2e20ecabc3802e03de450cb3908ab4e2e83 Mon Sep 17 00:00:00 2001 From: stefounet Date: Sun, 6 May 2012 00:50:15 +0200 Subject: [PATCH 4/7] Added a root index.js pointing to lib --- index.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 index.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..9750666 --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +require('./lib/ndns.js'); From 78d92759f4a8903f4c0ba4bcb001bcbc720b8814 Mon Sep 17 00:00:00 2001 From: stefounet Date: Sun, 6 May 2012 01:05:04 +0200 Subject: [PATCH 5/7] Export lib --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9750666..12a8438 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -require('./lib/ndns.js'); +module.exports = require('./lib/ndns.js'); From d1febd9b5fffc594f54ea24dd55598d1d81d0d0e Mon Sep 17 00:00:00 2001 From: stefounet Date: Mon, 7 May 2012 00:05:28 +0200 Subject: [PATCH 6/7] Changed buffer testing (buffer/slowbuffer) --- lib/ndns.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ndns.js b/lib/ndns.js index 5d6b49f..3772346 100644 --- a/lib/ndns.js +++ b/lib/ndns.js @@ -1176,7 +1176,7 @@ function DNSParser(buf, start, end) { return; } - if (!(buf instanceof Buffer)) { + if (!(Buffer.isBuffer(buf))) { throw new Error("Argument should be a buffer"); } if (start > buf.length) { From 17a952df549d496e8d7afcb6d565cfdf9581bacf Mon Sep 17 00:00:00 2001 From: stefounet Date: Mon, 7 May 2012 00:05:47 +0200 Subject: [PATCH 7/7] Changed ref to util module instead of sys --- lib/ndns.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ndns.js b/lib/ndns.js index 3772346..0c7bbfb 100644 --- a/lib/ndns.js +++ b/lib/ndns.js @@ -1,9 +1,9 @@ -var sys = require('sys'); +var util = require('util'); var debug; var debugLevel = parseInt(process.env.NODE_DEBUG, 16); if(debugLevel & 0x4) { - debug = function (x) { sys.error('NDNS: ' + x); }; + debug = function (x) { util.error('NDNS: ' + x); }; } else { debug = function () { }; } @@ -1959,7 +1959,7 @@ function Message (socket, rinfo) { this.q = new MessageObject(); this.rr = new MessageObject(); } -sys.inherits(Message, events.EventEmitter); +util.inherits(Message, events.EventEmitter); exports.Message = Message; Message.prototype.addRR = function (name, ttl, className, typeName) { @@ -2005,14 +2005,14 @@ Message.prototype.addQuestion = function (name, typeName, className) { function IncomingMessage (socket, rinfo) { Message.call(this, socket, rinfo); }; -sys.inherits(IncomingMessage, Message); +util.inherits(IncomingMessage, Message); exports.IncomingMessage = IncomingMessage; function OutgoingMessage (socket, rinfo) { Message.call(this, socket, rinfo); this.maxSend = 512; } -sys.inherits(OutgoingMessage, Message); +util.inherits(OutgoingMessage, Message); exports.OutgoingMessage = OutgoingMessage; OutgoingMessage.prototype._Buffer = new Buffer(ns_maxmsg); @@ -2045,7 +2045,7 @@ OutgoingMessage.prototype.send = function (message) { function ServerResponse (req) { OutgoingMessage.call(this, req.socket, req.rinfo); } -sys.inherits(ServerResponse, OutgoingMessage); +util.inherits(ServerResponse, OutgoingMessage); exports.ServerResponse = ServerResponse; function ClientRequest(client, socket, port, host) { @@ -2057,7 +2057,7 @@ function ClientRequest(client, socket, port, host) { this.port = port; this.host = host; } -sys.inherits(ClientRequest, OutgoingMessage); +util.inherits(ClientRequest, OutgoingMessage); exports.ClientRequest = ClientRequest; ClientRequest.prototype.send = function (message) { @@ -2091,7 +2091,7 @@ function Server(type, requestListener) { this.on("message", messageListener); }; -sys.inherits(Server, dgram.Socket); +util.inherits(Server, dgram.Socket); exports.Server = Server; Server.prototype._Parser = parsers.alloc(); @@ -2141,7 +2141,7 @@ function Client(type, responseListener) { this.on("message", clientMessageListener); this.bind(); } -sys.inherits(Client, dgram.Socket); +util.inherits(Client, dgram.Socket); exports.Client = Client; Client.prototype.request = function (port, host) {