// This file is generated by go generate

export interface SVCBKeyValue {}

export interface EDNS0 {}

// Helper function to quote strings containing special DNS characters (spaces, quotes, semicolons, parentheses)
function quoteStringIfNeeded(s: string): string {
    if (s.match(/[\s;()\"]/)) {
        return JSON.stringify(s);
    }
    return s;
}

export interface dnsRR {
    [key: string]: any;
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    A?: string;
    Ns?: string;
    Md?: string;
    Mf?: string;
    Target?: string;
    Mbox?: string;
    Serial?: number;
    Refresh?: number;
    Retry?: number;
    Expire?: number;
    Minttl?: number;
    Mb?: string;
    Mg?: string;
    Mr?: string;
    Data?: string;
    Ptr?: string;
    Cpu?: string;
    Os?: string;
    Rmail?: string;
    Email?: string;
    Preference?: number;
    Mx?: string;
    Txt?: string;
    Subtype?: number;
    Hostname?: string;
    PSDNAddress?: string;
    Address?: string | number;
    SubAddress?: string;
    Host?: string;
    Map822?: string;
    Mapx400?: string;
    Longitude?: string | number;
    Latitude?: string | number;
    Altitude?: string | number;
    AAAA?: string;
    Version?: number;
    Size?: number;
    HorizPre?: number;
    VertPre?: number;
    Endpoint?: string;
    Locator?: string;
    Priority?: number;
    Weight?: number;
    Port?: number;
    Order?: number;
    Flags?: string | number;
    Service?: string;
    Regexp?: string;
    Replacement?: string;
    Exchanger?: string;
    Type?: number;
    KeyTag?: number;
    Algorithm?: number | string;
    Certificate?: string;
    Option?: Array<EDNS0>;
    Prefixes?: Array<{
            Negation: boolean;
            Network: {
                IP: string;
                Mask: Array<number>;
            };
        }>;
    DigestType?: number;
    Digest?: string;
    FingerPrint?: string;
    Precedence?: number;
    GatewayType?: number;
    GatewayAddr?: string;
    GatewayHost?: string;
    PublicKey?: string;
    TypeCovered?: number;
    Labels?: number;
    OrigTtl?: number;
    Expiration?: number;
    Inception?: number;
    SignerName?: string;
    Signature?: string;
    NextDomain?: string;
    TypeBitMap?: Array<number>;
    Protocol?: number;
    Hash?: number;
    Iterations?: number;
    SaltLength?: number;
    Salt?: string;
    HashLength?: number;
    Usage?: number;
    Selector?: number;
    MatchingType?: number;
    HitLength?: number;
    PublicKeyAlgorithm?: number;
    PublicKeyLength?: number;
    Hit?: string;
    RendezvousServers?: Array<string>;
    ZSData?: Array<string>;
    PreviousName?: string;
    NextName?: string;
    Scheme?: number;
    Value?: Array<SVCBKeyValue> | string;
    Uinfo?: string;
    Uid?: number;
    Gid?: number;
    NodeID?: number;
    Locator32?: string;
    Locator64?: number;
    Fqdn?: string;
    Mode?: number;
    Error?: number;
    KeySize?: number;
    Key?: string;
    OtherLen?: number;
    OtherData?: string;
    TimeSigned?: number;
    Fudge?: number;
    MACSize?: number;
    MAC?: string;
    OrigId?: number;
    Flag?: number;
    Tag?: string;
}

export interface dnsTypeA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    A: string;
}

export interface dnsTypeNS {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Ns: string;
}

export interface dnsTypeMD {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Md: string;
}

export interface dnsTypeMF {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Mf: string;
}

export interface dnsTypeCNAME {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Target: string;
}

export interface dnsTypeSOA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Ns: string;
    Mbox: string;
    Serial: number;
    Refresh: number;
    Retry: number;
    Expire: number;
    Minttl: number;
}

export interface dnsTypeMB {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Mb: string;
}

export interface dnsTypeMG {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Mg: string;
}

export interface dnsTypeMR {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Mr: string;
}

export interface dnsTypeNULL {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Data: string;
}

export interface dnsTypePTR {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Ptr: string;
}

export interface dnsTypeHINFO {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Cpu: string;
    Os: string;
}

export interface dnsTypeMINFO {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Rmail: string;
    Email: string;
}

export interface dnsTypeMX {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Mx: string;
}

export interface dnsTypeTXT {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Txt: string;
}

export interface dnsTypeRP {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Mbox: string;
    Txt: string;
}

export interface dnsTypeAFSDB {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Subtype: number;
    Hostname: string;
}

export interface dnsTypeX25 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    PSDNAddress: string;
}

export interface dnsTypeISDN {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Address: string;
    SubAddress: string;
}

export interface dnsTypeRT {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Host: string;
}

export interface dnsTypeNSAP_PTR {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Ptr: string;
}

export interface dnsTypeSIG {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    TypeCovered: number;
    Algorithm: number;
    Labels: number;
    OrigTtl: number;
    Expiration: number;
    Inception: number;
    KeyTag: number;
    SignerName: string;
    Signature: string;
}

export interface dnsTypeKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Flags: number;
    Protocol: number;
    Algorithm: number;
    PublicKey: string;
}

export interface dnsTypePX {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Map822: string;
    Mapx400: string;
}

export interface dnsTypeGPOS {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Longitude: string;
    Latitude: string;
    Altitude: string;
}

export interface dnsTypeAAAA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    AAAA: string;
}

export interface dnsTypeLOC {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Version: number;
    Size: number;
    HorizPre: number;
    VertPre: number;
    Latitude: number;
    Longitude: number;
    Altitude: number;
}

export interface dnsTypeNXT {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    NextDomain: string;
    TypeBitMap: Array<number>;
}

export interface dnsTypeEID {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Endpoint: string;
}

export interface dnsTypeNIMLOC {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Locator: string;
}

export interface dnsTypeSRV {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Priority: number;
    Weight: number;
    Port: number;
    Target: string;
}

export interface dnsTypeNAPTR {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Order: number;
    Preference: number;
    Flags: string;
    Service: string;
    Regexp: string;
    Replacement: string;
}

export interface dnsTypeKX {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Exchanger: string;
}

export interface dnsTypeCERT {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Type: number;
    KeyTag: number;
    Algorithm: number;
    Certificate: string;
}

export interface dnsTypeDNAME {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Target: string;
}

export interface dnsTypeOPT {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Option: Array<EDNS0>;
}

export interface dnsTypeAPL {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Prefixes: Array<{
            Negation: boolean;
            Network: {
                IP: string;
                Mask: Array<number>;
            };
        }>;
}

export interface dnsTypeDS {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    KeyTag: number;
    Algorithm: number;
    DigestType: number;
    Digest: string;
}

export interface dnsTypeSSHFP {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Algorithm: number;
    Type: number;
    FingerPrint: string;
}

export interface dnsTypeIPSECKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Precedence: number;
    GatewayType: number;
    Algorithm: number;
    GatewayAddr: string;
    GatewayHost: string;
    PublicKey: string;
}

export interface dnsTypeRRSIG {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    TypeCovered: number;
    Algorithm: number;
    Labels: number;
    OrigTtl: number;
    Expiration: number;
    Inception: number;
    KeyTag: number;
    SignerName: string;
    Signature: string;
}

export interface dnsTypeNSEC {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    NextDomain: string;
    TypeBitMap: Array<number>;
}

