1.1.1 • Published 2 years ago

udns.js v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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 blob.kat@hotmail.com

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago