Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug fix #1

Open
wants to merge 7 commits into from

3 participants

This page is out of date. Refresh to see the latest.
Showing with 40 additions and 22 deletions.
  1. +1 −0  index.js
  2. +22 −22 lib/ndns.js
  3. +17 −0 package.json
View
1  index.js
@@ -0,0 +1 @@
+module.exports = require('./lib/ndns.js');
View
44 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 () { };
}
@@ -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
@@ -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) {
@@ -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('.');
};
@@ -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) {
View
17 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": "*"
+ }
+}
Something went wrong with that request. Please try again.