feat(rust): add Rust-based DNS server backend with IPC management and TypeScript bridge
This commit is contained in:
@@ -5,8 +5,35 @@
|
||||
The smartdns library is structured into three main modules:
|
||||
|
||||
1. **Client Module** (`ts_client/`) - DNS client functionality
|
||||
2. **Server Module** (`ts_server/`) - DNS server implementation
|
||||
2. **Server Module** (`ts_server/`) - DNS server with Rust backend
|
||||
3. **Main Module** (`ts/`) - Re-exports both client and server
|
||||
4. **Rust Module** (`rust/`) - High-performance DNS server binary
|
||||
|
||||
## Rust Backend Architecture (v8.0+)
|
||||
|
||||
The DNS server's network I/O, packet parsing/encoding, and DNSSEC signing run in Rust.
|
||||
TypeScript retains handler registration, ACME orchestration, and the public API.
|
||||
|
||||
### Rust Crate Structure
|
||||
- `rustdns` - Main binary with IPC management loop (`--management` flag)
|
||||
- `rustdns-protocol` - DNS wire format parsing/encoding, record types
|
||||
- `rustdns-server` - Async UDP + HTTPS DoH servers (tokio, hyper, rustls)
|
||||
- `rustdns-dnssec` - ECDSA P-256 / ED25519 key generation and RRset signing
|
||||
|
||||
### IPC Flow
|
||||
```
|
||||
DNS Query -> Rust (UDP/HTTPS) -> Parse packet
|
||||
-> Try local resolution (localhost, DNSKEY)
|
||||
-> If handler needed: emit "dnsQuery" event to TypeScript
|
||||
-> TypeScript runs minimatch handlers, sends "dnsQueryResult" back
|
||||
-> Rust builds response, signs DNSSEC if requested, sends packet
|
||||
```
|
||||
|
||||
### Key Files
|
||||
- `ts_server/classes.rustdnsbridge.ts` - TypeScript IPC bridge wrapping smartrust.RustBridge
|
||||
- `ts_server/classes.dnsserver.ts` - DnsServer class (public API, delegates to Rust bridge)
|
||||
- `rust/crates/rustdns/src/management.rs` - IPC management loop
|
||||
- `rust/crates/rustdns/src/resolver.rs` - DNS resolver with callback support
|
||||
|
||||
## Client Module (Smartdns class)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user