Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 646 Bytes

README.md

File metadata and controls

29 lines (22 loc) · 646 Bytes

DNS Authoritative Server

Installation

$ yarn add @krtn/dns-authoritative-server

Usage

const { TCPServer, UDPServer } = require('@krtn/dns-authoritative-server')

// (optional) restrict responder to handle only specific DNS zone
const zone = 'myzone'

// resolve IP address for the DNS name being requested
async function resolver (name) {
  console.log(`Resolving ${name}`)
  return name === `example.${zone}` ? '1.1.1.1' : null
}

// start UDP listener
const udpServer = new UDPServer(resolver, zone)
udpServer.start(53)

// start TCP listener
const tcpServer = new TCPServer(resolver, zone)
tcpServer.start(53)