Skip to main content

Entry function

The Scriptable DNS pipeline executes through a statically defined function handleQuery. To return a response to the query, you can return one of the DNS response objects as documented in the Query Response Object Types.
export default function handleQuery(query) {
  return new ARecord("111.111.111.111", 30);
}
console.log is intended for use within the Script Editor only. Please remove all logging statements before saving or publishing, as they may cause your script to fail at runtime.

Query object

The entry function is passed a DnsRequest object parameter called query that contains the information about the request, such as the hostname, country, remote IP, etc.

DnsRequest

FieldTypeDescription
requestDnsQueryThe DNS query request that contains the details about the query

DnsQuery

FieldTypeDescription
hostnamestringThe hostname that is being queried
clientIPstringThe IP of the remote client that sent the DNS query
queryTypestringThe query question type (A, AAAA, TXT)
ednsIPstringThe EDNS0 IP of the DNS query that was attached by the client
geoLocationGeoLocationThe geo location of the client
serverZonestringThe server zone of the DNS server that received the query (DE, UK, SG, etc.)

GeoLocation

FieldTypeDescription
latitudedoubleThe latitude location of the client
longitudedoubleThe longitude location of the client
countrystringThe detected two letter ISO country code of the client
asnlongThe detected ASN number of the client