udns.js
v1.1.1
Published
Performant DNS server
Downloads
10
Readme
Ultra-perfromant Node DNS server
import { DNSServer, Record } from 'udns.js'
const server = new DNSServer()
server.onrequest = (packet) => {
console.log('Got DNS request with questions: ', packet.questions.map(q => q.name))
for(const {name} of packet.questions){
// Alternatively supply an integer (e.g const answer = 0x01020304)
const answer = '1.2.3.4'
console.log('Responding to', name, 'with', answer)
packet.answers.push(Record.A(name, answer))
}
}
await server.listen(53)
console.log('DNS server listening on port 53')
~/Desktop$ dig @127.0.0.1 google.com
; <<>> DiG 9.10.6 <<>> @127.0.0.1 google.com
; (1 server found)
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 3600 IN A 1.2.3.4
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; MSG SIZE rcvd: 65
Got DNS request with questions: [ 'google.com' ]
Responding to google.com with 1.2.3.4
Security Issues
Please report privately to [email protected]