1.0.0 • Published 8 years ago

eva-dns v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Install

npm install eva-dns

TODO

  • Add a load more comments
  • Allow for answer concatenation

Example

Create a DNS relay with custom intercept injection and a log

var dns = require('eva-dns');

// Produces a log
dns.on('queryRequest', function (packet, host, port, cache) {
    var a;
    for (a in packet.questions) {
        if ({}.hasOwnProperty.call(packet.questions, a)) {
            console.log((cache ? "Intercept: " : "Forwarded: ") + host + " - " + packet.questions[a].QNAME);
        }
    }
})

// Create an 'A' record for 'test.example.com' => '64.233.184.102'. 0 Implies an answer
dns.recordCreate('test.example.com', 1, dns.ipToData('64.233.184.102'), 0)

// Catures errors I have thought of :)
dns.on('error', function (err) {
    console.log(err);
})

// Bind the server to (transit.host)
dns.bind();

Logless DNS relay and interception (note I am not catch errors)

var dns = require('eva-dns');

// Create an 'A' record for 'test.example.com' => '64.233.184.102'. 0 Implies an answer
dns.recordCreate('test.example.com', 1, dns.ipToData('64.233.184.102'), 0);

// Bind the server to (transit.host)
dns.bind();

Functions

Event: 'message'

dns.on('message', function (message, rInfo) {});
'message' is a [eva-dns-packet](scagood/eva-dns-packet) decoded output
'rInfo' is the sender info of the recieved message

Event: 'queryResponce'

dns.on('queryResponce', function (packet, host, port) {});
'packet' is a [eva-dns-packet](scagood/eva-dns-packet) decoded output
'host' is the senders host (The resolver's host)
'port' is the senders port (The resolver's port)

Event: 'queryRequest'

dns.on('queryRequest', function (packet, host, port) {});
'packet' is a [eva-dns-packet](scagood/eva-dns-packet) decoded output
'host' is the senders host (The requester's host)
'port' is the senders port (The requester's port)

Event: 'listening'

dns.on('listening', function () {});

Event: 'error'

dns.on('error', function (error) {});
'error' is the error

Event: 'close'

dns.on('close', function () {});

on(eventname, callback)

Events fire based on events above.

setTransit(host[, port, name])

Defaults:

host: getLocalIPs('v4')[0] // Converts to os interfaces
port: 53 // Default DNS port
name: 'DNS-Proxy.home' // The responce to ip.rev.192.in-addr.arpa

This sets the local settings

setResolve(host, port)

Defaults:

host: '8.8.8.8' // Google's open dns
port: 53 // Default DNS port

This sets the upstream resolver

bind()

This launches the server using transit.port, transit.host

close()

Closes the DNS server

recordCreate(name, type, data, answerType)

name - example: "example.com"
type - [One of the following resource types](https://en.wikipedia.org/wiki/List_of_DNS_record_types)
data - data for responce
answerType - 0 = answers - 1 = authority - 2 = additional

Creates a interupt record

recordRemove(name)

name - example: "example.com"

Deletes an interupt record

ipToData(ip)

This returns the data required for intercepting A and AAAA types