export interface dnsTypeDNSKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Flags: number;
    Protocol: number;
    Algorithm: number;
    PublicKey: string;
}

export interface dnsTypeDHCID {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Digest: string;
}

export interface dnsTypeNSEC3 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Hash: number;
    Flags: number;
    Iterations: number;
    SaltLength: number;
    Salt: string;
    HashLength: number;
    NextDomain: string;
    TypeBitMap: Array<number>;
}

export interface dnsTypeNSEC3PARAM {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Hash: number;
    Flags: number;
    Iterations: number;
    SaltLength: number;
    Salt: string;
}

export interface dnsTypeTLSA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Usage: number;
    Selector: number;
    MatchingType: number;
    Certificate: string;
}

export interface dnsTypeSMIMEA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Usage: number;
    Selector: number;
    MatchingType: number;
    Certificate: string;
}

export interface dnsTypeHIP {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    HitLength: number;
    PublicKeyAlgorithm: number;
    PublicKeyLength: number;
    Hit: string;
    PublicKey: string;
    RendezvousServers: Array<string>;
}

export interface dnsTypeNINFO {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    ZSData: Array<string>;
}

export interface dnsTypeRKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Flags: number;
    Protocol: number;
    Algorithm: number;
    PublicKey: string;
}

export interface dnsTypeTALINK {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    PreviousName: string;
    NextName: string;
}

export interface dnsTypeCDS {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    KeyTag: number;
    Algorithm: number;
    DigestType: number;
    Digest: string;
}

export interface dnsTypeCDNSKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Flags: number;
    Protocol: number;
    Algorithm: number;
    PublicKey: string;
}

export interface dnsTypeOPENPGPKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    PublicKey: string;
}

export interface dnsTypeCSYNC {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Serial: number;
    Flags: number;
    TypeBitMap: Array<number>;
}

export interface dnsTypeZONEMD {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Serial: number;
    Scheme: number;
    Hash: number;
    Digest: string;
}

export interface dnsTypeSVCB {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Priority: number;
    Target: string;
    Value: Array<SVCBKeyValue>;
}

export interface dnsTypeHTTPS {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Priority: number;
    Target: string;
    Value: Array<SVCBKeyValue>;
}

export interface dnsTypeSPF {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Txt: string;
}

export interface dnsTypeUINFO {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Uinfo: string;
}

export interface dnsTypeUID {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Uid: number;
}

export interface dnsTypeGID {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Gid: number;
}

export interface dnsTypeNID {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    NodeID: number;
}

export interface dnsTypeL32 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Locator32: string;
}

export interface dnsTypeL64 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Locator64: number;
}

export interface dnsTypeLP {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Preference: number;
    Fqdn: string;
}

export interface dnsTypeEUI48 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Address: number;
}

export interface dnsTypeEUI64 {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Address: number;
}

export interface dnsTypeNXNAME {
    Name: string;
    Rrtype: number;
    Class: number;
    Ttl: number;
    Rdlength: number;
}

export interface dnsTypeTKEY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Algorithm: string;
    Inception: number;
    Expiration: number;
    Mode: number;
    Error: number;
    KeySize: number;
    Key: string;
    OtherLen: number;
    OtherData: string;
}

export interface dnsTypeTSIG {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Algorithm: string;
    TimeSigned: number;
    Fudge: number;
    MACSize: number;
    MAC: string;
    OrigId: number;
    Error: number;
    OtherLen: number;
    OtherData: string;
}

export interface dnsTypeANY {
    Name: string;
    Rrtype: number;
    Class: number;
    Ttl: number;
    Rdlength: number;
}

export interface dnsTypeURI {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Priority: number;
    Weight: number;
    Target: string;
}

export interface dnsTypeCAA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Flag: number;
    Tag: string;
    Value: string;
}

export interface dnsTypeAVC {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Txt: string;
}

export interface dnsTypeAMTRELAY {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Precedence: number;
    GatewayType: number;
    GatewayAddr: string;
    GatewayHost: string;
}

export interface dnsTypeRESINFO {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    Txt: string;
}

export interface dnsTypeTA {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    KeyTag: number;
    Algorithm: number;
    DigestType: number;
    Digest: string;
}

export interface dnsTypeDLV {
    Hdr: {
        Name: string;
        Rrtype: number;
        Class: number;
        Ttl: number;
        Rdlength: number;
    };
    KeyTag: number;
    Algorithm: number;
    DigestType: number;
    Digest: string;
}

export interface dnsResource {
    a?: dnsTypeA;
    ns?: dnsTypeNS | Array<dnsTypeNS>;
    md?: dnsTypeMD;
    mf?: dnsTypeMF;
    cname?: dnsTypeCNAME;
    soa?: dnsTypeSOA;
    mb?: dnsTypeMB;
    mg?: dnsTypeMG;
    mr?: dnsTypeMR;
    null?: dnsTypeNULL;
    ptr?: dnsTypePTR;
    hinfo?: dnsTypeHINFO;
    minfo?: dnsTypeMINFO;
    mx?: dnsTypeMX | Array<dnsTypeMX>;
    txt?: dnsTypeTXT;
    rp?: dnsTypeRP;
    afsdb?: dnsTypeAFSDB;
    x25?: dnsTypeX25;
    isdn?: dnsTypeISDN;
    rt?: dnsTypeRT;
    nsap_ptr?: dnsTypeNSAP_PTR;
    sig?: dnsTypeSIG;
    key?: dnsTypeKEY;
    px?: dnsTypePX;
    gpos?: dnsTypeGPOS;
    aaaa?: dnsTypeAAAA;
    loc?: dnsTypeLOC;
    nxt?: dnsTypeNXT;
    eid?: dnsTypeEID;
    nimloc?: dnsTypeNIMLOC;
    srv?: dnsTypeSRV;
    naptr?: dnsTypeNAPTR;
    kx?: dnsTypeKX;
    cert?: dnsTypeCERT;
    dname?: dnsTypeDNAME;
    opt?: dnsTypeOPT;
    apl?: dnsTypeAPL;
    ds?: dnsTypeDS | Array<dnsTypeDS>;
    sshfp?: dnsTypeSSHFP;
    ipseckey?: dnsTypeIPSECKEY;
    rrsig?: dnsTypeRRSIG;
    nsec?: dnsTypeNSEC;
    dnskey?: dnsTypeDNSKEY;
    dhcid?: dnsTypeDHCID;
    nsec3?: dnsTypeNSEC3;
    nsec3param?: dnsTypeNSEC3PARAM;
    tlsa?: dnsTypeTLSA;
    smimea?: dnsTypeSMIMEA;
    hip?: dnsTypeHIP;
    ninfo?: dnsTypeNINFO;
    rkey?: dnsTypeRKEY;
    talink?: dnsTypeTALINK;
    cds?: dnsTypeCDS;
    cdnskey?: dnsTypeCDNSKEY;
    openpgpkey?: dnsTypeOPENPGPKEY;
    csync?: dnsTypeCSYNC;
    zonemd?: dnsTypeZONEMD;
    svcb?: dnsTypeSVCB;
    https?: dnsTypeHTTPS;
    spf?: dnsTypeSPF;
    uinfo?: dnsTypeUINFO;
    uid?: dnsTypeUID;
    gid?: dnsTypeGID;
    nid?: dnsTypeNID;
    l32?: dnsTypeL32;
    l64?: dnsTypeL64;
    lp?: dnsTypeLP;
    eui48?: dnsTypeEUI48;
    eui64?: dnsTypeEUI64;
    nxname?: dnsTypeNXNAME;
    tkey?: dnsTypeTKEY;
    tsig?: dnsTypeTSIG;
    any?: dnsTypeANY;
    uri?: dnsTypeURI;
    caa?: dnsTypeCAA | Array<dnsTypeCAA>;
    avc?: dnsTypeAVC;
    amtrelay?: dnsTypeAMTRELAY;
    resinfo?: dnsTypeRESINFO;
    ta?: dnsTypeTA;
    dlv?: dnsTypeDLV;
}

export function getRrtype(input: string): number {
    switch (input) {
        case "NONE":
        case "none":
            return 0;
        case "A":
        case "a":
            return 1;
        case "NS":
        case "ns":
            return 2;
        case "MD":
        case "md":
            return 3;
        case "MF":
        case "mf":
            return 4;
        case "CNAME":
        case "cname":
            return 5;
        case "SOA":
        case "soa":
            return 6;
        case "MB":
        case "mb":
            return 7;
        case "MG":
        case "mg":
            return 8;
        case "MR":
        case "mr":
            return 9;
        case "NULL":
        case "null":
            return 10;
        case "PTR":
        case "ptr":
            return 12;
        case "HINFO":
        case "hinfo":
            return 13;
        case "MINFO":
        case "minfo":
            return 14;
        case "MX":
        case "mx":
            return 15;
        case "TXT":
        case "txt":
            return 16;
        case "RP":
        case "rp":
            return 17;
        case "AFSDB":
        case "afsdb":
            return 18;
        case "X25":
        case "x25":
            return 19;
        case "ISDN":
        case "isdn":
            return 20;
        case "RT":
        case "rt":
            return 21;
        case "NSAP-PTR":
        case "nsap-ptr":
            return 23;
        case "SIG":
        case "sig":
            return 24;
        case "KEY":
        case "key":
            return 25;
        case "PX":
        case "px":
            return 26;
        case "GPOS":
        case "gpos":
            return 27;
        case "AAAA":
        case "aaaa":
            return 28;
        case "LOC":
        case "loc":
            return 29;
        case "NXT":
        case "nxt":
            return 30;
        case "EID":
        case "eid":
            return 31;
        case "NIMLOC":
        case "nimloc":
            return 32;
        case "SRV":
        case "srv":
            return 33;
        case "ATMA":
        case "atma":
            return 34;
        case "NAPTR":
        case "naptr":
            return 35;
        case "KX":
        case "kx":
            return 36;
        case "CERT":
        case "cert":
            return 37;
        case "DNAME":
        case "dname":
            return 39;
        case "OPT":
        case "opt":
            return 41;
        case "APL":
        case "apl":
            return 42;
        case "DS":
        case "ds":
            return 43;
        case "SSHFP":
        case "sshfp":
            return 44;
        case "IPSECKEY":
        case "ipseckey":
            return 45;
        case "RRSIG":
        case "rrsig":
            return 46;
        case "NSEC":
        case "nsec":
            return 47;
        case "DNSKEY":
        case "dnskey":
            return 48;
        case "DHCID":
        case "dhcid":
            return 49;
        case "NSEC3":
        case "nsec3":
            return 50;
        case "NSEC3PARAM":
        case "nsec3param":
            return 51;
        case "TLSA":
        case "tlsa":
            return 52;
        case "SMIMEA":
        case "smimea":
            return 53;
        case "HIP":
        case "hip":
            return 55;
        case "NINFO":
        case "ninfo":
            return 56;
        case "RKEY":
        case "rkey":
            return 57;
        case "TALINK":
        case "talink":
            return 58;
        case "CDS":
        case "cds":
            return 59;
        case "CDNSKEY":
        case "cdnskey":
            return 60;
        case "OPENPGPKEY":
        case "openpgpkey":
            return 61;
        case "CSYNC":
        case "csync":
            return 62;
        case "ZONEMD":
        case "zonemd":
            return 63;
        case "SVCB":
        case "svcb":
            return 64;
        case "HTTPS":
        case "https":
            return 65;
        case "SPF":
        case "spf":
            return 99;
        case "UINFO":
        case "uinfo":
            return 100;
        case "UID":
        case "uid":
            return 101;
        case "GID":
        case "gid":
            return 102;
        case "UNSPEC":
        case "unspec":
            return 103;
        case "NID":
        case "nid":
            return 104;
        case "L32":
        case "l32":
            return 105;
        case "L64":
        case "l64":
            return 106;
        case "LP":
        case "lp":
            return 107;
        case "EUI48":
        case "eui48":
            return 108;
        case "EUI64":
        case "eui64":
            return 109;
        case "NXNAME":
        case "nxname":
            return 128;
        case "TKEY":
        case "tkey":
            return 249;
        case "TSIG":
        case "tsig":
            return 250;
        case "IXFR":
        case "ixfr":
            return 251;
        case "AXFR":
        case "axfr":
            return 252;
        case "MAILB":
        case "mailb":
            return 253;
        case "MAILA":
        case "maila":
            return 254;
        case "ANY":
        case "any":
            return 255;
        case "URI":
        case "uri":
            return 256;
        case "CAA":
        case "caa":
            return 257;
        case "AVC":
        case "avc":
            return 258;
        case "AMTRELAY":
        case "amtrelay":
            return 260;
        case "RESINFO":
        case "resinfo":
            return 261;
        case "TA":
        case "ta":
            return 32768;
        case "DLV":
        case "dlv":
            return 32769;
        case "RESERVED":
        case "reserved":
            return 65535;
        default:
            throw "Unknown rrtype " + input;
    }
}

