48 lines
1.2 KiB
Markdown
48 lines
1.2 KiB
Markdown
# @push.rocks/smartdns
|
|
|
|
Unified entry point that re-exports both the DNS client and DNS server modules.
|
|
|
|
## Import
|
|
|
|
```typescript
|
|
import { dnsClientMod, dnsServerMod } from '@push.rocks/smartdns';
|
|
```
|
|
|
|
## Modules
|
|
|
|
| Module | Description |
|
|
|---|---|
|
|
| `dnsClientMod` | DNS resolution — system, UDP, DoH strategies via `Smartdns` class |
|
|
| `dnsServerMod` | Authoritative DNS server — UDP, HTTPS, DNSSEC, ACME via `DnsServer` class |
|
|
|
|
## Usage
|
|
|
|
```typescript
|
|
import { dnsClientMod, dnsServerMod } from '@push.rocks/smartdns';
|
|
|
|
// Client
|
|
const client = new dnsClientMod.Smartdns({ strategy: 'prefer-udp' });
|
|
const records = await client.getRecordsA('example.com');
|
|
client.destroy();
|
|
|
|
// Server
|
|
const server = new dnsServerMod.DnsServer({
|
|
udpPort: 5333,
|
|
httpsPort: 8443,
|
|
httpsKey: '...',
|
|
httpsCert: '...',
|
|
dnssecZone: 'example.com',
|
|
});
|
|
server.registerHandler('example.com', ['A'], (q) => ({
|
|
name: q.name, type: 'A', class: 'IN', ttl: 300, data: '93.184.215.14',
|
|
}));
|
|
await server.start();
|
|
```
|
|
|
|
For direct imports, use the sub-module paths:
|
|
|
|
```typescript
|
|
import { Smartdns } from '@push.rocks/smartdns/client';
|
|
import { DnsServer } from '@push.rocks/smartdns/server';
|
|
```
|