Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dns-suite

Package Overview
Dependencies
Maintainers
7
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dns-suite - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

10

dns.js

@@ -8,2 +8,4 @@ ;(function (exports) {

//var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
var logged = {};
exports.DNSPacket = {

@@ -25,4 +27,10 @@ parse: function (nb) {

} catch (e) {
console.error('[Error] unpackRdata: ' + e.message);
record.error = e;
if (!/^support for dns/i.test(e.message)) {
console.error('[Error] unpackRdata: ' + e.message);
}
else if (!logged[e.message]) {
console.error('[Error] unpackRdata: ' + e.message);
logged[e.message] = true;
}
}

@@ -29,0 +37,0 @@ }

@@ -40,2 +40,7 @@ (function (exports) {

}
if (!classes[r.className]) {
console.warn("ignoring invalid class '" + r.className + "' for '" + r.name);
} else {
r.class = classes[r.className];
}
}

@@ -48,3 +53,5 @@

if (!types[r.typeName]) {
console.warn("ignoring invalid type '" + r.type + "' for '" + r.name + "', ignoring");
console.warn("ignoring invalid type '" + r.typeName + "' for '" + r.name);
} else {
r.type = types[r.typeName];
}

@@ -51,0 +58,0 @@ }

18

dns.parser.js

@@ -34,2 +34,3 @@ ;(function (exports) {

var optWarned = false;
pdns.unpackOpt = function (ab, packet, rec) {

@@ -39,5 +40,8 @@ var dv;

// https://tools.ietf.org/html/rfc6891#section-6
console.log('OPT is not yet supported');
if (!optWarned) {
console.warn('OPT is not yet supported');
optWarned = true;
}
if ('undefined' !== typeof packet.edns_version) {
console.warn("More that one OPT, should respond with FORMERR, but not implmentede");
console.warn("More that one OPT, should respond with FORMERR, but not implemented");
}

@@ -65,7 +69,7 @@ if (packet.name) {

packet.z = dv.getUint16(2, false) & 0x7FFF; // 0111 1111
/*
"edns_options": [],
"payload": 4096,
"edns_version": 0,
"do": 0
/*
"edns_options": [],
"payload": 4096,
"edns_version": 0,
"do": 0
*/

@@ -72,0 +76,0 @@ };

'use strict';
module.exports.respond = function (socket, packets, rinfo) {
var dns = require('dns-js');
var dns = require('../');
var os = require('os');

@@ -11,2 +11,7 @@ var queryname = '_cloud._tcp.local';

packets.forEach(function (packet) {
// Only respond to queries, otherwise we'll end up responding to ourselves forever.
if (packet.header.qr !== 0) {
return;
}
packet.question.forEach(function (q) {

@@ -18,6 +23,35 @@ if (queryname !== q.name) {

console.log('question', q.name, q.typeName, q.className, q.flag, q);
var rpacket = new dns.DNSPacket();
var rpacket = {
header: {
id: packet.header.id
, qr: 1
, opcode: 0
, aa: 1
, tc: 0
, rd: 0
, ra: 0
, res1: 0
, res2: 0
, res3: 0
, rcode: 0
, }
, question: [q]
, answer: []
, authority: []
, additional: []
, edns_options: []
};
var myRndId = 'be1af7a';
rpacket.answer.push({
name: q.name
, typeName: 'PTR'
, ttl: 10
, className: 'IN'
, data: myRndId + '.' + queryname
});
var ifaces = os.networkInterfaces();
//var llRe = /^(fe80|169)/i; // link-local
Object.keys(ifaces).forEach(function (iname) {

@@ -33,6 +67,6 @@ var iface = ifaces[iname];

rpacket.additional.push({
name: q.name
, type: ('IPv4' === pface.family ? dns.DNSRecord.Type.A : dns.DNSRecord.Type.AAAA)
name: myRndId + '.' + q.name
, typeName: ('IPv4' === pface.family ? 'A' : 'AAAA')
, ttl: 10
, class: dns.DNSRecord.Class.IN
, className: 'IN'
, address: pface.address // '_workstation._tcp.local'

@@ -43,37 +77,19 @@ });

var myRndId = 'be1af7a';
rpacket.answer.push({
name: q.name
, type: dns.DNSRecord.Type.PTR
, ttl: 10
, class: dns.DNSRecord.Class.IN
, data: myRndId + '.' + queryname
});
rpacket.question.push(new dns.DNSRecord(
queryname // Name
, dns.DNSRecord.Type.PTR // Type
, dns.DNSRecord.Class.IN // Class
//, null // TTL
));
rpacket.additional.push({
name: myRndId + '.' + queryname
, type: dns.DNSRecord.Type.SRV
, typeName: 'SRV'
, ttl: 10
, class: dns.DNSRecord.Class.IN
, priority: 0
, className: 'IN'
, priority: 1
, weight: 0
, port: 443
, target: myRndId + ".local"
, target: myRndId + ".local"
});
rpacket.additional.push({
name: myRndId + '.' + '_device-info._tcp.local'
, type: dns.DNSRecord.Type.TXT
, typeName: 'TXT'
, ttl: 10
, class: dns.DNSRecord.Class.IN
, className: 'IN'
, data: ["model=CloudHome1,1", "dappsvers=1"]
});
rpacket.header.id = packet.header.id;
rpacket.header.aa = 1;
rpacket.header.qr = 1;
rpacket.header.rd = 0;

@@ -83,3 +99,3 @@ console.log('');

console.log(rpacket);
var buf = dns.DNSPacket.toBuffer(rpacket);
var buf = dns.DNSPacket.write(rpacket);
console.log(buf.toString('hex'));

@@ -97,4 +113,3 @@ console.log('END JSON PACKET');

});
/*
*/
packet.answer.forEach(function (a) {

@@ -101,0 +116,0 @@ console.log('answer', a.name, a.typeName, a.className, a.flag, a);

'use strict';
var dgram = require('dgram');
var dnsjs = require('dns-js');

@@ -25,2 +24,2 @@ // SO_REUSEADDR and SO_REUSEPORT are set because

// ... more stuff
});
});

@@ -8,3 +8,3 @@ 'use strict';

});
var dns = require('dns-js');
var dns = require('../');
//var DNSPacket = dns.DNSPacket;

@@ -35,13 +35,10 @@

socket.on('message', function (message, rinfo) {
console.log('Received %d bytes from %s:%d\n',
message.length, rinfo.address, rinfo.port);
console.log('Received %d bytes from %s:%d', message.length, rinfo.address, rinfo.port);
//console.log(msg.toString('utf8'));
message.forEach(function(byte){
console.log(pad(byte.toString(2), 8, '0'));
});
console.log(pad(byte.toString(2), 8,'0'));
});
// console.log(message.toString('hex'));

@@ -48,0 +45,0 @@ // console.log(message.toString('ascii'));

{
"name": "dns-suite",
"version": "1.1.0",
"version": "1.1.1",
"description": "testing dns",

@@ -5,0 +5,0 @@ "main": "dns.js",

@@ -6,3 +6,3 @@ (function (exports) {

// Priority: The relative priority of this service. 16-bit (range 0-65535)
// Weight: Used when more than one serivice has the same priority. 16-bit
// Weight: Used when more than one serivice has the same priority. 16-bit
// (range 0-65535)

@@ -35,4 +35,4 @@ // Port: Port number assigned to the symbolic service. 16-bit (range 0-65535)

// console.log("total length currently is: " + total);
var srvLen = 6; // 16-bit priority, weight and port = 6 Bytes

@@ -67,3 +67,3 @@ var rdLenIndex = total;

dv.setUint16(rdLenIndex, srvLen, false);
return total;

@@ -70,0 +70,0 @@ };

@@ -30,2 +30,16 @@ (function (exports) {

// Represent the string address as recommended on the wikipedia page
// https://en.wikipedia.org/wiki/IPv6_address#Recommended_representation_as_text.
// (shorten the longest section of 0's as long as it's more than one section, replacing
// the left-most instance in the event of ties.)
var re = /:(0:)+/g;
var match;
var longest = '_BAD';
while (!!(match = re.exec(s))) {
if (match[0].length > longest.length) {
longest = match[0];
}
}
s = s.replace(longest, '::');
record.address = s;

@@ -32,0 +46,0 @@ return record;

@@ -27,3 +27,3 @@ (function (exports) {

record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
// if there exists compression pointers in the rdata

@@ -33,3 +33,3 @@ if (cpcount > 0){

// I need the length of all the data before the email address starts.
// if there are compression pointers then there will be a byte to indicate the length of each label, the label,
// if there are compression pointers then there will be a byte to indicate the length of each label, the label,
// then there will be a compression pointer to grab the longest label.

@@ -46,3 +46,3 @@

}
}
}
} // if there are no compression pointers, we can get the email address directly from the offset

@@ -63,4 +63,4 @@ else {

record.nx = dv.getUint32(dv.byteLength - 4, false);
return record;

@@ -67,0 +67,0 @@

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