export function newRR(dn: string, rrtype: number): dnsRR {
    const rec = { Hdr: { Name: dn, Rrtype: rrtype, Class: 1, Ttl: 3600 } } as dnsRR;

    switch (rrtype) {
        case 1: // A
            rec.A = "";
            return rec;
        case 2: // NS
            rec.Ns = "";
            return rec;
        case 3: // MD
            rec.Md = "";
            return rec;
        case 4: // MF
            rec.Mf = "";
            return rec;
        case 5: // CNAME
            rec.Target = "";
            return rec;
        case 6: // SOA
            rec.Ns = "";
            rec.Mbox = "";
            rec.Serial = 0;
            rec.Refresh = 0;
            rec.Retry = 0;
            rec.Expire = 0;
            rec.Minttl = 0;
            return rec;
        case 7: // MB
            rec.Mb = "";
            return rec;
        case 8: // MG
            rec.Mg = "";
            return rec;
        case 9: // MR
            rec.Mr = "";
            return rec;
        case 10: // NULL
            rec.Data = "";
            return rec;
        case 12: // PTR
            rec.Ptr = "";
            return rec;
        case 13: // HINFO
            rec.Cpu = "";
            rec.Os = "";
            return rec;
        case 14: // MINFO
            rec.Rmail = "";
            rec.Email = "";
            return rec;
        case 15: // MX
            rec.Preference = 0;
            rec.Mx = "";
            return rec;
        case 16: // TXT
            rec.Txt = "";
            return rec;
        case 17: // RP
            rec.Mbox = "";
            rec.Txt = "";
            return rec;
        case 18: // AFSDB
            rec.Subtype = 0;
            rec.Hostname = "";
            return rec;
        case 19: // X25
            rec.PSDNAddress = "";
            return rec;
        case 20: // ISDN
            rec.Address = "";
            rec.SubAddress = "";
            return rec;
        case 21: // RT
            rec.Preference = 0;
            rec.Host = "";
            return rec;
        case 23: // NSAP-PTR
            rec.Ptr = "";
            return rec;
        case 24: // SIG
            rec.TypeCovered = 0;
            rec.Algorithm = 0;
            rec.Labels = 0;
            rec.OrigTtl = 0;
            rec.Expiration = 0;
            rec.Inception = 0;
            rec.KeyTag = 0;
            rec.SignerName = "";
            rec.Signature = "";
            return rec;
        case 25: // KEY
            rec.Flags = 0;
            rec.Protocol = 0;
            rec.Algorithm = 0;
            rec.PublicKey = "";
            return rec;
        case 26: // PX
            rec.Preference = 0;
            rec.Map822 = "";
            rec.Mapx400 = "";
            return rec;
        case 27: // GPOS
            rec.Longitude = "";
            rec.Latitude = "";
            rec.Altitude = "";
            return rec;
        case 28: // AAAA
            rec.AAAA = "";
            return rec;
        case 29: // LOC
            rec.Version = 0;
            rec.Size = 0;
            rec.HorizPre = 0;
            rec.VertPre = 0;
            rec.Latitude = 0;
            rec.Longitude = 0;
            rec.Altitude = 0;
            return rec;
        case 30: // NXT
            rec.NextDomain = "";
            rec.TypeBitMap = [];
            return rec;
        case 31: // EID
            rec.Endpoint = "";
            return rec;
        case 32: // NIMLOC
            rec.Locator = "";
            return rec;
        case 33: // SRV
            rec.Priority = 0;
            rec.Weight = 0;
            rec.Port = 0;
            rec.Target = "";
            return rec;
        case 35: // NAPTR
            rec.Order = 0;
            rec.Preference = 0;
            rec.Flags = "";
            rec.Service = "";
            rec.Regexp = "";
            rec.Replacement = "";
            return rec;
        case 36: // KX
            rec.Preference = 0;
            rec.Exchanger = "";
            return rec;
        case 37: // CERT
            rec.Type = 0;
            rec.KeyTag = 0;
            rec.Algorithm = 0;
            rec.Certificate = "";
            return rec;
        case 39: // DNAME
            rec.Target = "";
            return rec;
        case 42: // APL
            rec.Prefixes = [];
            return rec;
        case 43: // DS
            rec.KeyTag = 0;
            rec.Algorithm = 0;
            rec.DigestType = 0;
            rec.Digest = "";
            return rec;
        case 44: // SSHFP
            rec.Algorithm = 0;
            rec.Type = 0;
            rec.FingerPrint = "";
            return rec;
        case 45: // IPSECKEY
            rec.Precedence = 0;
            rec.GatewayType = 0;
            rec.Algorithm = 0;
            rec.GatewayAddr = "";
            rec.GatewayHost = "";
            rec.PublicKey = "";
            return rec;
        case 46: // RRSIG
            rec.TypeCovered = 0;
            rec.Algorithm = 0;
            rec.Labels = 0;
            rec.OrigTtl = 0;
            rec.Expiration = 0;
            rec.Inception = 0;
            rec.KeyTag = 0;
            rec.SignerName = "";
            rec.Signature = "";
            return rec;
        case 47: // NSEC
            rec.NextDomain = "";
            rec.TypeBitMap = [];
            return rec;
        case 48: // DNSKEY
            rec.Flags = 0;
            rec.Protocol = 0;
            rec.Algorithm = 0;
            rec.PublicKey = "";
            return rec;
        case 49: // DHCID
            rec.Digest = "";
            return rec;
        case 50: // NSEC3
            rec.Hash = 0;
            rec.Flags = 0;
            rec.Iterations = 0;
            rec.SaltLength = 0;
            rec.Salt = "";
            rec.HashLength = 0;
            rec.NextDomain = "";
            rec.TypeBitMap = [];
            return rec;
        case 51: // NSEC3PARAM
            rec.Hash = 0;
            rec.Flags = 0;
            rec.Iterations = 0;
            rec.SaltLength = 0;
            rec.Salt = "";
            return rec;
        case 52: // TLSA
            rec.Usage = 0;
            rec.Selector = 0;
            rec.MatchingType = 0;
            rec.Certificate = "";
            return rec;
        case 53: // SMIMEA
            rec.Usage = 0;
            rec.Selector = 0;
            rec.MatchingType = 0;
            rec.Certificate = "";
            return rec;
        case 55: // HIP
            rec.HitLength = 0;
            rec.PublicKeyAlgorithm = 0;
            rec.PublicKeyLength = 0;
            rec.Hit = "";
            rec.PublicKey = "";
            rec.RendezvousServers = [];
            return rec;
        case 56: // NINFO
            rec.ZSData = [];
            return rec;
        case 57: // RKEY
            rec.Flags = 0;
            rec.Protocol = 0;
            rec.Algorithm = 0;
            rec.PublicKey = "";
            return rec;
        case 58: // TALINK
            rec.PreviousName = "";
            rec.NextName = "";
            return rec;
        case 59: // CDS
            rec.KeyTag = 0;
            rec.Algorithm = 0;
            rec.DigestType = 0;
            rec.Digest = "";
            return rec;
        case 60: // CDNSKEY
            rec.Flags = 0;
            rec.Protocol = 0;
            rec.Algorithm = 0;
            rec.PublicKey = "";
            return rec;
        case 61: // OPENPGPKEY
            rec.PublicKey = "";
            return rec;
        case 62: // CSYNC
            rec.Serial = 0;
            rec.Flags = 0;
            rec.TypeBitMap = [];
            return rec;
        case 63: // ZONEMD
            rec.Serial = 0;
            rec.Scheme = 0;
            rec.Hash = 0;
            rec.Digest = "";
            return rec;
        case 64: // SVCB
            rec.Priority = 0;
            rec.Target = "";
            rec.Value = [];
            return rec;
        case 65: // HTTPS
            rec.Priority = 0;
            rec.Target = "";
            rec.Value = [];
            return rec;
        case 99: // SPF
            rec.Txt = "";
            return rec;
        case 100: // UINFO
            rec.Uinfo = "";
            return rec;
        case 101: // UID
            rec.Uid = 0;
            return rec;
        case 102: // GID
            rec.Gid = 0;
            return rec;
        case 104: // NID
            rec.Preference = 0;
            rec.NodeID = 0;
            return rec;
        case 105: // L32
            rec.Preference = 0;
            rec.Locator32 = "";
            return rec;
        case 106: // L64
            rec.Preference = 0;
            rec.Locator64 = 0;
            return rec;
        case 107: // LP
            rec.Preference = 0;
            rec.Fqdn = "";
            return rec;
        case 108: // EUI48
            rec.Address = 0;
            return rec;
        case 109: // EUI64
            rec.Address = 0;
            return rec;
        case 249: // TKEY
            rec.Algorithm = "";
            rec.Inception = 0;
            rec.Expiration = 0;
            rec.Mode = 0;
            rec.Error = 0;
            rec.KeySize = 0;
            rec.Key = "";
            rec.OtherLen = 0;
            rec.OtherData = "";
            return rec;
        case 250: // TSIG
            rec.Algorithm = "";
            rec.TimeSigned = 0;
            rec.Fudge = 0;
            rec.MACSize = 0;
            rec.MAC = "";
            rec.OrigId = 0;
            rec.Error = 0;
            rec.OtherLen = 0;
            rec.OtherData = "";
            return rec;
        case 256: // URI
            rec.Priority = 0;
            rec.Weight = 0;
            rec.Target = "";
            return rec;
        case 257: // CAA
            rec.Flag = 0;
            rec.Tag = "";
            rec.Value = "";
            return rec;
        case 258: // AVC
            rec.Txt = "";
            return rec;
        case 260: // AMTRELAY
            rec.Precedence = 0;
            rec.GatewayType = 0;
            rec.GatewayAddr = "";
            rec.GatewayHost = "";
            return rec;
        case 261: // RESINFO
            rec.Txt = "";
            return rec;
        case 32768: // TA
            rec.KeyTag = 0;
            rec.Algorithm = 0;
            rec.DigestType = 0;
            rec.Digest = "";
            return rec;
        case 32769: // DLV
            rec.KeyTag = 0;
            rec.Algorithm = 0;
            rec.DigestType = 0;
            rec.Digest = "";
            return rec;
        default: return rec;
    }
}

