@push.rocks/smartdns 7.6.1 → 7.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,52 +32,65 @@ interface LetsEncryptOptions {
32
32
  }
33
33
  export declare class DnsServer {
34
34
  private options;
35
- private udpServer;
36
- private httpsServer;
35
+ private bridge;
37
36
  private handlers;
38
- private dnsSec;
39
- private dnskeyRecord;
40
- private keyTag;
41
- private udpServerInitialized;
42
- private httpsServerInitialized;
37
+ private bridgeSpawned;
38
+ private httpsServer;
39
+ private udpServer;
43
40
  constructor(options: IDnsServerOptions);
44
41
  /**
45
- * Initialize servers without binding to ports
46
- * This is called automatically by start() or can be called manually
42
+ * Register a DNS handler for a domain pattern and record types.
43
+ */
44
+ registerHandler(domainPattern: string, recordTypes: string[], handler: (question: dnsPacket.Question) => DnsAnswer | null): void;
45
+ /**
46
+ * Unregister a specific handler.
47
+ */
48
+ unregisterHandler(domainPattern: string, recordTypes: string[]): boolean;
49
+ /**
50
+ * Start the DNS server.
51
+ */
52
+ start(): Promise<void>;
53
+ /**
54
+ * Stop the DNS server.
55
+ */
56
+ stop(): Promise<void>;
57
+ /**
58
+ * Initialize servers (no-op with Rust bridge, kept for API compatibility).
47
59
  */
48
60
  initializeServers(): void;
49
61
  /**
50
- * Initialize UDP server without binding
62
+ * Initialize UDP server (no-op with Rust bridge).
51
63
  */
52
64
  initializeUdpServer(): void;
53
65
  /**
54
- * Initialize HTTPS server without binding
66
+ * Initialize HTTPS server (no-op with Rust bridge).
55
67
  */
56
68
  initializeHttpsServer(): void;
57
69
  /**
58
- * Handle a raw TCP socket for HTTPS/DoH
59
- * @param socket The TCP socket to handle
70
+ * Handle a raw TCP socket for HTTPS/DoH.
71
+ * In Rust mode, this is not directly supported — use processRawDnsPacket instead.
60
72
  */
61
73
  handleHttpsSocket(socket: plugins.net.Socket): void;
62
74
  /**
63
- * Handle a UDP message manually
64
- * @param msg The DNS message buffer
65
- * @param rinfo Remote address information
66
- * @param responseCallback Optional callback to handle the response
75
+ * Handle a UDP message manually.
67
76
  */
68
77
  handleUdpMessage(msg: Buffer, rinfo: plugins.dgram.RemoteInfo, responseCallback?: (response: Buffer, rinfo: plugins.dgram.RemoteInfo) => void): void;
69
78
  /**
70
- * Process a raw DNS packet and return the response
71
- * This is useful for custom transport implementations
79
+ * Process a raw DNS packet and return the response.
80
+ * Synchronous version using the TypeScript fallback (for backward compatibility).
72
81
  */
73
82
  processRawDnsPacket(packet: Buffer): Buffer;
74
- registerHandler(domainPattern: string, recordTypes: string[], handler: (question: dnsPacket.Question) => DnsAnswer | null): void;
75
- unregisterHandler(domainPattern: string, recordTypes: string[]): boolean;
83
+ /**
84
+ * Process a raw DNS packet asynchronously via Rust bridge.
85
+ */
86
+ processRawDnsPacketAsync(packet: Buffer): Promise<Buffer>;
87
+ /**
88
+ * Process a DNS request locally (TypeScript handler resolution).
89
+ * Used as fallback and for pre-bridge-spawn calls.
90
+ */
91
+ processDnsRequest(request: dnsPacket.Packet): dnsPacket.Packet;
76
92
  /**
77
93
  * Retrieve SSL certificate for specified domains using Let's Encrypt
78
- * @param domainNames Array of domain names to include in the certificate
79
- * @param options Configuration options for Let's Encrypt
80
- * @returns Object containing certificate, private key, and success status
81
94
  */
82
95
  retrieveSslCertificate(domainNames: string[], options?: LetsEncryptOptions): Promise<{
83
96
  cert: string;
@@ -85,41 +98,15 @@ export declare class DnsServer {
85
98
  success: boolean;
86
99
  }>;
87
100
  /**
88
- * Create DNS record value for the ACME challenge
89
- */
90
- private getDnsRecordValueForChallenge;
91
- /**
92
- * Restart the HTTPS server with the new certificate
93
- */
94
- private restartHttpsServer;
95
- /**
96
- * Filter domains to include only those the server is authoritative for
101
+ * Filter domains to include only those the server is authoritative for.
97
102
  */
98
103
  filterAuthorizedDomains(domainNames: string[]): string[];
99
104
  /**
100
- * Validate if a string is a valid IP address (IPv4 or IPv6)
105
+ * Resolve a DNS query event from Rust using TypeScript handlers.
101
106
  */
107
+ private resolveQuery;
108
+ private getDnsRecordValueForChallenge;
102
109
  private isValidIpAddress;
103
- /**
104
- * Determine if an IP address is IPv6
105
- */
106
- private isIPv6;
107
- /**
108
- * Check if the server is authoritative for a domain
109
- */
110
110
  private isAuthorizedForDomain;
111
- processDnsRequest(request: dnsPacket.Packet): dnsPacket.Packet;
112
- private isDnssecRequested;
113
- private generateRRSIG;
114
- private serializeRRset;
115
- private serializeRData;
116
- private parseDNSKEYRecord;
117
- private computeKeyTag;
118
- private handleHttpsRequest;
119
- start(): Promise<void>;
120
- stop(): Promise<void>;
121
- private qtypeToNumber;
122
- private classToNumber;
123
- private nameToBuffer;
124
111
  }
125
112
  export {};