import * as plugins from './plugins.js';
import * as dnsPacket from 'dns-packet';
export interface IDnsServerOptions {
    httpsKey: string;
    httpsCert: string;
    httpsPort: number;
    udpPort: number;
    dnssecZone: string;
    udpBindInterface?: string;
    httpsBindInterface?: string;
    manualUdpMode?: boolean;
    manualHttpsMode?: boolean;
    primaryNameserver?: string;
}
export interface DnsAnswer {
    name: string;
    type: string;
    class: string | number;
    ttl: number;
    data: any;
}
export interface IDnsHandler {
    domainPattern: string;
    recordTypes: string[];
    handler: (question: dnsPacket.Question) => DnsAnswer | null;
}
interface LetsEncryptOptions {
    email?: string;
    staging?: boolean;
    certDir?: string;
}
export declare class DnsServer {
    private options;
    private udpServer;
    private httpsServer;
    private handlers;
    private dnsSec;
    private dnskeyRecord;
    private keyTag;
    private udpServerInitialized;
    private httpsServerInitialized;
    constructor(options: IDnsServerOptions);
    /**
     * Initialize servers without binding to ports
     * This is called automatically by start() or can be called manually
     */
    initializeServers(): void;
    /**
     * Initialize UDP server without binding
     */
    initializeUdpServer(): void;
    /**
     * Initialize HTTPS server without binding
     */
    initializeHttpsServer(): void;
    /**
     * Handle a raw TCP socket for HTTPS/DoH
     * @param socket The TCP socket to handle
     */
    handleHttpsSocket(socket: plugins.net.Socket): void;
    /**
     * Handle a UDP message manually
     * @param msg The DNS message buffer
     * @param rinfo Remote address information
     * @param responseCallback Optional callback to handle the response
     */
    handleUdpMessage(msg: Buffer, rinfo: plugins.dgram.RemoteInfo, responseCallback?: (response: Buffer, rinfo: plugins.dgram.RemoteInfo) => void): void;
    /**
     * Process a raw DNS packet and return the response
     * This is useful for custom transport implementations
     */
    processRawDnsPacket(packet: Buffer): Buffer;
    registerHandler(domainPattern: string, recordTypes: string[], handler: (question: dnsPacket.Question) => DnsAnswer | null): void;
    unregisterHandler(domainPattern: string, recordTypes: string[]): boolean;
    /**
     * Retrieve SSL certificate for specified domains using Let's Encrypt
     * @param domainNames Array of domain names to include in the certificate
     * @param options Configuration options for Let's Encrypt
     * @returns Object containing certificate, private key, and success status
     */
    retrieveSslCertificate(domainNames: string[], options?: LetsEncryptOptions): Promise<{
        cert: string;
        key: string;
        success: boolean;
    }>;
    /**
     * Create DNS record value for the ACME challenge
     */
    private getDnsRecordValueForChallenge;
    /**
     * Restart the HTTPS server with the new certificate
     */
    private restartHttpsServer;
    /**
     * Filter domains to include only those the server is authoritative for
     */
    filterAuthorizedDomains(domainNames: string[]): string[];
    /**
     * Validate if a string is a valid IP address (IPv4 or IPv6)
     */
    private isValidIpAddress;
    /**
     * Determine if an IP address is IPv6
     */
    private isIPv6;
    /**
     * Check if the server is authoritative for a domain
     */
    private isAuthorizedForDomain;
    processDnsRequest(request: dnsPacket.Packet): dnsPacket.Packet;
    private isDnssecRequested;
    private generateRRSIG;
    private serializeRRset;
    private serializeRData;
    private parseDNSKEYRecord;
    private computeKeyTag;
    private handleHttpsRequest;
    start(): Promise<void>;
    stop(): Promise<void>;
    private qtypeToNumber;
    private classToNumber;
    private nameToBuffer;
}
export {};