export function nsrrtype(input: number | string): string {
    switch (input) {
        case "0":
        case 0:
            return "None";
        case "1":
        case 1:
            return "A";
        case "2":
        case 2:
            return "NS";
        case "3":
        case 3:
            return "MD";
        case "4":
        case 4:
            return "MF";
        case "5":
        case 5:
            return "CNAME";
        case "6":
        case 6:
            return "SOA";
        case "7":
        case 7:
            return "MB";
        case "8":
        case 8:
            return "MG";
        case "9":
        case 9:
            return "MR";
        case "10":
        case 10:
            return "NULL";
        case "12":
        case 12:
            return "PTR";
        case "13":
        case 13:
            return "HINFO";
        case "14":
        case 14:
            return "MINFO";
        case "15":
        case 15:
            return "MX";
        case "16":
        case 16:
            return "TXT";
        case "17":
        case 17:
            return "RP";
        case "18":
        case 18:
            return "AFSDB";
        case "19":
        case 19:
            return "X25";
        case "20":
        case 20:
            return "ISDN";
        case "21":
        case 21:
            return "RT";
        case "23":
        case 23:
            return "NSAP-PTR";
        case "24":
        case 24:
            return "SIG";
        case "25":
        case 25:
            return "KEY";
        case "26":
        case 26:
            return "PX";
        case "27":
        case 27:
            return "GPOS";
        case "28":
        case 28:
            return "AAAA";
        case "29":
        case 29:
            return "LOC";
        case "30":
        case 30:
            return "NXT";
        case "31":
        case 31:
            return "EID";
        case "32":
        case 32:
            return "NIMLOC";
        case "33":
        case 33:
            return "SRV";
        case "34":
        case 34:
            return "ATMA";
        case "35":
        case 35:
            return "NAPTR";
        case "36":
        case 36:
            return "KX";
        case "37":
        case 37:
            return "CERT";
        case "39":
        case 39:
            return "DNAME";
        case "41":
        case 41:
            return "OPT";
        case "42":
        case 42:
            return "APL";
        case "43":
        case 43:
            return "DS";
        case "44":
        case 44:
            return "SSHFP";
        case "45":
        case 45:
            return "IPSECKEY";
        case "46":
        case 46:
            return "RRSIG";
        case "47":
        case 47:
            return "NSEC";
        case "48":
        case 48:
            return "DNSKEY";
        case "49":
        case 49:
            return "DHCID";
        case "50":
        case 50:
            return "NSEC3";
        case "51":
        case 51:
            return "NSEC3PARAM";
        case "52":
        case 52:
            return "TLSA";
        case "53":
        case 53:
            return "SMIMEA";
        case "55":
        case 55:
            return "HIP";
        case "56":
        case 56:
            return "NINFO";
        case "57":
        case 57:
            return "RKEY";
        case "58":
        case 58:
            return "TALINK";
        case "59":
        case 59:
            return "CDS";
        case "60":
        case 60:
            return "CDNSKEY";
        case "61":
        case 61:
            return "OPENPGPKEY";
        case "62":
        case 62:
            return "CSYNC";
        case "63":
        case 63:
            return "ZONEMD";
        case "64":
        case 64:
            return "SVCB";
        case "65":
        case 65:
            return "HTTPS";
        case "99":
        case 99:
            return "SPF";
        case "100":
        case 100:
            return "UINFO";
        case "101":
        case 101:
            return "UID";
        case "102":
        case 102:
            return "GID";
        case "103":
        case 103:
            return "UNSPEC";
        case "104":
        case 104:
            return "NID";
        case "105":
        case 105:
            return "L32";
        case "106":
        case 106:
            return "L64";
        case "107":
        case 107:
            return "LP";
        case "108":
        case 108:
            return "EUI48";
        case "109":
        case 109:
            return "EUI64";
        case "128":
        case 128:
            return "NXNAME";
        case "249":
        case 249:
            return "TKEY";
        case "250":
        case 250:
            return "TSIG";
        case "251":
        case 251:
            return "IXFR";
        case "252":
        case 252:
            return "AXFR";
        case "253":
        case 253:
            return "MAILB";
        case "254":
        case 254:
            return "MAILA";
        case "255":
        case 255:
            return "ANY";
        case "256":
        case 256:
            return "URI";
        case "257":
        case 257:
            return "CAA";
        case "258":
        case 258:
            return "AVC";
        case "260":
        case 260:
            return "AMTRELAY";
        case "261":
        case 261:
            return "RESINFO";
        case "32768":
        case 32768:
            return "TA";
        case "32769":
        case 32769:
            return "DLV";
        case "65535":
        case 65535:
            return "Reserved";
        default:
            return "#";
    }
}

export function rdatatostr(rr: dnsRR): string {
    switch (rr.Hdr.Rrtype) {
        case 1: { const rec = rr as dnsTypeA; return rec.A.toString(); } // A
        case 2: { const rec = rr as dnsTypeNS; return quoteStringIfNeeded(rec.Ns.toString()); } // NS
        case 3: { const rec = rr as dnsTypeMD; return quoteStringIfNeeded(rec.Md.toString()); } // MD
        case 4: { const rec = rr as dnsTypeMF; return quoteStringIfNeeded(rec.Mf.toString()); } // MF
        case 5: { const rec = rr as dnsTypeCNAME; return quoteStringIfNeeded(rec.Target.toString()); } // CNAME
        case 6: { const rec = rr as dnsTypeSOA; return [quoteStringIfNeeded(rec.Ns.toString()), quoteStringIfNeeded(rec.Mbox.toString()), rec.Serial.toString(), rec.Refresh.toString(), rec.Retry.toString(), rec.Expire.toString(), rec.Minttl.toString()].join(' '); } // SOA
        case 7: { const rec = rr as dnsTypeMB; return quoteStringIfNeeded(rec.Mb.toString()); } // MB
        case 8: { const rec = rr as dnsTypeMG; return quoteStringIfNeeded(rec.Mg.toString()); } // MG
        case 9: { const rec = rr as dnsTypeMR; return quoteStringIfNeeded(rec.Mr.toString()); } // MR
        case 10: { const rec = rr as dnsTypeNULL; return quoteStringIfNeeded(rec.Data.toString()); } // NULL
        case 12: { const rec = rr as dnsTypePTR; return quoteStringIfNeeded(rec.Ptr.toString()); } // PTR
        case 13: { const rec = rr as dnsTypeHINFO; return [quoteStringIfNeeded(rec.Cpu.toString()), quoteStringIfNeeded(rec.Os.toString())].join(' '); } // HINFO
        case 14: { const rec = rr as dnsTypeMINFO; return [quoteStringIfNeeded(rec.Rmail.toString()), quoteStringIfNeeded(rec.Email.toString())].join(' '); } // MINFO
        case 15: { const rec = rr as dnsTypeMX; return [rec.Preference.toString(), quoteStringIfNeeded(rec.Mx.toString())].join(' '); } // MX
        case 16: { const rec = rr as dnsTypeTXT; return quoteStringIfNeeded(rec.Txt.toString()); } // TXT
        case 17: { const rec = rr as dnsTypeRP; return [quoteStringIfNeeded(rec.Mbox.toString()), quoteStringIfNeeded(rec.Txt.toString())].join(' '); } // RP
        case 18: { const rec = rr as dnsTypeAFSDB; return [rec.Subtype.toString(), quoteStringIfNeeded(rec.Hostname.toString())].join(' '); } // AFSDB
        case 19: { const rec = rr as dnsTypeX25; return quoteStringIfNeeded(rec.PSDNAddress.toString()); } // X25
        case 20: { const rec = rr as dnsTypeISDN; return [quoteStringIfNeeded(rec.Address.toString()), quoteStringIfNeeded(rec.SubAddress.toString())].join(' '); } // ISDN
        case 21: { const rec = rr as dnsTypeRT; return [rec.Preference.toString(), quoteStringIfNeeded(rec.Host.toString())].join(' '); } // RT
        case 23: { const rec = rr as dnsTypeNSAP_PTR; return quoteStringIfNeeded(rec.Ptr.toString()); } // NSAP-PTR
        case 24: { const rec = rr as dnsTypeSIG; return [rec.TypeCovered.toString(), rec.Algorithm.toString(), rec.Labels.toString(), rec.OrigTtl.toString(), rec.Expiration.toString(), rec.Inception.toString(), rec.KeyTag.toString(), quoteStringIfNeeded(rec.SignerName.toString()), quoteStringIfNeeded(rec.Signature.toString())].join(' '); } // SIG
        case 25: { const rec = rr as dnsTypeKEY; return [rec.Flags.toString(), rec.Protocol.toString(), rec.Algorithm.toString(), quoteStringIfNeeded(rec.PublicKey.toString())].join(' '); } // KEY
        case 26: { const rec = rr as dnsTypePX; return [rec.Preference.toString(), quoteStringIfNeeded(rec.Map822.toString()), quoteStringIfNeeded(rec.Mapx400.toString())].join(' '); } // PX
        case 27: { const rec = rr as dnsTypeGPOS; return [quoteStringIfNeeded(rec.Longitude.toString()), quoteStringIfNeeded(rec.Latitude.toString()), quoteStringIfNeeded(rec.Altitude.toString())].join(' '); } // GPOS
        case 28: { const rec = rr as dnsTypeAAAA; return rec.AAAA.toString(); } // AAAA
        case 29: { const rec = rr as dnsTypeLOC; return [rec.Version.toString(), rec.Size.toString(), rec.HorizPre.toString(), rec.VertPre.toString(), rec.Latitude.toString(), rec.Longitude.toString(), rec.Altitude.toString()].join(' '); } // LOC
        case 30: { const rec = rr as dnsTypeNXT; return [quoteStringIfNeeded(rec.NextDomain.toString()), rec.TypeBitMap.join(' ')].join(' '); } // NXT
        case 31: { const rec = rr as dnsTypeEID; return quoteStringIfNeeded(rec.Endpoint.toString()); } // EID
        case 32: { const rec = rr as dnsTypeNIMLOC; return quoteStringIfNeeded(rec.Locator.toString()); } // NIMLOC
        case 33: { const rec = rr as dnsTypeSRV; return [rec.Priority.toString(), rec.Weight.toString(), rec.Port.toString(), quoteStringIfNeeded(rec.Target.toString())].join(' '); } // SRV
        case 35: { const rec = rr as dnsTypeNAPTR; return [rec.Order, rec.Preference, JSON.stringify(String(rec.Flags)), JSON.stringify(String(rec.Service)), JSON.stringify(String(rec.Regexp)), quoteStringIfNeeded(rec.Replacement)].join(' '); } // NAPTR
        case 36: { const rec = rr as dnsTypeKX; return [rec.Preference.toString(), quoteStringIfNeeded(rec.Exchanger.toString())].join(' '); } // KX
        case 37: { const rec = rr as dnsTypeCERT; return [rec.Type.toString(), rec.KeyTag.toString(), rec.Algorithm.toString(), quoteStringIfNeeded(rec.Certificate.toString())].join(' '); } // CERT
        case 39: { const rec = rr as dnsTypeDNAME; return quoteStringIfNeeded(rec.Target.toString()); } // DNAME
        case 42: { const rec = rr as dnsTypeAPL; return rec.Prefixes.map((a) => {
        let ret = "";

        if (a.Negation)
            ret += "!";

        if (a.Network.IP.indexOf(':'))
            ret += "2";
        else
            ret += "1";

        ret += ":";
        ret += a.Network.IP;
        ret += "/";
        ret += a.Network.Mask;
        return ret.length + ret;
    }).join(' '); } // APL
        case 43: { const rec = rr as dnsTypeDS; return [rec.KeyTag.toString(), rec.Algorithm.toString(), rec.DigestType.toString(), quoteStringIfNeeded(rec.Digest.toString())].join(' '); } // DS
        case 44: { const rec = rr as dnsTypeSSHFP; return [rec.Algorithm.toString(), rec.Type.toString(), quoteStringIfNeeded(rec.FingerPrint.toString())].join(' '); } // SSHFP
        case 45: { const rec = rr as dnsTypeIPSECKEY; return [rec.Precedence.toString(), rec.GatewayType.toString(), rec.Algorithm.toString(), rec.GatewayAddr.toString(), quoteStringIfNeeded(rec.GatewayHost.toString()), quoteStringIfNeeded(rec.PublicKey.toString())].join(' '); } // IPSECKEY
        case 46: { const rec = rr as dnsTypeRRSIG; return [rec.TypeCovered.toString(), rec.Algorithm.toString(), rec.Labels.toString(), rec.OrigTtl.toString(), rec.Expiration.toString(), rec.Inception.toString(), rec.KeyTag.toString(), quoteStringIfNeeded(rec.SignerName.toString()), quoteStringIfNeeded(rec.Signature.toString())].join(' '); } // RRSIG
        case 47: { const rec = rr as dnsTypeNSEC; return [quoteStringIfNeeded(rec.NextDomain.toString()), rec.TypeBitMap.join(' ')].join(' '); } // NSEC
        case 48: { const rec = rr as dnsTypeDNSKEY; return [rec.Flags.toString(), rec.Protocol.toString(), rec.Algorithm.toString(), quoteStringIfNeeded(rec.PublicKey.toString())].join(' '); } // DNSKEY
        case 49: { const rec = rr as dnsTypeDHCID; return quoteStringIfNeeded(rec.Digest.toString()); } // DHCID
        case 50: { const rec = rr as dnsTypeNSEC3; return [rec.Hash.toString(), rec.Flags.toString(), rec.Iterations.toString(), rec.SaltLength.toString(), quoteStringIfNeeded(rec.Salt.toString()), rec.HashLength.toString(), quoteStringIfNeeded(rec.NextDomain.toString()), rec.TypeBitMap.join(' ')].join(' '); } // NSEC3
        case 51: { const rec = rr as dnsTypeNSEC3PARAM; return [rec.Hash.toString(), rec.Flags.toString(), rec.Iterations.toString(), rec.SaltLength.toString(), quoteStringIfNeeded(rec.Salt.toString())].join(' '); } // NSEC3PARAM
        case 52: { const rec = rr as dnsTypeTLSA; return [rec.Usage.toString(), rec.Selector.toString(), rec.MatchingType.toString(), quoteStringIfNeeded(rec.Certificate.toString())].join(' '); } // TLSA
        case 53: { const rec = rr as dnsTypeSMIMEA; return [rec.Usage.toString(), rec.Selector.toString(), rec.MatchingType.toString(), quoteStringIfNeeded(rec.Certificate.toString())].join(' '); } // SMIMEA
        case 55: { const rec = rr as dnsTypeHIP; return [rec.HitLength.toString(), rec.PublicKeyAlgorithm.toString(), rec.PublicKeyLength.toString(), quoteStringIfNeeded(rec.Hit.toString()), quoteStringIfNeeded(rec.PublicKey.toString()), rec.RendezvousServers.map(s => quoteStringIfNeeded(s)).join(' ')].join(' '); } // HIP
        case 56: { const rec = rr as dnsTypeNINFO; return quoteStringIfNeeded(rec.ZSData.toString()); } // NINFO
        case 57: { const rec = rr as dnsTypeRKEY; return [rec.Flags.toString(), rec.Protocol.toString(), rec.Algorithm.toString(), quoteStringIfNeeded(rec.PublicKey.toString())].join(' '); } // RKEY
        case 58: { const rec = rr as dnsTypeTALINK; return [quoteStringIfNeeded(rec.PreviousName.toString()), quoteStringIfNeeded(rec.NextName.toString())].join(' '); } // TALINK
        case 59: { const rec = rr as dnsTypeCDS; return [rec.KeyTag.toString(), rec.Algorithm.toString(), rec.DigestType.toString(), quoteStringIfNeeded(rec.Digest.toString())].join(' '); } // CDS
        case 60: { const rec = rr as dnsTypeCDNSKEY; return [rec.Flags.toString(), rec.Protocol.toString(), rec.Algorithm.toString(), quoteStringIfNeeded(rec.PublicKey.toString())].join(' '); } // CDNSKEY
        case 61: { const rec = rr as dnsTypeOPENPGPKEY; return quoteStringIfNeeded(rec.PublicKey.toString()); } // OPENPGPKEY
        case 62: { const rec = rr as dnsTypeCSYNC; return [rec.Serial.toString(), rec.Flags.toString(), rec.TypeBitMap.join(' ')].join(' '); } // CSYNC
        case 63: { const rec = rr as dnsTypeZONEMD; return [rec.Serial.toString(), rec.Scheme.toString(), rec.Hash.toString(), quoteStringIfNeeded(rec.Digest.toString())].join(' '); } // ZONEMD
        case 64: { const rec = rr as dnsTypeSVCB; return [rec.Priority.toString(), quoteStringIfNeeded(rec.Target.toString()), rec.Value.join(' ')].join(' '); } // SVCB
        case 65: { const rec = rr as dnsTypeHTTPS; return [rec.Priority.toString(), quoteStringIfNeeded(rec.Target.toString()), rec.Value.join(' ')].join(' '); } // HTTPS
        case 99: { const rec = rr as dnsTypeSPF; return quoteStringIfNeeded(rec.Txt.toString()); } // SPF
        case 100: { const rec = rr as dnsTypeUINFO; return quoteStringIfNeeded(rec.Uinfo.toString()); } // UINFO
        case 101: { const rec = rr as dnsTypeUID; return rec.Uid.toString(); } // UID
        case 102: { const rec = rr as dnsTypeGID; return rec.Gid.toString(); } // GID
        case 104: { const rec = rr as dnsTypeNID; return [rec.Preference.toString(), rec.NodeID.toString()].join(' '); } // NID
        case 105: { const rec = rr as dnsTypeL32; return [rec.Preference.toString(), rec.Locator32.toString()].join(' '); } // L32
        case 106: { const rec = rr as dnsTypeL64; return [rec.Preference.toString(), rec.Locator64.toString()].join(' '); } // L64
        case 107: { const rec = rr as dnsTypeLP; return [rec.Preference.toString(), quoteStringIfNeeded(rec.Fqdn.toString())].join(' '); } // LP
        case 108: { const rec = rr as dnsTypeEUI48; return rec.Address.toString(); } // EUI48
        case 109: { const rec = rr as dnsTypeEUI64; return rec.Address.toString(); } // EUI64
        case 249: { const rec = rr as dnsTypeTKEY; return [quoteStringIfNeeded(rec.Algorithm.toString()), rec.Inception.toString(), rec.Expiration.toString(), rec.Mode.toString(), rec.Error.toString(), rec.KeySize.toString(), quoteStringIfNeeded(rec.Key.toString()), rec.OtherLen.toString(), quoteStringIfNeeded(rec.OtherData.toString())].join(' '); } // TKEY
        case 250: { const rec = rr as dnsTypeTSIG; return [quoteStringIfNeeded(rec.Algorithm.toString()), rec.TimeSigned.toString(), rec.Fudge.toString(), rec.MACSize.toString(), quoteStringIfNeeded(rec.MAC.toString()), rec.OrigId.toString(), rec.Error.toString(), rec.OtherLen.toString(), quoteStringIfNeeded(rec.OtherData.toString())].join(' '); } // TSIG
        case 256: { const rec = rr as dnsTypeURI; return [rec.Priority.toString(), rec.Weight.toString(), quoteStringIfNeeded(rec.Target.toString())].join(' '); } // URI
        case 257: { const rec = rr as dnsTypeCAA; return [rec.Flag.toString(), quoteStringIfNeeded(rec.Tag.toString()), quoteStringIfNeeded(rec.Value.toString())].join(' '); } // CAA
        case 258: { const rec = rr as dnsTypeAVC; return quoteStringIfNeeded(rec.Txt.toString()); } // AVC
        case 260: { const rec = rr as dnsTypeAMTRELAY; return [rec.Precedence.toString(), rec.GatewayType.toString(), rec.GatewayAddr.toString(), quoteStringIfNeeded(rec.GatewayHost.toString())].join(' '); } // AMTRELAY
        case 261: { const rec = rr as dnsTypeRESINFO; return quoteStringIfNeeded(rec.Txt.toString()); } // RESINFO
        case 32768: { const rec = rr as dnsTypeTA; return [rec.KeyTag.toString(), rec.Algorithm.toString(), rec.DigestType.toString(), quoteStringIfNeeded(rec.Digest.toString())].join(' '); } // TA
        case 32769: { const rec = rr as dnsTypeDLV; return [rec.KeyTag.toString(), rec.Algorithm.toString(), rec.DigestType.toString(), quoteStringIfNeeded(rec.Digest.toString())].join(' '); } // DLV
        default: return 'unknown #' + rr.Hdr.Rrtype
    }
}

