Changes user-agent
This commit is contained in:
parent
1c37df8ddd
commit
108335b50c
1 changed files with 1 additions and 55 deletions
56
src/doh.js
56
src/doh.js
|
|
@ -68,7 +68,7 @@ function sendDohMsg(packet, url, timeout) {
|
|||
let requestOptions;
|
||||
const headers = {
|
||||
'Accept': 'application/dns-message',
|
||||
'User-Agent': 'domain-forward/1.0.0'
|
||||
'User-Agent': 'domain-forward/1.x'
|
||||
};
|
||||
const dnsQueryParam = buf.toString('base64').toString('utf-8').replace(/=/g, '');
|
||||
url = `${url}?dns=${dnsQueryParam}`;
|
||||
|
|
@ -116,58 +116,4 @@ function sendDohMsg(packet, url, timeout) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 'Prettifies' a dnsPacket message.
|
||||
*
|
||||
* Namely, this convert Buffers the the appropriate presentation format.
|
||||
* This is useful to make json human readable.
|
||||
*
|
||||
* *NOTE* This function may modify the message such that it no longer works with dnsPacket.
|
||||
* Caution should be used when calling this object on query packets before sending them
|
||||
*
|
||||
* @param msg {object} a dnsPacket
|
||||
* @returns {object} the msg which has been modified in-place. *May not be a valid <dnsPacket> afterwards*
|
||||
*/
|
||||
function prettify(msg) {
|
||||
for (const rr of (msg['answers'] || []).concat((msg['authorities'] || []))) {
|
||||
if (rr.hasOwnProperty('data')) {
|
||||
switch (rr.type) {
|
||||
case 'TXT':
|
||||
rr.data = rr.data.toString('utf8');
|
||||
break;
|
||||
case 'DNSKEY':
|
||||
rr.data.key = rr.data.key.toString('base64').replace('=', '');
|
||||
break;
|
||||
case 'DS':
|
||||
rr.data.digest = rr.data.digest.toString('hex');
|
||||
break;
|
||||
case 'NSEC3':
|
||||
rr.data.salt = rr.data.salt.toString('hex');
|
||||
rr.data.nextDomain = base32Encode(rr.data.nextDomain, 'RFC4648-HEX').replace('=', '')
|
||||
break;
|
||||
case 'RRSIG':
|
||||
rr.data.signature = rr.data.signature.toString('base64').replace('=', '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const rr of (msg['additionals'] || [])) {
|
||||
if (rr.type === 'OPT') {
|
||||
for (const opt of rr['options']) {
|
||||
switch(opt.code) {
|
||||
case 12:
|
||||
opt.length = opt.data.length;
|
||||
opt.data = opt.data.toString('hex').substring(0, 80);
|
||||
if (opt.data.length === 80 ) {
|
||||
opt.data += '...'
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
export default DohResolver;
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue