Skip to content

A minimal dns parser and server write by nodejs. Best for learning dns message.

License

Notifications You must be signed in to change notification settings

wwwzbwcom/minimal-dns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minimal-dns

A minimal, zero dependencies DNS parser and server write by Node.js. Best for learning structure of DNS message.

Dependencies

Node.js

Usage

Example

There is a basic example in main.js

simply run

node main

under the project directory you can start a dns server on your ip (redirecting the google DNS).

DNS Parser

Using

const DNSMessage = require('./dns-parser');

you can import the DNSMessage class, it has toBuffer() and fromBuffer() methods that can parse DNS message from Buffer, or encode DNS Message to Buffer.

DNSServer

Using

const { DNSServer, DNSRecord } = require('./dns-server');

you can import the DNSServer class。

With

var dnsServer = new DNSServer();

you can start a DNS Server on 0.0.0.0:53 (Port 53 of all available IPs on your computer).

The DNSServer class has a addRecord method, With

dnsServer.addRecord(new DNSRecord("example.com.", "1.1.1.1"));

you can add a custom DNS Records to your DNS Server.

Functions

DNS Parser

  • Parse DNS Message From Socket Message
  • Encode DNS Message to Socket Message

DNS Server

  • Can add some Custom DNS Records
  • Can setup a remote DNS Server and redirect the query (When missing custom DNS Records)

About

A minimal dns parser and server write by nodejs. Best for learning dns message.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published