export function rdatafields(input: number | string): Array<string> {
    switch (input) {
        case 1: case "A": return ["A"]; // A
        case 2: case "NS": return ["Ns"]; // NS
        case 3: case "MD": return ["Md"]; // MD
        case 4: case "MF": return ["Mf"]; // MF
        case 5: case "CNAME": return ["Target"]; // CNAME
        case 6: case "SOA": return ["Ns", "Mbox", "Serial", "Refresh", "Retry", "Expire", "Minttl"]; // SOA
        case 7: case "MB": return ["Mb"]; // MB
        case 8: case "MG": return ["Mg"]; // MG
        case 9: case "MR": return ["Mr"]; // MR
        case 10: case "NULL": return ["Data"]; // NULL
        case 12: case "PTR": return ["Ptr"]; // PTR
        case 13: case "HINFO": return ["Cpu", "Os"]; // HINFO
        case 14: case "MINFO": return ["Rmail", "Email"]; // MINFO
        case 15: case "MX": return ["Preference", "Mx"]; // MX
        case 16: case "TXT": return ["Txt"]; // TXT
        case 17: case "RP": return ["Mbox", "Txt"]; // RP
        case 18: case "AFSDB": return ["Subtype", "Hostname"]; // AFSDB
        case 19: case "X25": return ["PSDNAddress"]; // X25
        case 20: case "ISDN": return ["Address", "SubAddress"]; // ISDN
        case 21: case "RT": return ["Preference", "Host"]; // RT
        case 23: case "NSAP-PTR": return ["Ptr"]; // NSAP-PTR
        case 24: case "SIG": return ["TypeCovered", "Algorithm", "Labels", "OrigTtl", "Expiration", "Inception", "KeyTag", "SignerName", "Signature"]; // SIG
        case 25: case "KEY": return ["Flags", "Protocol", "Algorithm", "PublicKey"]; // KEY
        case 26: case "PX": return ["Preference", "Map822", "Mapx400"]; // PX
        case 27: case "GPOS": return ["Longitude", "Latitude", "Altitude"]; // GPOS
        case 28: case "AAAA": return ["AAAA"]; // AAAA
        case 29: case "LOC": return ["Version", "Size", "HorizPre", "VertPre", "Latitude", "Longitude", "Altitude"]; // LOC
        case 30: case "NXT": return ["NextDomain", "TypeBitMap"]; // NXT
        case 31: case "EID": return ["Endpoint"]; // EID
        case 32: case "NIMLOC": return ["Locator"]; // NIMLOC
        case 33: case "SRV": return ["Priority", "Weight", "Port", "Target"]; // SRV
        case 35: case "NAPTR": return ["Order", "Preference", "Flags", "Service", "Regexp", "Replacement"]; // NAPTR
        case 36: case "KX": return ["Preference", "Exchanger"]; // KX
        case 37: case "CERT": return ["Type", "KeyTag", "Algorithm", "Certificate"]; // CERT
        case 39: case "DNAME": return ["Target"]; // DNAME
        case 42: case "APL": return ["Prefixes"]; // APL
        case 43: case "DS": return ["KeyTag", "Algorithm", "DigestType", "Digest"]; // DS
        case 44: case "SSHFP": return ["Algorithm", "Type", "FingerPrint"]; // SSHFP
        case 45: case "IPSECKEY": return ["Precedence", "GatewayType", "Algorithm", "GatewayAddr", "GatewayHost", "PublicKey"]; // IPSECKEY
        case 46: case "RRSIG": return ["TypeCovered", "Algorithm", "Labels", "OrigTtl", "Expiration", "Inception", "KeyTag", "SignerName", "Signature"]; // RRSIG
        case 47: case "NSEC": return ["NextDomain", "TypeBitMap"]; // NSEC
        case 48: case "DNSKEY": return ["Flags", "Protocol", "Algorithm", "PublicKey"]; // DNSKEY
        case 49: case "DHCID": return ["Digest"]; // DHCID
        case 50: case "NSEC3": return ["Hash", "Flags", "Iterations", "SaltLength", "Salt", "HashLength", "NextDomain", "TypeBitMap"]; // NSEC3
        case 51: case "NSEC3PARAM": return ["Hash", "Flags", "Iterations", "SaltLength", "Salt"]; // NSEC3PARAM
        case 52: case "TLSA": return ["Usage", "Selector", "MatchingType", "Certificate"]; // TLSA
        case 53: case "SMIMEA": return ["Usage", "Selector", "MatchingType", "Certificate"]; // SMIMEA
        case 55: case "HIP": return ["HitLength", "PublicKeyAlgorithm", "PublicKeyLength", "Hit", "PublicKey", "RendezvousServers"]; // HIP
        case 56: case "NINFO": return ["ZSData"]; // NINFO
        case 57: case "RKEY": return ["Flags", "Protocol", "Algorithm", "PublicKey"]; // RKEY
        case 58: case "TALINK": return ["PreviousName", "NextName"]; // TALINK
        case 59: case "CDS": return ["KeyTag", "Algorithm", "DigestType", "Digest"]; // CDS
        case 60: case "CDNSKEY": return ["Flags", "Protocol", "Algorithm", "PublicKey"]; // CDNSKEY
        case 61: case "OPENPGPKEY": return ["PublicKey"]; // OPENPGPKEY
        case 62: case "CSYNC": return ["Serial", "Flags", "TypeBitMap"]; // CSYNC
        case 63: case "ZONEMD": return ["Serial", "Scheme", "Hash", "Digest"]; // ZONEMD
        case 64: case "SVCB": return ["Priority", "Target", "Value"]; // SVCB
        case 65: case "HTTPS": return ["Priority", "Target", "Value"]; // HTTPS
        case 99: case "SPF": return ["Txt"]; // SPF
        case 100: case "UINFO": return ["Uinfo"]; // UINFO
        case 101: case "UID": return ["Uid"]; // UID
        case 102: case "GID": return ["Gid"]; // GID
        case 104: case "NID": return ["Preference", "NodeID"]; // NID
        case 105: case "L32": return ["Preference", "Locator32"]; // L32
        case 106: case "L64": return ["Preference", "Locator64"]; // L64
        case 107: case "LP": return ["Preference", "Fqdn"]; // LP
        case 108: case "EUI48": return ["Address"]; // EUI48
        case 109: case "EUI64": return ["Address"]; // EUI64
        case 249: case "TKEY": return ["Algorithm", "Inception", "Expiration", "Mode", "Error", "KeySize", "Key", "OtherLen", "OtherData"]; // TKEY
        case 250: case "TSIG": return ["Algorithm", "TimeSigned", "Fudge", "MACSize", "MAC", "OrigId", "Error", "OtherLen", "OtherData"]; // TSIG
        case 256: case "URI": return ["Priority", "Weight", "Target"]; // URI
        case 257: case "CAA": return ["Flag", "Tag", "Value"]; // CAA
        case 258: case "AVC": return ["Txt"]; // AVC
        case 260: case "AMTRELAY": return ["Precedence", "GatewayType", "GatewayAddr", "GatewayHost"]; // AMTRELAY
        case 261: case "RESINFO": return ["Txt"]; // RESINFO
        case 32768: case "TA": return ["KeyTag", "Algorithm", "DigestType", "Digest"]; // TA
        case 32769: case "DLV": return ["KeyTag", "Algorithm", "DigestType", "Digest"]; // DLV
        default: return [];
    }
}

