Skip to main content
Each response object usually consists of a constructor that receives a string representation of the value and a TTL value parameter that determines how long the response client should cache the object. Objects can be returned as a single object or as an array of objects depending on the desired output.

Supported response objects

Example response

Below is an example code snippet to illustrate how to return a dynamic DNS response to a DNS query. If the request is coming from Germany, then 222.222.222.222 is returned, otherwise, 111.111.111.111 is returned.
export default function handleQuery(query) {
    if (query.request.geoLocation.country == "DE") {
        return new ARecord("222.222.222.222", 30);
    }
    
    return new ARecord("111.111.111.111", 30);
}

ARecord

The ARecord represents the A type DNS answer to return A records.
declare class ARecord {
    constructor(ip: string, ttl: number = 30);

    /**
     * The IP of the A record
     */
    ip: string;

    /**
     * The TTL of the answer
     */
    ttl: number;
}

AaaaRecord

The AaaaRecord represents the AAAA type DNS answer to return AAAA records.
declare class AaaaRecord {
    constructor(ip: string, ttl: number = 30);

    /**
     * The IP of the AAAA record
     */
    ip: string;

    /**
     * The TTL of the answer
     */
    ttl: number;
}

Cname Record

The CnameRecord represents the CNAME type DNS answer to return CNAME records.
declare class CnameRecord {
    constructor(hostname: string, ttl: number = 30);

    /**
     * The hostname of the CNAME record
     */
    hostname: string;

    /**
     * The TTL of the answer
     */
    ttl: number;
}

PullZoneRecord

The PullZoneRecord is used to map the response to a Pull Zone response, meaning the DNS system will automatically map the response to the appropriate A or AAAA records for this specific pull zone.
declare class PullZoneRecord {
    constructor(pullzone: string);

    /**
     * The name of the pull zone
     */
    pullzone: string;
}