A pure TypeScript, modular DNS server inspired by Express, Nest.js, and CoreDNS.
⚠️ WARNING: this framework is under active development and is in its very early days. There may be changes to the core APIs and right now no guarantees are made about its stability.
npm i --save dinodns
DinoDNS is an event-based, pure-TypeScript DNS server framework.
Unlike most other DNS servers, it is not a standalone application — instead, it is meant to provide a convenient, familiar API to lower the bar for authoring efficient, scalable, bespoke DNS servers.
If you're comfortable with the Express API, you should feel right at home with DinoDNS.
Docs are available at dinodns.dev. API documentation is also separately available.
DinoDNS embraces the Express-style method of defining handlers for your application. You simply create a server, define your middleware and handlers, and the rest is handled by the router.
Middleware are registered using a familiar syntax:
server.use((req, res, next) => {...});
And handlers are registered similarly, the server's handle
method. For handlers, you must also pass in the domain string you wish to match against. Wildcards are supported, and match in accordance with RFC 1034.
server.handle('example.com', (req, res) => {...})
A complete, working "hello world" application is defined below:
import { DefaultServer, DNSOverTCP, DNSOverUDP } from 'dinodns/common';
const server = new DefaultServer({
networks: [new DNSOverTCP({ address: '0.0.0.0', port: 1053 }), new DNSOverUDP({ address: '0.0.0.0', port: 1053 })],
});
server.handle('example.com', (req, res) => {
const { type } = req.packet.questions[0];
switch (type) {
case 'TXT':
return res.answer({
name: 'example.com',
type: 'TXT',
class: 'IN',
ttl: 300,
data: 'Hello, World!',
});
default:
return res.errors.notImplemented();
}
});
server.start(() => {
console.log('Server started');
});