@push.rocks/smartdns 7.5.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.
@@ -11,6 +11,7 @@ export interface IDnsServerOptions {
11
11
  manualUdpMode?: boolean;
12
12
  manualHttpsMode?: boolean;
13
13
  primaryNameserver?: string;
14
+ enableLocalhostHandling?: boolean;
14
15
  }
15
16
  export interface DnsAnswer {
16
17
  name: string;
@@ -31,52 +32,65 @@ interface LetsEncryptOptions {
31
32
  }
32
33
  export declare class DnsServer {
33
34
  private options;
34
- private udpServer;
35
- private httpsServer;
35
+ private bridge;
36
36
  private handlers;
37
- private dnsSec;
38
- private dnskeyRecord;
39
- private keyTag;
40
- private udpServerInitialized;
41
- private httpsServerInitialized;
37
+ private bridgeSpawned;
38
+ private httpsServer;
39
+ private udpServer;
42
40
  constructor(options: IDnsServerOptions);
43
41
  /**
44
- * Initialize servers without binding to ports
45
- * 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).
46
59
  */
47
60
  initializeServers(): void;
48
61
  /**
49
- * Initialize UDP server without binding
62
+ * Initialize UDP server (no-op with Rust bridge).
50
63
  */
51
64
  initializeUdpServer(): void;
52
65
  /**
53
- * Initialize HTTPS server without binding
66
+ * Initialize HTTPS server (no-op with Rust bridge).
54
67
  */
55
68
  initializeHttpsServer(): void;
56
69
  /**
57
- * Handle a raw TCP socket for HTTPS/DoH
58
- * @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.
59
72
  */
60
73
  handleHttpsSocket(socket: plugins.net.Socket): void;
61
74
  /**
62
- * Handle a UDP message manually
63
- * @param msg The DNS message buffer
64
- * @param rinfo Remote address information
65
- * @param responseCallback Optional callback to handle the response
75
+ * Handle a UDP message manually.
66
76
  */
67
77
  handleUdpMessage(msg: Buffer, rinfo: plugins.dgram.RemoteInfo, responseCallback?: (response: Buffer, rinfo: plugins.dgram.RemoteInfo) => void): void;
68
78
  /**
69
- * Process a raw DNS packet and return the response
70
- * 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).
71
81
  */
72
82
  processRawDnsPacket(packet: Buffer): Buffer;
73
- registerHandler(domainPattern: string, recordTypes: string[], handler: (question: dnsPacket.Question) => DnsAnswer | null): void;
74
- 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;
75
92
  /**
76
93
  * Retrieve SSL certificate for specified domains using Let's Encrypt
77
- * @param domainNames Array of domain names to include in the certificate
78
- * @param options Configuration options for Let's Encrypt
79
- * @returns Object containing certificate, private key, and success status
80
94
  */
81
95
  retrieveSslCertificate(domainNames: string[], options?: LetsEncryptOptions): Promise<{
82
96
  cert: string;
@@ -84,41 +98,15 @@ export declare class DnsServer {
84
98
  success: boolean;
85
99
  }>;
86
100
  /**
87
- * Create DNS record value for the ACME challenge
88
- */
89
- private getDnsRecordValueForChallenge;
90
- /**
91
- * Restart the HTTPS server with the new certificate
92
- */
93
- private restartHttpsServer;
94
- /**
95
- * Filter domains to include only those the server is authoritative for
101
+ * Filter domains to include only those the server is authoritative for.
96
102
  */
97
103
  filterAuthorizedDomains(domainNames: string[]): string[];
98
104
  /**
99
- * Validate if a string is a valid IP address (IPv4 or IPv6)
105
+ * Resolve a DNS query event from Rust using TypeScript handlers.
100
106
  */
107
+ private resolveQuery;
108
+ private getDnsRecordValueForChallenge;
101
109
  private isValidIpAddress;
102
- /**
103
- * Determine if an IP address is IPv6
104
- */
105
- private isIPv6;
106
- /**
107
- * Check if the server is authoritative for a domain
108
- */
109
110
  private isAuthorizedForDomain;
110
- processDnsRequest(request: dnsPacket.Packet): dnsPacket.Packet;
111
- private isDnssecRequested;
112
- private generateRRSIG;
113
- private serializeRRset;
114
- private serializeRData;
115
- private parseDNSKEYRecord;
116
- private computeKeyTag;
117
- private handleHttpsRequest;
118
- start(): Promise<void>;
119
- stop(): Promise<void>;
120
- private qtypeToNumber;
121
- private classToNumber;
122
- private nameToBuffer;
123
111
  }
124
112
  export {};