New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dns

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dns - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

30

lib/dns.js

@@ -78,13 +78,27 @@ module.exports = function () {

length = hostname.length,
answer = {};
answer = {},
key = this.config.prefix + hostname;
this.redis.get(this.config.prefix + (question.type === 'AAAA' ? 'AAAA:' : '') + hostname, function (err, value) {
if (!err && value && value.length > 0) {
this.redis.get(key, function (err, value) {
$this.logger.log('debug', '%s:%s/%s - local - %s question:"%s" - redis key[%s] value[%s] err[%j]', req.connection.remoteAddress, req.connection.remotePort, req.connection.type, hostname, question, key, value, err, $this.meta);
var object;
if (!err && value) {
try {
object = JSON.parse(value);
$this.logger.log('debug', '%s:%s/%s - local - %s question:"%s" - redis key[%s] value[%s] == object[%j]', req.connection.remoteAddress, req.connection.remotePort, req.connection.type, hostname, question, key, value, object, $this.meta);
} catch (e) {
err = new Error("Exception [" + util.inspect(e, true) + "] while parsing redis response [" + value + "]");
$this.logger.log('error', '%s:%s/%s - local - %s question:"%s" - redis key[%s] value[%s]', req.connection.remoteAddress, req.connection.remotePort, req.connection.type, hostname, question, key, value, $this.meta);
}
}
if (!err && object && object.hasOwnProperty(question.type)) {
answer = {
name : hostname,
type : question.type,
class : question.class,
data : value,
ttl : $this.config.ttl
name: hostname,
type: question.type,
class: question.class,
ttl: $this.config.ttl
};
if (object[question.type]) {
answer.data = object[question.type];
}
res.answer.push(answer);

@@ -91,0 +105,0 @@ $this.logger.log('info', '%s:%s/%s - local - %s question:"%s" - %j', req.connection.remoteAddress, req.connection.remotePort, req.connection.type, hostname, question, answer, $this.meta);

@@ -88,3 +88,3 @@ module.exports = function () {

for(var i = 0 ; i < keys.length && i < values.length ; ++i) {
vector.push({name:keys[i],address:values[i]});
vector.push({key:keys[i],value:values[i]});
}

@@ -91,0 +91,0 @@ next(null, vector);

@@ -14,7 +14,14 @@ module.exports = function () {

if (err) {
res.json({name:req.params.name,operation:"get",error:err,status:"FAILED"});
} else {
res.json({name:req.params.name,address:value,operation:"get",status:"OK"});
return res.status(500).json({name:req.params.name,operation:"get",error:err,status:"FAILED"}).end();
}
res.end();
if (value) {
var record;
try {
record = JSON.parse(value);
} catch (e) {
return res.status(500).json({name:req.params.name,operation:"get",error:e,status:"FAILED"}).end();
}
return res.json({name:req.params.name,record:record,operation:"get",status:"OK"}).end();
}
return res.status(404).json({name:req.params.name,operation:"get",status:"NOT-FOUND"}).end();
});

@@ -24,10 +31,11 @@ } else {

if (err) {
res.json({name:req.params.name,operation:"mgetkeys",error:err,status:"FAILED"});
} else {
return res.status(500).json({name:req.params.name,operation:"mgetkeys",error:err,status:"FAILED"}).end();
}
if (values) {
var valuesWithoutPrefix = values.map(function (tuple) {
return {name:tuple.name.substring(prefixSize), address:tuple.address};
return {name:tuple.key.substring(prefixSize), record:JSON.parse(tuple.value)};
});
res.json({addresses:valuesWithoutPrefix,operation:"mgetkeys",status:"OK"});
return res.json({records:valuesWithoutPrefix,operation:"mgetkeys",status:"OK"}).end();
}
res.end();
return res.status(404).json({name:req.params.name,operation:"mgetkeys",status:"NOT-FOUND"}).end();
});

@@ -39,10 +47,30 @@ }

app.put('/dns/api/v1/name/:name', function (req, res) {
redis.set(prefix + req.params.name, req.body, function (err, result) {
var arpa,
record = {
host : req.params.name,
PTR : null
};
if (req.body) {
if (req.body.ipv4) {
record.A = req.body.ipv4;
arpa = record.A.split('.').reverse().join('.') + '.in-addr.arpa';
}
if (req.body.ipv6) {
record.AAAA = req.body.ipv6;
}
}
redis.set(prefix + req.params.name, JSON.stringify(record), function (err, result) {
if (err) {
res.json({name:req.params.name,value:req.body,operation:"set",status:'FAILED',error:err});
} else {
io.sockets.emit('new:host', {name:req.params.name, address: req.body});
res.json({name:req.params.name,value:req.body,operation:"set",status:'OK'});
return res.status(500).json({name:req.params.name,operation:"set",error:err,status:"FAILED"}).end();
}
res.end();
io.sockets.emit('new:host', {name:req.params.name, record: record});
redis.set(prefix + arpa, JSON.stringify(record), function (err, result) {
if (err) {
return res.status(500).json({name:arpa,operation:"set",isArpa:true,error:err,status:"FAILED"}).end();
}
io.sockets.emit('new:host', {name:arpa, record: record});
return res.json({name:req.params.name,value:record,operation:"set",status:'OK'}).end();
});
});

@@ -56,8 +84,6 @@ });

if (err) {
res.json({name:req.params.name,operation:"del",error:err,status:"FAILED"});
} else {
io.sockets.emit('del:host', {name:req.params.name});
res.json({name:req.params.name,operation:"del",status:"OK"});
return res.status(500).json({name:req.params.name,operation:"delete",error:err,status:"FAILED"}).end();
}
res.end();
io.sockets.emit('delete:host', {name:req.params.name});
return res.json({name:req.params.name,operation:"delete",status:"OK"}).end();
});

@@ -70,4 +96,3 @@ } else {

if (!keys || keys.length < 1) {
res.json({name:"*",force:true, operation:"del",total:total,failed:failed,status:"OK"});
return res.end();
return res.json({name:"*",force:true, operation:"delete",total:total,failed:failed,status:"OK"}).end();
}

@@ -79,3 +104,3 @@ var key = keys.shift();

} else {
io.sockets.emit('del:host', {name:key.substring(prefixSize)});
io.sockets.emit('delete:host', {name:key.substring(prefixSize)});
total += 1;

@@ -90,4 +115,3 @@ }

if (err) {
res.json({name:"*",force:true, operation:"del",error:err,status:"FAILED"});
return res.end();
return res.status(500).json({name:"*",force:true,operation:"delete",error:err,status:"FAILED"}).end();
}

@@ -97,4 +121,3 @@ removeEntry(keys)

} else {
res.json({name:"*",operation:"del",error:new Error("To delete all the entries, you must use the 'force' option"),status:"FAILED"});
res.end();
return res.status(400).json({name:"*",operation:"delete",error:new Error("To delete all the entries, you must use the 'force' option"),status:"FAILED"}).end();
}

@@ -105,4 +128,3 @@ }

app.get('/dns/api/v1/zone', function (req, res) {
res.json({zone:config.dns.zone,operation:"zone",status:"OK"});
res.end();
return res.json({zone:config.dns.zone,operation:"zone",status:"OK"}).end();
});

@@ -112,4 +134,3 @@

app.get('/dns/api/v1/status', function (req, res) {
res.json({status:'OK',operation:"status"});
res.end();
return res.json({status:'OK',operation:"status"}).end();
});

@@ -116,0 +137,0 @@ }

