Fathom v0.2

component fathom.proto.dns

This component provides an API for the DNS protocol.

Methods

Methods Returns Description
create( proto ) void static This function creates and returns a DNS object.

Parameters:

  • proto <string> Indicates the protocol to be used for communication with the resolver, i.e., either 'udp' or 'tcp'.
lookup( callback, url ) void static This function implements an asynchronous DNS lookup.
(1) Needing to provide a URL is cumbersome and unintuitive. (2) Error semantics are missing.

Parameters:

  • callback <function> Fathom invokes this callback upon arrival of the DNS response. If successful, the callback receives a dictionary whose members convey the DNS response.
  • url <string> URL containing the name to look up.
query( dnsObj, domain, type, recordClass, flags ) void static This function creates a DNS query.

Parameters:

  • dnsObj <object> This is the DNS object created using the 'create' API.
  • domain <string> This is the domain to be resolved.
  • type <integer> This is the DNS record type, e.g., 1 for 'A' as mentioned in RFC1035 (and other RFCs), etc.
  • recordClass <integer> This is the DNS record class, e.g., 1 for 'IN', 2 for 'CS', 3 for 'CH', 4 for 'HS', etc.
  • flags <integer> This is the DNS flag options, e.g., '0x0100' for query.
response( dnsObj, buf, domain, callback ) void static This function creates a DNS response from the data received.

Parameters:

  • dnsObj <object> This is the DNS object created using the 'create' API.
  • buf <array> This is a buffer for the response received.
  • domain <string> This is the domain to be resolved.
  • callback <function> This is a callback to be invoked on receiveing a valid DNS response.
sendRecv( dnsObj, server, port, data, sendCallback, receiveCallback ) void static This API performs low-level socket operations based on the protocol selected and sends and receives data.

Parameters:

  • dnsObj <object> This is the DNS object created using the 'create' API.
  • server <string> This is the IP for the DNS resolver.
  • port <integer> This the port to be used on the resolver.
  • data <array> This is typically the return value of the query API.
  • sendCallback <function> This is a callback to be invoked on a socket send operation.
  • receiveCallback <function> This is a callback to be invoked on a socket receive operation. Typically, it should invoke the response API to parse the response into a DNS response.