Adding function to Recursion Available flag from header dynamicly

This commit is contained in:
Fabian Stamm 2018-05-13 22:34:20 +02:00
parent e5c55b402b
commit 8d3b541d3d
5 changed files with 14 additions and 4 deletions

1
lib/request.d.ts vendored
View File

@ -103,6 +103,7 @@ export declare class Request implements Message {
_packet: Buffer;
constructor(packet: Buffer, sendCallback: (packet: Buffer) => any);
error(error: ErrorCodes): void;
noRecursion(): void;
send(): void;
serialize(truncate?: boolean, rcode?: 0 | 1 | 2 | 3 | 4 | 5): Buffer;
private serializeHeader();

View File

@ -176,6 +176,7 @@ class Request {
this._header = headerParser.parse(headerData);
this._header.AD = 0;
this._header.RCODE = types_1.ErrorCodes.NoError;
this._header.RA = this._header.RD;
this._questions = parseQuestions(this._header.QDCOUNT, bodyData);
}
get header() {
@ -188,6 +189,9 @@ class Request {
if (this._header.RCODE === types_1.ErrorCodes.NoError)
this._header.RCODE = error;
}
noRecursion() {
this._header.RA = 0;
}
send() {
this.sendCallback(this.serialize());
}
@ -198,7 +202,6 @@ class Request {
this._header.NSCOUNT = this.authorities.length;
this._header.QR = 1;
this._header.RCODE = rcode;
this._header.RA = 0;
let questions = this.questions.map(this.serializeQuestion, this);
let answers = this.answers.map(this.serializeResourceRecord, this);
let authority = this.authorities.map(this.serializeResourceRecord, this);

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "nodename-core",
"version": "0.1.7",
"version": "0.1.8",
"main": "lib/listener.js",
"types": "lib/listener.d.ts",
"author": "Fabian Stamm <dev@fabianstamm.de>",

View File

@ -213,6 +213,8 @@ export class Request implements Message {
this._header = <any>headerParser.parse(headerData);
this._header.AD = 0;
this._header.RCODE = ErrorCodes.NoError;
this._header.RA = this._header.RD;
this._questions = parseQuestions(this._header.QDCOUNT, bodyData);
}
@ -221,6 +223,10 @@ export class Request implements Message {
this._header.RCODE = error;
}
noRecursion() {
this._header.RA = 0;
}
send() {
this.sendCallback(this.serialize());
}
@ -232,7 +238,7 @@ export class Request implements Message {
this._header.NSCOUNT = this.authorities.length;
this._header.QR = 1;
this._header.RCODE = rcode;
this._header.RA = 0;
let questions = this.questions.map(this.serializeQuestion, this)
let answers = this.answers.map(this.serializeResourceRecord, this)
let authority = this.authorities.map(this.serializeResourceRecord, this)