@@ -5,3 +5,3 @@ {

"description" : "A DNS Server with an Web UI and using Redis a configuration store",
"version" : "0.0.9",
"version" : "0.1.0",
"keywords" : ["dns"],

@@ -8,0 +8,0 @@

@@ -9,7 +9,7 @@ angular.module('dnsControllers', ['dnsServices', 'dnsModels'])

var found = false;
if ($scope.dns.hosts.addresses) {
for (var i = 0 ; i < $scope.dns.hosts.addresses.length ; ++i) {
if ($scope.dns.hosts.addresses[i].name === host.name) {
if ($scope.dns.hosts.records) {
for (var i = 0 ; i < $scope.dns.hosts.records.length ; ++i) {
if ($scope.dns.hosts.records[i].name === host.name) {
found = true;
$scope.dns.hosts.addresses[i].address = host.address;
$scope.dns.hosts.records[i].record = host.record;
break;

@@ -20,12 +20,12 @@ }

if (!found) {
if (!$scope.dns.hosts.addresses)
$scope.dns.hosts.addresses = [];
$scope.dns.hosts.addresses.push(host);
if (!$scope.dns.hosts.records)
$scope.dns.hosts.records = [];
$scope.dns.hosts.records.push(host);
}
});
socket.on('del:host', function (host) {
if ($scope.dns.hosts.addresses) {
for (var i = 0 ; i < $scope.dns.hosts.addresses.length ; ++i) {
if ($scope.dns.hosts.addresses[i].name === host.name) {
$scope.dns.hosts.addresses.splice(i, 1);
socket.on('delete:host', function (host) {
if ($scope.dns.hosts.records) {
for (var i = 0 ; i < $scope.dns.hosts.records.length ; ++i) {
if ($scope.dns.hosts.records[i].name === host.name) {
$scope.dns.hosts.records.splice(i, 1);
break;

@@ -32,0 +32,0 @@ }

@@ -74,3 +74,3 @@ [![Build Status](https://travis-ci.org/hbouvier/dns.png)](https://travis-ci.org/hbouvier/dns)

curl -X PUT -H 'Content-Type: text/plain' -d '291.168.1.100' http://localhost:8053/dns/api/v1/name/database.domain.com
curl -X PUT -H 'Content-Type: application/json' -d '{"ipv4":"192.168.1.1", "ipv6":"2605:f8b0:4006:802:0:0:0:1010"}' http://localhost:8053/dns/api/v1/name/database.domain.com

@@ -82,2 +82,4 @@ ## To query the address of a host

dig @127.0.0.1 database.domain.com
or
dig @127.0.0.1 database.domain.com AAAA

@@ -87,1 +89,7 @@ ## To remove a host from the registry

curl -X DELETE http://localhost:8053/dns/api/v1/name/database.domain.com
# UPGRADING from 0.0.9 to further version.
You will need to clear your redis configuration before running the new version.
for key in `echo 'KEYS dns*' | redis-cli | awk '{print $1}'` ; do echo DEL $key ; done | redis-cli

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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