Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prettify): prettify TLSA #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ function prettify(msg) {
case 'DS':
rr.data.digest = rr.data.digest.toString('hex');
break;
case 'TLSA':
rr.data.certificate = rr.data.certificate.toString('hex');
break;
case 'NSEC3':
rr.data.salt = rr.data.salt.toString('hex');
rr.data.nextDomain = base32Encode(rr.data.nextDomain, 'RFC4648-HEX').replace('=', '')
Expand Down
11 changes: 10 additions & 1 deletion lib/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {makeQuery, DohResolver, sendDohMsg, MethodNotAllowedError, isMethodAllowed, dnsPacket} = require('.');
const {makeQuery, DohResolver, sendDohMsg, MethodNotAllowedError, isMethodAllowed, dnsPacket, prettify} = require('.');

test('DNS query message should be created', () => {
expect(makeQuery('example.com')).toBeTruthy();
Expand Down Expand Up @@ -65,6 +65,15 @@ test('DohResolver.query() for example.com TXT contains answers', async () => {
}
});

test('prettify can handle TLSA', async () => {
// From '_443._tcp.good.dane.huque.com', 'TLSA'
const buf = Buffer.from('000081800001000100000000045f343433045f74637004676f6f640464616e6505687571756503636f6d0000340001c00c0034000100001c2000230301016e8d1119ab26b6ef204b33a4036f2835cab86b0833f36ee96642e5703b74486c', 'hex')
const msg = dnsPacket.decode(buf);

const [{ data }] = prettify(msg).answers;
expect(typeof data.certificate).toBe('string')
});

test('timeout works properly (and cloudflare doesn\'t respond within 1 millisecond)', async () => {
let msg = makeQuery('example.org');
try {
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"argparse": "^1.0.10",
"base32-encode": "^1.1.1",
"browserify": "^16.5.0",
"dns-packet": "^5.2.1",
"dns-packet": "^5.6.1",
"glob-parent": "^5.1.2",
"ws": "^7.4.6"
},
Expand Down