@push.rocks/smartdns 7.6.1 → 7.8.1

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.
Files changed (33) hide show
  1. package/dist_rust/rustdns-client_linux_amd64 +0 -0
  2. package/dist_rust/rustdns-client_linux_arm64 +0 -0
  3. package/dist_rust/rustdns_linux_amd64 +0 -0
  4. package/dist_rust/rustdns_linux_arm64 +0 -0
  5. package/dist_ts/00_commitinfo_data.js +1 -1
  6. package/dist_ts_client/classes.dnsclient.d.ts +14 -32
  7. package/dist_ts_client/classes.dnsclient.js +63 -55
  8. package/dist_ts_client/classes.rustdnsclientbridge.d.ts +59 -0
  9. package/dist_ts_client/classes.rustdnsclientbridge.js +110 -0
  10. package/dist_ts_client/index.d.ts +1 -0
  11. package/dist_ts_client/index.js +2 -1
  12. package/dist_ts_client/plugins.d.ts +8 -2
  13. package/dist_ts_client/plugins.js +8 -3
  14. package/dist_ts_server/classes.dnsserver.d.ts +38 -57
  15. package/dist_ts_server/classes.dnsserver.js +180 -702
  16. package/dist_ts_server/classes.rustdnsbridge.d.ts +119 -0
  17. package/dist_ts_server/classes.rustdnsbridge.js +136 -0
  18. package/dist_ts_server/index.d.ts +1 -0
  19. package/dist_ts_server/index.js +2 -1
  20. package/dist_ts_server/plugins.d.ts +8 -8
  21. package/dist_ts_server/plugins.js +7 -9
  22. package/npmextra.json +18 -6
  23. package/package.json +19 -19
  24. package/readme.hints.md +30 -4
  25. package/readme.md +345 -645
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/readme.md +47 -0
  28. package/dist_ts_client/dnsly.plugins.d.ts +0 -10
  29. package/dist_ts_client/dnsly.plugins.js +0 -12
  30. package/dist_ts_server/classes.dnssec.d.ts +0 -31
  31. package/dist_ts_server/classes.dnssec.js +0 -155
  32. package/dist_ts_server/classes.dnstools.d.ts +0 -31
  33. package/dist_ts_server/classes.dnstools.js +0 -139
@@ -1,5 +1,4 @@
1
1
  import * as plugins from './plugins.js';
2
- import * as dnsPacket from 'dns-packet';
3
2
  export interface IDnsServerOptions {
4
3
  httpsKey: string;
5
4
  httpsCert: string;
@@ -20,10 +19,15 @@ export interface DnsAnswer {
20
19
  ttl: number;
21
20
  data: any;
22
21
  }
22
+ export interface IDnsQuestion {
23
+ name: string;
24
+ type: string;
25
+ class?: string;
26
+ }
23
27
  export interface IDnsHandler {
24
28
  domainPattern: string;
25
29
  recordTypes: string[];
26
- handler: (question: dnsPacket.Question) => DnsAnswer | null;
30
+ handler: (question: IDnsQuestion) => DnsAnswer | null;
27
31
  }
28
32
  interface LetsEncryptOptions {
29
33
  email?: string;
@@ -32,52 +36,55 @@ interface LetsEncryptOptions {
32
36
  }
33
37
  export declare class DnsServer {
34
38
  private options;
35
- private udpServer;
36
- private httpsServer;
39
+ private bridge;
37
40
  private handlers;
38
- private dnsSec;
39
- private dnskeyRecord;
40
- private keyTag;
41
- private udpServerInitialized;
42
- private httpsServerInitialized;
41
+ private bridgeSpawned;
42
+ private httpsServer;
43
+ private udpServer;
43
44
  constructor(options: IDnsServerOptions);
44
45
  /**
45
- * Initialize servers without binding to ports
46
- * This is called automatically by start() or can be called manually
46
+ * Register a DNS handler for a domain pattern and record types.
47
+ */
48
+ registerHandler(domainPattern: string, recordTypes: string[], handler: (question: IDnsQuestion) => DnsAnswer | null): void;
49
+ /**
50
+ * Unregister a specific handler.
51
+ */
52
+ unregisterHandler(domainPattern: string, recordTypes: string[]): boolean;
53
+ /**
54
+ * Start the DNS server.
55
+ */
56
+ start(): Promise<void>;
57
+ /**
58
+ * Stop the DNS server.
59
+ */
60
+ stop(): Promise<void>;
61
+ /**
62
+ * Initialize servers (no-op with Rust bridge, kept for API compatibility).
47
63
  */
48
64
  initializeServers(): void;
49
65
  /**
50
- * Initialize UDP server without binding
66
+ * Initialize UDP server (no-op with Rust bridge).
51
67
  */
52
68
  initializeUdpServer(): void;
53
69
  /**
54
- * Initialize HTTPS server without binding
70
+ * Initialize HTTPS server (no-op with Rust bridge).
55
71
  */
56
72
  initializeHttpsServer(): void;
57
73
  /**
58
- * Handle a raw TCP socket for HTTPS/DoH
59
- * @param socket The TCP socket to handle
74
+ * Handle a raw TCP socket for HTTPS/DoH.
75
+ * In Rust mode, this is not directly supported — use processRawDnsPacket instead.
60
76
  */
61
77
  handleHttpsSocket(socket: plugins.net.Socket): void;
62
78
  /**
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
79
+ * Handle a UDP message manually.
67
80
  */
68
81
  handleUdpMessage(msg: Buffer, rinfo: plugins.dgram.RemoteInfo, responseCallback?: (response: Buffer, rinfo: plugins.dgram.RemoteInfo) => void): void;
69
82
  /**
70
- * Process a raw DNS packet and return the response
71
- * This is useful for custom transport implementations
83
+ * Process a raw DNS packet asynchronously via Rust bridge.
72
84
  */
73
- processRawDnsPacket(packet: Buffer): Buffer;
74
- registerHandler(domainPattern: string, recordTypes: string[], handler: (question: dnsPacket.Question) => DnsAnswer | null): void;
75
- unregisterHandler(domainPattern: string, recordTypes: string[]): boolean;
85
+ processRawDnsPacketAsync(packet: Buffer): Promise<Buffer>;
76
86
  /**
77
87
  * 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
88
  */
82
89
  retrieveSslCertificate(domainNames: string[], options?: LetsEncryptOptions): Promise<{
83
90
  cert: string;
@@ -85,41 +92,15 @@ export declare class DnsServer {
85
92
  success: boolean;
86
93
  }>;
87
94
  /**
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
95
+ * Filter domains to include only those the server is authoritative for.
97
96
  */
98
97
  filterAuthorizedDomains(domainNames: string[]): string[];
99
98
  /**
100
- * Validate if a string is a valid IP address (IPv4 or IPv6)
99
+ * Resolve a DNS query event from Rust using TypeScript handlers.
101
100
  */
101
+ private resolveQuery;
102
+ private getDnsRecordValueForChallenge;
102
103
  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
104
  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
105
  }
125
106
  export {};