trevoro / node-named Goto Github PK
View Code? Open in Web Editor NEWDNS Server in node.js
License: MIT License
DNS Server in node.js
License: MIT License
Please, add NS record type
I know this isn't an issue with the project itself and I'll close it asap but I was wondering how I might go about saving the DNS records I set.
It is important to remember that these DNS records are not permanently added to the server. They only exist for the length of the particular request. After that, they are destroyed. This means you have to create your own lookup mechanism.
I don't understand what the last part means because I thought DNS lookups were just that — looking up the DNS for a domain. I don't see how that would save DNS changes.
D:\Nodejs_Projects\person\dns.prj\node_modules\node-named>node examples\reflect.js
events.js:160
throw er; // Unhandled 'error' event
^
Error: bind EINVAL 127.0.0.1:9999
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at dgram.js:221:18
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
D:\Nodejs_Projects\person\dns.prj\node_modules\node-named>node -v
v6.9.1
http://stackoverflow.com/questions/18733381/node-js-giving-error-bind-einval
I have installed node-named on a fresh install of Ubuntu 12.04. To test it I am using the Server API example in node-named/docs/index.md
However whenever I try to use the dig command suggested in the docs:
$ dig @localhost -p9999 example.com SOA
It crashes with the following error:
{
"name":"named",
"hostname":"my-server-name",
"pid":1642,
"component":"agent",
"level":40,
"err":{"message":"undefined is not a function","name":"TypeError","stack":"TypeError: undefined is not a function\n at Server. (/apps/nodejs/dns/dns.js:12:15)\n at Server.EventEmitter.emit (events.js:95:17)\n at Socket. (/apps/nodejs/dns/node_modules/node-named/lib/server.js:92:30)\n at Socket.EventEmitter.emit (events.js:98:17)\n at UDP.onMessage (dgram.js:440:8)"},
"msg":"query handler threw an uncaughtException",
"time":"2014-04-22T17:12:08.972Z",
"v":0
}
Am I missing something?
Hi,
I've created a simple server, but if I make requests from the local machine (OS X El Capitan, dig command) always is ok, if I make requests from another computer in the same LAN (Windows 10, Chrome) always I get EHOSTDOWN or EINVAL errors.
The code I used is this.
var named = require('node-named')
var dns = require('dns')
var dnsServer = named.createServer()
dnsServer.on('query', (query) => {
switch(query.type()) {
case 'A':
dns.resolve(query.name(), 'A', (err, addresses) => {
if(err)
return
for(var i = 0; i < addresses.length; i++)
query.addAnswer(query.name(), new named.ARecord(addresses[i]), 0)
dnsServer.send(query)
})
break
}
})
dnsServer.on('uncaughtException', (e) => console.log('LOG0'))
dnsServer.on('after', (e) => console.log('LOG1'))
dnsServer.on('clientError', (e) => console.log('LOG2'));
dnsServer.listen(process.env.DNS_PORT || 53, () => {
console.log('DNS server started.')
})
Console output is this
imac-di-edoardo:ad Edoardo$ sudo npm start
> [email protected] start /Users/Edoardo/Desktop/FLRAuth/ad
> node server.js
DNS server started.
{ Error: send EHOSTDOWN ::ffff:192.168.1.4:61551
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at SendWrap.afterSend [as oncomplete] (dgram.js:406:11)
code: 'EHOSTDOWN',
errno: 'EHOSTDOWN',
syscall: 'send',
address: '::ffff:192.168.1.4',
port: 61551 }
{"name":"named","hostname":"imac-di-edoardo.local","pid":1081,"component":"agent","level":40,"adddress":"::ffff:192.168.1.4","port":61551,"err":{"message":"send EHOSTDOWN ::ffff:192.168.1.4:61551","name":"Error","stack":"Error: send EHOSTDOWN ::ffff:192.168.1.4:61551\n at Object.exports._errnoException (util.js:1018:11)\n at exports._exceptionWithHostPort (util.js:1041:20)\n at SendWrap.afterSend [as oncomplete] (dgram.js:406:11)","code":"EHOSTDOWN","errno":"EHOSTDOWN","syscall":"send","address":"::ffff:192.168.1.4","port":61551},"msg":"send: unable to send response","time":"2017-04-18T16:45:12.387Z","v":0}
events.js:160
throw er; // Unhandled 'error' event
^
ExceptionError: function () {
return msg || name;
}
at SendWrap.callback (/Users/Edoardo/Desktop/FLRAuth/ad/node_modules/node-named/lib/server.js:137:44)
at SendWrap.afterSend [as oncomplete] (dgram.js:411:8)
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.10.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ad package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ad
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ad
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Edoardo/Desktop/FLRAuth/ad/npm-debug.log
My node version is 6.10.1.
Thank you in advance.
I'm wondering if node-named wouldn't be a nifty addition to NicTool? NicTool stores DNS data in a MySQL database and exports to a number of DNS servers. By using node-named, I'd opt to serve directly out of the database, which could obviously be a bottleneck. That could be worked around by caching MySQL query results in Redis for N seconds. Redis is fast enough to for all but the most demanding of DNS servers. Am I crazy?
Hello !
Thanks for your job, it's works very well for me.
It's more a general question about how DNS works. What's append if no answer is added to query ?
server.send(query) ( without query.addAnswer called).
Is the query will go to other server name ?
Thansk for your support
Hi :-)
would you please add a license like MIT ?
(Germans have big trouble with no license by law)
The docs say that named.AAAARecord()
is named.AaaaRecord()
.
var named = require('node-named');
var server = named.createServer();
server.listen(53, '192.168.0.4', function() {
console.log('DNS server started on port 53');
});
server.on('query', function(query) {
console.log(query.name());
});
foo:dns brandonros$ sudo node app.js
events.js:160
throw er; // Unhandled 'error' event
^
Error: bind EINVAL 192.168.0.4:53
Can you please publish a new version to npm since I'd like to be able to run with the fix from 73719b0.
Thanks!
Run on Debian 8.5 with 'dig' available.
~/GitHub/node-named/test$ nodeunit named.test.js
named.test.js
Error: bind EINVAL 0.0.0.0:1153
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at _handle.lookup (dgram.js:215:18)
at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
FAILURES: Undone tests (or their setups/teardowns):
- listen and close (port only)
To fix this, make sure all tests call test.done()
When I try start example I get error:
Error: bind EINVAL 192.168.0.102:9999
I found somthing about it here - http://stackoverflow.com/questions/18733381/node-js-giving-error-bind-einval
But this did not help.
Hello trevoro,
Thanks for writing this library! =)
I've recently encountered an issue with the library as shown in the following error snippet:
There was a client error: ProtocolError: function () {
return msg || name;
}
/home/ubuntu/dnsd/node_modules/node-named/lib/server.js:87
query.respond = function respond() {
^
TypeError: Cannot set property 'respond' of undefined
at Socket.<anonymous> (/home/ubuntu/dnsd/node_modules/node-named/lib/server.js:87:31)
at Socket.EventEmitter.emit (events.js:98:17)
at UDP.onMessage (dgram.js:437:8)
My assumption is that Query.parse()
may have thrown an exception. It seems possible, via protocol.decode()
when it encounters an invalid DNS record type.
I have implemented a possible fix on my fork; the query
event will not be emitted if there is no query object returned.
Please see my pull request for details.
I don't know why github requires a fork to make a pull request, but here's a repo with everything working if you want to incorporate.
Hello!
We developed a module that replaces/extends node's dns.lookup
method. The main goal is to bypass issues with blocking of thread pool. So module caches responses.
I want to ask you is it possible to add link and short description to our module in your project?
Module was tested in production and highload environments. Also we have good unit and functional tests with 100% coverage, multi-records resolving and TTL support. Here it is: https://github.com/LCMApps/dns-lookup-cache
Thank you for reply!
Because node-named uses 'udp6' to create the socket, a specific IPv4 address to bind to gets ignored and the socket always listens on '::'
Consequently, when a DNS request arrives on a loopback IP address, the response is sent with an interface IP, and the client doesn't process it
Hi,
I tried using this library on a debian machine binding to the default 0.0.0.0 adress.
My node version is 13.7.0.
The library fails to bind to the specified port (no matter which one I choose). I located the error in this line where it says udp6 instead of udp4. If I change it the error disappears and everything seems to work. But I don't understand why no one else seemed to have this issue before and why there even was udp6 in this line in the first place.
So it this a bug and can I change it?
Kind regards
Joshua
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.