edgeport - v1.0.6
    Preparing search index...

    Function encodeMessage

    • Encodes a complete DNS message (header, question, and RR sections) to its wire bytes.

      Section counts are derived from the array lengths. Each resource record is written with its raw rdata; names are always uncompressed. The result is the bare DNS message - the 2-byte TCP length prefix is added by the transport, not here.

      Parameters

      Returns Uint8Array

      The encoded message octets.

      If a name or label is out of range.

      1.0.4

      import { encodeMessage, RecordType, RecordClass, Opcode, ResponseCode } from 'edgeport/dns';

      const bytes = encodeMessage({
      id: 0x1234,
      flags: { qr: false, opcode: Opcode.QUERY, aa: false, tc: false, rd: true, ra: false,
      z: false, ad: false, cd: false, rcode: ResponseCode.NOERROR },
      question: [{ name: 'example.com', type: RecordType.A, class: RecordClass.IN }],
      answer: [], authority: [], additional: []
      });