Replacer is a class that replaces placeholders in a string with values from a DNSRequest or DNSResponse. The replacerMap is a map of keys to functions that take a DNSRequest or DNSResponse and return a string.

The default log format replaces the following keys:

  • remote: The remote address of the connection
  • port: The remote port of the connection
  • operation: The operation being performed (query or response)
  • id: The ID of the packet
  • type: The rrtype of the question
  • class: The rrclass of the question
  • name: The name of the question
  • proto: The protocol being used (UDP, TCP, DoH, etc.)
  • rcode: The response code of the packet
  • rflags: The flags of the packet, comma-separated
  • duration: The duration of the request in seconds (only available for responses)

You may customize this format by providing a different format string to the constructor. If you use keys not in the replacerMap, you will need to provide a custom replacer function for that key or it will not be replaced.

You may also provide any custom class that satisifes the replacer interface's replace method.

Implements

Constructors

Properties

Methods

Constructors

Properties

format: string
replacerMap: {
    [key: string]: ((req: DNSRequest | DNSResponse) => string | undefined);
} = ...

Methods