2026-02-02 22:21:55 +00:00
# @serve.zone/dcrouter
2024-05-11 12:33:14 +02:00
2025-06-20 00:44:04 +00:00

2026-02-11 16:32:49 +00:00
**dcrouter: The all-in-one gateway for your datacenter.** 🚀
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
A comprehensive traffic routing solution that provides unified gateway capabilities for HTTP/HTTPS, TCP/SNI, email (SMTP), DNS, and RADIUS protocols. Designed for enterprises requiring robust traffic management, automatic TLS certificate provisioning, and enterprise-grade email infrastructure — all from a single process.
2026-02-02 22:21:55 +00:00
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/ ](https://community.foss.global/ ). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/ ](https://code.foss.global/ ) account to submit Pull Requests directly.
2025-05-22 13:10:45 +00:00
## Table of Contents
- [Features ](#features )
- [Installation ](#installation )
- [Quick Start ](#quick-start )
- [Architecture ](#architecture )
2026-02-11 16:32:49 +00:00
- [Configuration Reference ](#configuration-reference )
- [HTTP/HTTPS & TCP/SNI Routing ](#httphttps--tcpsni-routing )
2025-05-22 13:10:45 +00:00
- [Email System ](#email-system )
2026-02-11 16:32:49 +00:00
- [DNS Server ](#dns-server )
2026-02-02 22:21:55 +00:00
- [RADIUS Server ](#radius-server )
2026-02-16 00:22:23 +00:00
- [Certificate Management ](#certificate-management )
2026-02-11 16:32:49 +00:00
- [Storage & Caching ](#storage--caching )
2025-05-22 13:10:45 +00:00
- [Security Features ](#security-features )
2026-02-02 22:21:55 +00:00
- [OpsServer Dashboard ](#opsserver-dashboard )
2025-05-22 13:10:45 +00:00
- [API Reference ](#api-reference )
2026-02-11 16:32:49 +00:00
- [Sub-Modules ](#sub-modules )
2026-02-02 22:21:55 +00:00
- [Testing ](#testing )
2026-02-11 16:32:49 +00:00
- [License and Legal Information ](#license-and-legal-information )
2025-05-22 13:10:45 +00:00
## Features
2026-02-11 16:32:49 +00:00
### 🌐 Universal Traffic Router
- **HTTP/HTTPS routing** with domain matching, path-based forwarding, and automatic TLS
- **TCP/SNI proxy** for any protocol with TLS termination or passthrough
2026-02-12 10:15:26 +00:00
- **DNS server** (Rust-powered via [SmartDNS ](https://code.foss.global/push.rocks/smartdns )) with authoritative zones, dynamic record management, and DNS-over-HTTPS
2026-02-11 16:32:49 +00:00
- **Multi-protocol support** on the same infrastructure via [SmartProxy ](https://code.foss.global/push.rocks/smartproxy )
2025-05-22 13:10:45 +00:00
2026-02-12 10:15:26 +00:00
### 📧 Complete Email Infrastructure (powered by [smartmta](https://code.foss.global/push.rocks/smartmta))
2025-05-22 13:10:45 +00:00
- **Multi-domain SMTP server** on standard ports (25, 587, 465)
2026-02-11 16:32:49 +00:00
- **Pattern-based email routing** with four action types: forward, process, deliver, reject
- **DKIM signing & verification**, SPF, DMARC authentication stack
- **Enterprise deliverability** with IP warmup schedules and sender reputation tracking
- **Bounce handling** with automatic suppression lists
- **Hierarchical rate limiting** — global, per-domain, per-sender
### 🔒 Enterprise Security
2026-02-16 00:22:23 +00:00
- **Automatic TLS certificates** via ACME (smartacme v9) with Cloudflare DNS-01 challenges
- **Smart certificate scheduling** — per-domain deduplication, controlled parallelism, and account rate limiting handled automatically
- **Per-domain exponential backoff** — failed provisioning attempts are tracked and backed off to avoid hammering ACME servers
2026-02-11 16:32:49 +00:00
- **IP reputation checking** with caching and configurable thresholds
- **Content scanning** for spam, viruses, and malicious attachments
- **Security event logging** with structured audit trails
### 📡 RADIUS Server
2026-02-02 00:36:19 +00:00
- **MAC Authentication Bypass (MAB)** for network device authentication
2026-02-11 16:32:49 +00:00
- **VLAN assignment** based on exact MAC, OUI prefix, or wildcard patterns
- **RADIUS accounting** for session tracking, traffic metering, and billing
- **Real-time management** via OpsServer API
### ⚡ High Performance
- **Rust-powered proxy engine** via SmartProxy for maximum throughput
2026-02-12 10:15:26 +00:00
- **Rust-powered MTA engine** via smartmta (TypeScript + Rust hybrid) for reliable email delivery
- **Rust-powered DNS engine** via SmartDNS for high-performance UDP and DNS-over-HTTPS
2026-02-11 16:32:49 +00:00
- **Connection pooling** for outbound SMTP and backend services
- **Socket-handler mode** — direct socket passing eliminates internal port hops
- **Real-time metrics** via SmartMetrics (CPU, memory, connections, throughput)
### 💾 Persistent Storage & Caching
- **Multiple storage backends**: filesystem, custom functions, or in-memory
2026-02-12 10:15:26 +00:00
- **Embedded cache database** via smartdata + LocalTsmDb (MongoDB-compatible)
- **Automatic TTL-based cleanup** for cached emails and IP reputation data
2026-02-11 16:32:49 +00:00
### 🖥️ OpsServer Dashboard
- **Web-based management interface** with real-time monitoring
- **JWT authentication** with session persistence
2026-02-16 00:22:23 +00:00
- **Live views** for connections, email queues, DNS queries, RADIUS sessions, certificates, and security events
- **Domain-centric certificate overview** with backoff status and one-click reprovisioning
2026-02-11 16:32:49 +00:00
- **Read-only configuration display** — DcRouter is configured through code
2026-02-02 22:21:55 +00:00
2025-05-22 13:10:45 +00:00
## Installation
```bash
2026-02-02 22:21:55 +00:00
pnpm add @serve .zone/dcrouter
2026-02-11 16:32:49 +00:00
# or
npm install @serve .zone/dcrouter
2025-05-22 13:10:45 +00:00
```
### Prerequisites
2026-02-12 10:15:26 +00:00
- **Node.js 20+** with ES module support
2026-02-11 16:32:49 +00:00
- Valid domain with DNS control (for ACME certificate automation)
- Cloudflare API token (for DNS-01 challenges) — optional
2025-05-22 13:10:45 +00:00
## Quick Start
2024-02-15 20:30:38 +01:00
2025-05-22 13:10:45 +00:00
### Basic HTTP/HTTPS Router
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
```typescript
import { DcRouter } from '@serve .zone/dcrouter';
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
const router = new DcRouter({
smartProxyConfig: {
routes: [
{
2026-02-11 16:32:49 +00:00
name: 'web-app',
match: { domains: ['example.com', 'www.example.com'], ports: [443] },
2025-05-22 13:10:45 +00:00
action: {
type: 'forward',
2026-02-02 00:36:19 +00:00
targets: [{ host: '192.168.1.10', port: 8080 }],
2025-05-22 13:10:45 +00:00
tls: { mode: 'terminate', certificate: 'auto' }
}
}
],
acme: {
email: 'admin@example .com',
enabled: true,
useProduction: true
}
}
});
await router.start();
2024-05-11 12:33:14 +02:00
```
2026-02-11 16:32:49 +00:00
### Basic Email Server
2025-05-22 13:10:45 +00:00
```typescript
import { DcRouter } from '@serve .zone/dcrouter';
const router = new DcRouter({
emailConfig: {
ports: [25, 587, 465],
hostname: 'mail.example.com',
2026-02-11 16:32:49 +00:00
domains: [
{
domain: 'example.com',
dnsMode: 'external-dns'
}
],
2025-05-28 14:12:50 +00:00
routes: [
2025-05-22 13:10:45 +00:00
{
2026-02-11 16:32:49 +00:00
name: 'process-all',
2025-05-28 14:12:50 +00:00
match: { recipients: '*@example .com' },
action: {
type: 'process',
2026-02-11 16:32:49 +00:00
process: { scan: true, dkim: true, queue: 'normal' }
2025-05-22 13:10:45 +00:00
}
}
2026-02-11 16:32:49 +00:00
]
2025-05-22 13:10:45 +00:00
}
});
2024-02-15 20:30:38 +01:00
2025-05-22 13:10:45 +00:00
await router.start();
```
2024-02-15 20:30:38 +01:00
2026-02-11 16:32:49 +00:00
### Full Stack with Dashboard
2026-02-02 22:21:55 +00:00
```typescript
import { DcRouter } from '@serve .zone/dcrouter';
const router = new DcRouter({
2026-02-11 16:32:49 +00:00
// HTTP/HTTPS routing
smartProxyConfig: {
routes: [
{
name: 'website',
match: { domains: ['example.com'], ports: [443] },
action: {
type: 'forward',
targets: [{ host: '192.168.1.10', port: 80 }],
tls: { mode: 'terminate', certificate: 'auto' }
}
}
],
acme: { email: 'ssl@example .com', enabled: true, useProduction: true }
2026-02-02 22:21:55 +00:00
},
2026-02-12 10:15:26 +00:00
// Email system (powered by smartmta)
2026-02-11 16:32:49 +00:00
emailConfig: {
ports: [25, 587, 465],
hostname: 'mail.example.com',
domains: [{ domain: 'example.com', dnsMode: 'external-dns' }],
routes: [
{
name: 'inbound-mail',
match: { recipients: '*@example .com' },
action: { type: 'process', process: { scan: true, dkim: true, queue: 'normal' } }
}
]
},
// Authoritative DNS
dnsNsDomains: ['ns1.example.com', 'ns2.example.com'],
dnsScopes: ['example.com'],
publicIp: '203.0.113.1',
dnsRecords: [
{ name: 'example.com', type: 'A', value: '203.0.113.1' },
{ name: 'www.example.com', type: 'CNAME', value: 'example.com' }
],
// RADIUS authentication
radiusConfig: {
authPort: 1812,
acctPort: 1813,
clients: [
{ name: 'switch-1', ipRange: '192.168.1.0/24', secret: 'radius-secret', enabled: true }
],
vlanAssignment: {
defaultVlan: 100,
allowUnknownMacs: true,
mappings: [
{ mac: 'aa:bb:cc:dd:ee:ff', vlan: 10, enabled: true },
{ mac: 'aa:bb:cc', vlan: 20, enabled: true } // OUI prefix
]
},
accounting: { enabled: true, retentionDays: 30 }
},
// Persistent storage
storage: { fsPath: '/var/lib/dcrouter/data' },
// Cache database
2026-02-12 14:20:42 +00:00
cacheConfig: { enabled: true, storagePath: '~/.serve.zone/dcrouter/tsmdb' },
2026-02-11 16:32:49 +00:00
// TLS & ACME
tls: { contactEmail: 'admin@example .com' },
dnsChallenge: { cloudflareApiKey: process.env.CLOUDFLARE_API_KEY }
2026-02-02 22:21:55 +00:00
});
await router.start();
2026-02-11 16:32:49 +00:00
// OpsServer dashboard available at http://localhost:3000
2026-02-02 22:21:55 +00:00
```
2025-05-22 13:10:45 +00:00
## Architecture
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
### System Overview
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
```mermaid
graph TB
subgraph "External Traffic"
HTTP[HTTP/HTTPS Clients]
SMTP[SMTP Clients]
TCP[TCP Clients]
DNS[DNS Queries]
2026-02-11 16:32:49 +00:00
RAD[RADIUS Clients]
2025-05-22 13:10:45 +00:00
end
2026-02-02 22:21:55 +00:00
2025-05-22 13:10:45 +00:00
subgraph "DcRouter Core"
2026-02-11 16:32:49 +00:00
DC[DcRouter Orchestrator]
2026-02-12 10:15:26 +00:00
SP[SmartProxy Engine<br/><i>Rust-powered</i>]
ES[smartmta Email Server<br/><i>TypeScript + Rust</i>]
DS[SmartDNS Server<br/><i>Rust-powered</i>]
RS[SmartRadius Server]
2026-02-16 00:22:23 +00:00
CM[Certificate Manager<br/><i>smartacme v9</i>]
2026-02-11 16:32:49 +00:00
OS[OpsServer Dashboard]
MM[Metrics Manager]
SM[Storage Manager]
CD[Cache Database]
2025-05-22 13:10:45 +00:00
end
2026-02-02 22:21:55 +00:00
2025-05-22 13:10:45 +00:00
subgraph "Backend Services"
2026-02-11 16:32:49 +00:00
WEB[Web Services]
MAIL[Mail Servers]
DB[Databases]
API[Internal APIs]
2025-05-22 13:10:45 +00:00
end
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
HTTP --> SP
TCP --> SP
SMTP --> ES
DNS --> DS
RAD --> RS
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
DC --> SP
DC --> ES
DC --> DS
DC --> RS
DC --> CM
DC --> OS
DC --> MM
DC --> SM
DC --> CD
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
SP --> WEB
SP --> API
ES --> MAIL
ES --> DB
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
CM -.-> SP
CM -.-> ES
```
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
### Core Components
2025-05-22 13:10:45 +00:00
2026-02-12 10:15:26 +00:00
| Component | Package | Description |
|-----------|---------|-------------|
| **DcRouter ** | `@serve.zone/dcrouter` | Central orchestrator — starts, stops, and coordinates all services |
| **SmartProxy ** | `@push.rocks/smartproxy` | High-performance HTTP/HTTPS and TCP/SNI proxy with route-based config (Rust engine) |
| **UnifiedEmailServer ** | `@push.rocks/smartmta` | Full SMTP server with pattern-based routing, DKIM, queue management (TypeScript + Rust) |
| **DNS Server ** | `@push.rocks/smartdns` | Authoritative DNS with dynamic records and DKIM TXT auto-generation (Rust engine) |
2026-02-16 00:22:23 +00:00
| **SmartAcme ** | `@push.rocks/smartacme` | ACME certificate management with per-domain dedup, concurrency control, and rate limiting |
2026-02-12 10:15:26 +00:00
| **RADIUS Server ** | `@push.rocks/smartradius` | Network authentication with MAB, VLAN assignment, and accounting |
| **OpsServer ** | `@api.global/typedserver` | Web dashboard + TypedRequest API for monitoring and management |
| **MetricsManager ** | `@push.rocks/smartmetrics` | Real-time metrics collection (CPU, memory, email, DNS, security) |
| **StorageManager ** | built-in | Pluggable key-value storage (filesystem, custom, or in-memory) |
| **CacheDb ** | `@push.rocks/smartdata` | Embedded MongoDB-compatible database (LocalTsmDb) for persistent caching |
### How It Works
DcRouter acts purely as an **orchestrator ** — it doesn't implement protocols itself. Instead, it wires together best-in-class packages for each protocol:
1. **On `start()` ** : DcRouter initializes OpsServer (port 3000), then spins up SmartProxy, smartmta, SmartDNS, and SmartRadius based on which configs are provided.
2026-02-16 00:22:23 +00:00
2. **During operation ** : Each service handles its own protocol independently. SmartProxy uses a Rust-powered engine for maximum throughput. smartmta uses a hybrid TypeScript + Rust architecture for reliable email delivery. SmartAcme v9 handles all certificate operations with built-in concurrency control and rate limiting.
3. **On `stop()` ** : All services are gracefully shut down in parallel, including cleanup of HTTP agents and DNS clients.
2026-02-12 10:15:26 +00:00
### Rust-Powered Architecture
DcRouter itself is a pure TypeScript orchestrator, but three of its core sub-components ship with **compiled Rust binaries ** for performance-critical paths. At runtime each package detects the platform, unpacks the correct binary, and communicates with TypeScript over IPC/FFI — so you get the ergonomics of TypeScript with the throughput of native code.
| Component | Rust Binary | What It Handles |
|-----------|-------------|-----------------|
| **SmartProxy ** | `smartproxy-bin` | All TCP/TLS/HTTP proxy networking, NFTables integration, connection metrics |
| **smartmta ** | `mailer-bin` | SMTP server + client, DKIM/SPF/DMARC, content scanning, IP reputation |
| **SmartDNS ** | `smartdns-bin` | DNS server (UDP + DNS-over-HTTPS), DNSSEC, DNS client resolution |
| **SmartRadius ** | — | Pure TypeScript (no Rust component) |
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
## Configuration Reference
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
### `IDcRouterOptions`
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
```typescript
interface IDcRouterOptions {
2026-02-11 16:32:49 +00:00
// ── Traffic Routing ────────────────────────────────────────────
/** SmartProxy config for HTTP/HTTPS and TCP/SNI routing */
smartProxyConfig?: ISmartProxyOptions;
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
// ── Email ──────────────────────────────────────────────────────
2026-02-12 10:15:26 +00:00
/** Unified email server configuration (smartmta) */
emailConfig?: IUnifiedEmailServerOptions;
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
/** Custom email port mapping overrides */
emailPortConfig?: {
portMapping?: Record<number, number>;
portSettings?: Record<number, any>;
receivedEmailsPath?: string;
2025-05-22 13:10:45 +00:00
};
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
// ── DNS ────────────────────────────────────────────────────────
/** Nameserver domains — get A records automatically */
2026-02-12 10:15:26 +00:00
dnsNsDomains?: string[];
2026-02-11 16:32:49 +00:00
/** Domains this server is authoritative for */
2026-02-12 10:15:26 +00:00
dnsScopes?: string[];
2026-02-11 16:32:49 +00:00
/** Public IP for NS A records */
publicIp?: string;
/** Ingress proxy IPs (hides real server IP) */
proxyIps?: string[];
/** Custom DNS records */
dnsRecords?: Array<{
name: string;
type: 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SOA';
value: string;
ttl?: number;
useIngressProxy?: boolean;
}>;
// ── RADIUS ─────────────────────────────────────────────────────
/** RADIUS server for network authentication */
2026-02-02 22:21:55 +00:00
radiusConfig?: {
2026-02-11 16:32:49 +00:00
authPort?: number; // default: 1812
acctPort?: number; // default: 1813
clients: IRadiusClient[];
vlanAssignment?: IVlanManagerConfig;
accounting?: { enabled: boolean; retentionDays?: number };
2026-02-02 22:21:55 +00:00
};
2026-02-11 16:32:49 +00:00
// ── TLS & Certificates ────────────────────────────────────────
2025-05-22 13:10:45 +00:00
tls?: {
contactEmail: string;
2026-02-11 16:32:49 +00:00
domain?: string;
certPath?: string;
keyPath?: string;
2025-05-22 13:10:45 +00:00
};
2026-02-11 16:32:49 +00:00
dnsChallenge?: { cloudflareApiKey?: string };
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
// ── Storage & Caching ─────────────────────────────────────────
2025-05-30 07:06:00 +00:00
storage?: {
2026-02-11 16:32:49 +00:00
fsPath?: string;
readFunction?: (key: string) => Promise<string>;
writeFunction?: (key: string, value: string) => Promise<void>;
2024-05-11 12:33:14 +02:00
};
2026-02-11 16:32:49 +00:00
cacheConfig?: {
enabled?: boolean; // default: true
2026-02-12 14:20:42 +00:00
storagePath?: string; // default: '~/.serve.zone/dcrouter/tsmdb'
2026-02-11 16:32:49 +00:00
dbName?: string; // default: 'dcrouter'
cleanupIntervalHours?: number; // default: 1
ttlConfig?: {
emails?: number; // default: 30 days
ipReputation?: number; // default: 1 day
bounces?: number; // default: 30 days
dkimKeys?: number; // default: 90 days
suppression?: number; // default: 30 days
2025-05-22 13:10:45 +00:00
};
};
}
```
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
## HTTP/HTTPS & TCP/SNI Routing
2025-05-29 16:26:19 +00:00
2026-02-11 16:32:49 +00:00
DcRouter uses [SmartProxy ](https://code.foss.global/push.rocks/smartproxy ) for all HTTP/HTTPS and TCP/SNI routing. Routes are pattern-matched by domain, port, or both.
2025-05-29 16:26:19 +00:00
2026-02-11 16:32:49 +00:00
### HTTPS with Auto-TLS
2025-05-29 16:26:19 +00:00
```typescript
2026-02-11 16:32:49 +00:00
{
name: 'api-gateway',
match: { domains: ['api.example.com'], ports: [443] },
action: {
type: 'forward',
targets: [{ host: '192.168.1.20', port: 8080 }],
tls: { mode: 'terminate', certificate: 'auto' }
2025-05-29 16:26:19 +00:00
}
2026-02-11 16:32:49 +00:00
}
2025-05-29 16:26:19 +00:00
```
2026-02-11 16:32:49 +00:00
### TLS Passthrough (SNI Routing)
2025-05-29 16:26:19 +00:00
```typescript
2026-02-11 16:32:49 +00:00
{
name: 'secure-backend',
match: { domains: ['secure.example.com'], ports: [8443] },
action: {
type: 'forward',
targets: [{ host: '192.168.1.40', port: 8443 }],
tls: { mode: 'passthrough' }
2025-05-29 16:26:19 +00:00
}
2026-02-11 16:32:49 +00:00
}
2025-05-29 16:26:19 +00:00
```
2026-02-11 16:32:49 +00:00
### TCP Port Range Forwarding
2025-05-29 16:26:19 +00:00
2026-02-11 16:32:49 +00:00
```typescript
{
name: 'database-cluster',
match: { ports: [{ from: 5432, to: 5439 }] },
action: {
type: 'forward',
targets: [{ host: '192.168.1.30', port: 'preserve' }],
security: { ipAllowList: ['192.168.1.0/24'] }
}
}
2025-05-29 16:26:19 +00:00
```
2026-02-11 16:32:49 +00:00
### HTTP Redirect
```typescript
{
name: 'http-to-https',
match: { ports: [80] },
action: { type: 'redirect', redirect: { to: 'https://{domain}{path}' } }
}
2025-05-29 16:26:19 +00:00
```
2025-05-22 13:10:45 +00:00
## Email System
2026-02-12 10:15:26 +00:00
The email system is powered by [`@push.rocks/smartmta` ](https://code.foss.global/push.rocks/smartmta ), a TypeScript + Rust hybrid MTA. DcRouter configures and orchestrates smartmta's **UnifiedEmailServer ** , which handles SMTP sessions, route matching, delivery queuing, DKIM signing, and all email processing.
2025-05-30 07:06:00 +00:00
2026-02-11 16:32:49 +00:00
### Email Domain Configuration
2025-05-30 07:06:00 +00:00
2026-02-11 16:32:49 +00:00
Domains define _ infrastructure _ — how DNS and DKIM are handled for each domain:
2025-05-30 07:06:00 +00:00
2026-02-11 16:32:49 +00:00
#### Forward Mode
Simple forwarding without local DNS management:
2025-05-30 07:06:00 +00:00
```typescript
{
domain: 'forwarded.com',
dnsMode: 'forward',
2026-02-11 16:32:49 +00:00
dns: { forward: { skipDnsValidation: true, targetDomain: 'mail.target.com' } }
2025-05-30 07:06:00 +00:00
}
```
2026-02-11 16:32:49 +00:00
#### Internal DNS Mode
Uses DcRouter's built-in DNS server (requires `dnsNsDomains` + `dnsScopes` ):
2025-05-30 07:06:00 +00:00
```typescript
{
domain: 'mail.example.com',
dnsMode: 'internal-dns',
2026-02-11 16:32:49 +00:00
dns: { internal: { mxPriority: 10, ttl: 3600 } },
dkim: { selector: 'mail2024', keySize: 2048, rotateKeys: true, rotationInterval: 90 }
2025-05-30 07:06:00 +00:00
}
```
2026-02-11 16:32:49 +00:00
#### External DNS Mode
Uses existing DNS infrastructure with validation:
2025-05-30 07:06:00 +00:00
```typescript
{
domain: 'mail.external.com',
dnsMode: 'external-dns',
2026-02-11 16:32:49 +00:00
dns: { external: { requiredRecords: ['MX', 'SPF', 'DKIM', 'DMARC'] } },
2025-05-30 07:06:00 +00:00
rateLimits: {
2026-02-11 16:32:49 +00:00
inbound: { messagesPerMinute: 100, connectionsPerIp: 10 },
outbound: { messagesPerMinute: 200 }
2025-05-30 07:06:00 +00:00
}
}
```
2025-05-28 14:12:50 +00:00
### Email Route Actions
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
Routes define _ behavior _ — what happens when an email matches:
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
#### Forward 📤
Routes emails to an external SMTP server:
2025-05-22 13:10:45 +00:00
```typescript
{
2025-05-28 14:12:50 +00:00
name: 'forward-to-internal',
match: { recipients: '*@company .com' },
action: {
type: 'forward',
forward: {
host: 'internal-mail.company.com',
port: 25,
2026-02-11 16:32:49 +00:00
auth: { user: 'relay-user', pass: 'relay-pass' },
addHeaders: { 'X-Forwarded-By': 'dcrouter' }
2025-05-22 13:10:45 +00:00
}
}
2024-05-11 12:33:14 +02:00
}
2025-05-22 13:10:45 +00:00
```
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
#### Process ⚙️
Full MTA processing with content scanning and delivery queues:
2025-05-22 13:10:45 +00:00
```typescript
{
2025-05-28 14:12:50 +00:00
name: 'process-notifications',
match: { recipients: '*@notifications .company.com' },
action: {
type: 'process',
2026-02-11 16:32:49 +00:00
process: { scan: true, dkim: true, queue: 'priority' }
2025-05-22 13:10:45 +00:00
}
}
2024-05-11 12:33:14 +02:00
```
2026-02-11 16:32:49 +00:00
#### Deliver 📥
Local mailbox delivery:
2025-05-22 13:10:45 +00:00
```typescript
{
2025-05-28 14:12:50 +00:00
name: 'deliver-local',
2026-02-11 16:32:49 +00:00
match: { recipients: '*@local .company.com' },
action: { type: 'deliver' }
2025-05-28 14:12:50 +00:00
}
```
2026-02-11 16:32:49 +00:00
#### Reject 🚫
Reject with custom SMTP response code:
2025-05-28 14:12:50 +00:00
```typescript
{
2026-02-11 16:32:49 +00:00
name: 'reject-spam-domain',
match: { senders: '*@spam -domain.com', sizeRange: { min: 1000000 } },
2025-05-28 14:12:50 +00:00
action: {
type: 'reject',
2026-02-11 16:32:49 +00:00
reject: { code: 550, message: 'Message rejected due to policy' }
2025-05-28 14:12:50 +00:00
}
}
```
2026-02-11 16:32:49 +00:00
### Route Matching
2025-05-28 14:12:50 +00:00
2026-02-11 16:32:49 +00:00
Routes support powerful matching criteria:
2025-05-28 14:12:50 +00:00
```typescript
2026-02-11 16:32:49 +00:00
// Recipient patterns
match: { recipients: '*@example .com' } // All addresses at domain
match: { recipients: 'admin@*' } // "admin" at any domain
match: { senders: ['*@trusted .com', '*@vip .com'] } // Multiple sender patterns
// IP-based matching (CIDR)
match: { clientIp: '192.168.0.0/16' }
match: { clientIp: ['10.0.0.0/8', '172.16.0.0/12'] }
// Authentication state
match: { authenticated: true }
// Header matching
match: { headers: { 'X-Priority': 'high', 'Subject': /urgent|emergency/i } }
// Size and content
match: { sizeRange: { min: 1000, max: 5000000 }, hasAttachments: true }
match: { subject: /invoice|receipt/i }
2025-05-28 14:12:50 +00:00
```
2026-02-11 16:32:49 +00:00
### Email Security Stack
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
- **DKIM** — Automatic key generation, signing, and rotation for all domains
- **SPF** — Sender Policy Framework verification on inbound mail
- **DMARC** — Domain-based Message Authentication verification
- **IP Reputation** — Real-time IP reputation checking with caching
- **Content Scanning** — Spam, virus, and attachment scanning
- **Rate Limiting** — Hierarchical limits (global → domain → sender)
- **Bounce Management** — Automatic bounce detection and suppression lists
2025-05-28 14:12:50 +00:00
2026-02-11 16:32:49 +00:00
### Email Deliverability
2025-05-28 14:12:50 +00:00
2026-02-11 16:32:49 +00:00
- **IP Warmup Manager** — Multi-stage warmup schedules for new IPs
- **Sender Reputation Monitor** — Per-domain reputation tracking and scoring
- **Connection Pooling** — Pooled outbound SMTP connections per destination
2025-05-28 14:12:50 +00:00
2026-02-11 16:32:49 +00:00
## DNS Server
2025-05-28 14:12:50 +00:00
2026-02-11 16:32:49 +00:00
DcRouter includes an authoritative DNS server built on [smartdns ](https://code.foss.global/push.rocks/smartdns ). It handles standard UDP DNS on port 53 and DNS-over-HTTPS via SmartProxy socket handler.
### Enabling DNS
DNS is activated when both `dnsNsDomains` and `dnsScopes` are configured:
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
const router = new DcRouter({
dnsNsDomains: ['ns1.example.com', 'ns2.example.com'],
dnsScopes: ['example.com'],
publicIp: '203.0.113.1',
dnsRecords: [
{ name: 'example.com', type: 'A', value: '203.0.113.1' },
{ name: 'www.example.com', type: 'CNAME', value: 'example.com' },
{ name: 'example.com', type: 'MX', value: '10:mail.example.com' },
{ name: 'example.com', type: 'TXT', value: 'v=spf1 a mx ~all' }
]
});
2025-05-22 13:10:45 +00:00
```
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
### Automatic DNS Records
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
DcRouter auto-generates:
- **NS records** for all domains in `dnsScopes`
- **SOA records** for authoritative zones
- **A records** for nameserver domains (`dnsNsDomains` )
- **MX, SPF, DKIM, DMARC records** for email domains with `internal-dns` mode
- **ACME challenge records** for certificate provisioning
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
### Ingress Proxy Support
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
When `proxyIps` is configured, A records with `useIngressProxy: true` (default) will use the proxy IP instead of the real server IP — hiding your origin:
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
{
proxyIps: ['198.51.100.1', '198.51.100.2'],
dnsRecords: [
{ name: 'example.com', type: 'A', value: '203.0.113.1' }, // Will resolve to 198.51.100.1
{ name: 'ns1.example.com', type: 'A', value: '203.0.113.1', useIngressProxy: false } // Stays real IP
]
}
2024-05-11 12:33:14 +02:00
```
2026-02-02 22:21:55 +00:00
## RADIUS Server
2026-02-11 16:32:49 +00:00
DcRouter includes a RADIUS server for network access control, built on [smartradius ](https://code.foss.global/push.rocks/smartradius ).
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
### Configuration
2026-02-02 22:21:55 +00:00
```typescript
const router = new DcRouter({
radiusConfig: {
2026-02-11 16:32:49 +00:00
authPort: 1812,
acctPort: 1813,
2026-02-02 22:21:55 +00:00
clients: [
{
2026-02-11 16:32:49 +00:00
name: 'core-switch',
ipRange: '192.168.1.0/24',
secret: 'shared-secret',
enabled: true
2026-02-02 22:21:55 +00:00
}
2026-02-11 16:32:49 +00:00
],
vlanAssignment: {
2026-02-02 22:21:55 +00:00
defaultVlan: 100,
2026-02-11 16:32:49 +00:00
allowUnknownMacs: true,
mappings: [
{ mac: 'aa:bb:cc:dd:ee:ff', vlan: 10, enabled: true }, // Exact MAC
{ mac: 'aa:bb:cc', vlan: 20, enabled: true }, // OUI prefix
]
},
accounting: {
enabled: true,
retentionDays: 30
2026-02-02 22:21:55 +00:00
}
}
});
```
2026-02-11 16:32:49 +00:00
### Components
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
| Component | Purpose |
|-----------|---------|
| **RadiusServer ** | Main RADIUS server handling auth + accounting requests |
| **VlanManager ** | MAC-to-VLAN mapping with exact, OUI, and wildcard patterns |
| **AccountingManager ** | Session tracking, traffic metering, start/stop/interim updates |
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
### OpsServer API
RADIUS is fully manageable at runtime via the OpsServer API:
- Client management (add/remove/list NAS devices)
- VLAN mapping CRUD operations
- Session monitoring and forced disconnects
- Accounting summaries and statistics
2026-02-16 00:22:23 +00:00
## Certificate Management
DcRouter uses [`@push.rocks/smartacme` ](https://code.foss.global/push.rocks/smartacme ) v9 for ACME certificate provisioning. smartacme v9 brings significant improvements over previous versions:
### How It Works
When a `dnsChallenge` is configured (e.g. with a Cloudflare API key), DcRouter creates a SmartAcme instance that handles DNS-01 challenges for automatic certificate provisioning. SmartProxy calls the `certProvisionFunction` whenever a route needs a TLS certificate, and SmartAcme takes care of the rest.
```typescript
const router = new DcRouter({
smartProxyConfig: {
routes: [
{
name: 'secure-app',
match: { domains: ['app.example.com'], ports: [443] },
action: {
type: 'forward',
targets: [{ host: '192.168.1.10', port: 8080 }],
tls: { mode: 'terminate', certificate: 'auto' } // ← triggers ACME provisioning
}
}
],
acme: { email: 'admin@example .com', enabled: true, useProduction: true }
},
tls: { contactEmail: 'admin@example .com' },
dnsChallenge: { cloudflareApiKey: process.env.CLOUDFLARE_API_KEY }
});
```
### smartacme v9 Features
| Feature | Description |
|---------|-------------|
| **Per-domain deduplication ** | Concurrent requests for the same domain share a single ACME operation |
| **Global concurrency cap ** | Default 5 parallel ACME operations to prevent overload |
| **Account rate limiting ** | Sliding window (250 orders / 3 hours) to stay within ACME provider limits |
| **Structured errors ** | `AcmeError` with `isRetryable` , `isRateLimited` , `retryAfter` fields |
| **Clean shutdown ** | `stop()` properly destroys HTTP agents and DNS clients |
### Per-Domain Backoff
DcRouter's `CertProvisionScheduler` adds **per-domain exponential backoff ** on top of smartacme's built-in protections. If a DNS-01 challenge fails for a domain:
1. The failure is recorded (persisted to storage)
2. The domain enters backoff: `min(failures² × 1 hour, 24 hours)`
3. Subsequent requests for that domain are rejected until the backoff expires
4. On success, the backoff is cleared
This prevents hammering ACME servers for domains with persistent issues (e.g. missing DNS delegation).
### Fallback to HTTP-01
If DNS-01 fails, the `certProvisionFunction` returns `'http01'` to tell SmartProxy to fall back to HTTP-01 challenge validation. This provides a safety net for domains where DNS-01 isn't viable.
### Certificate Storage
Certificates are persisted via the `StorageBackedCertManager` which uses DcRouter's `StorageManager` . This means certs survive restarts and don't need to be re-provisioned unless they expire.
### Dashboard
The OpsServer includes a **Certificates ** view showing:
- All domains with their certificate status (valid, expiring, expired, failed)
- Certificate source (ACME, provision function, static)
- Expiry dates and issuer information
- Backoff status for failed domains
- One-click reprovisioning per domain
2026-02-11 16:32:49 +00:00
## Storage & Caching
2025-05-30 07:06:00 +00:00
### StorageManager
2026-02-11 16:32:49 +00:00
Provides a unified key-value interface with three backends:
2025-05-30 07:06:00 +00:00
```typescript
2026-02-11 16:32:49 +00:00
// Filesystem backend
storage: { fsPath: '/var/lib/dcrouter/data' }
2025-05-30 07:06:00 +00:00
2026-02-11 16:32:49 +00:00
// Custom backend (Redis, S3, etc.)
storage: {
readFunction: async (key) => await redis.get(key),
writeFunction: async (key, value) => await redis.set(key, value)
}
// In-memory (development only — data lost on restart)
// Simply omit the storage config
2025-05-30 07:06:00 +00:00
```
2026-02-16 00:22:23 +00:00
Used for: TLS certificates, DKIM keys, email routes, bounce/suppression lists, IP reputation data, domain configs, cert backoff state.
2026-02-11 16:32:49 +00:00
### Cache Database
2026-02-12 10:15:26 +00:00
An embedded MongoDB-compatible database (via smartdata + LocalTsmDb) for persistent caching with automatic TTL cleanup:
2026-02-11 16:32:49 +00:00
2025-05-30 07:06:00 +00:00
```typescript
2026-02-11 16:32:49 +00:00
cacheConfig: {
enabled: true,
2026-02-12 14:20:42 +00:00
storagePath: '~/.serve.zone/dcrouter/tsmdb',
2026-02-11 16:32:49 +00:00
dbName: 'dcrouter',
cleanupIntervalHours: 1,
ttlConfig: {
emails: 30, // days
ipReputation: 1, // days
bounces: 30, // days
dkimKeys: 90, // days
suppression: 30 // days
}
}
2025-05-30 07:06:00 +00:00
```
2026-02-12 10:15:26 +00:00
Cached document types: `CachedEmail` , `CachedIPReputation` .
2025-05-30 07:06:00 +00:00
2025-05-22 13:10:45 +00:00
## Security Features
2024-05-11 12:33:14 +02:00
2025-05-22 13:10:45 +00:00
### IP Reputation Checking
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
Automatic IP reputation checks on inbound connections with configurable caching:
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
// IP reputation is checked automatically for inbound SMTP connections.
// Results are cached according to cacheConfig.ttlConfig.ipReputation.
```
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
### Rate Limiting
2024-05-11 12:33:14 +02:00
2026-02-11 16:32:49 +00:00
Hierarchical rate limits with three levels of specificity:
```typescript
// Global defaults (via emailConfig.defaults.rateLimits)
defaults: {
rateLimits: {
inbound: { messagesPerMinute: 50, connectionsPerIp: 5, recipientsPerMessage: 50 },
outbound: { messagesPerMinute: 100 }
}
}
// Per-domain overrides (in domain config)
{
domain: 'high-volume.com',
rateLimits: {
outbound: { messagesPerMinute: 500 } // Override for this domain
}
2024-05-11 12:33:14 +02:00
}
2025-05-22 13:10:45 +00:00
```
2026-02-11 16:32:49 +00:00
**Precedence**: Domain-specific > Pattern-specific > Global
### Content Scanning
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
action: {
type: 'process',
options: {
contentScanning: true,
scanners: [
{ type: 'spam', threshold: 5.0, action: 'tag' },
{ type: 'virus', action: 'reject' },
{ type: 'attachment', blockedExtensions: ['.exe', '.bat', '.scr'], action: 'reject' }
]
2025-05-22 13:10:45 +00:00
}
2026-02-11 16:32:49 +00:00
}
2026-02-02 22:21:55 +00:00
```
## OpsServer Dashboard
2026-02-11 16:32:49 +00:00
The OpsServer provides a web-based management interface served on port 3000. It's built with modern web components using [@design.estate/dees-catalog ](https://code.foss.global/design.estate/dees-catalog ).
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
### Dashboard Views
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
| View | Description |
|------|-------------|
| 📊 **Overview ** | Real-time server stats, CPU/memory, connection counts, email throughput |
| 🌐 **Network ** | Active connections, top IPs, throughput rates, SmartProxy metrics |
| 📧 **Email ** | Queue monitoring (queued/sent/failed), bounce records, security incidents |
2026-02-16 00:22:23 +00:00
| 🔐 **Certificates ** | Domain-centric certificate overview, status, backoff info, reprovisioning |
2026-02-11 16:32:49 +00:00
| 📜 **Logs ** | Real-time log viewer with level filtering and search |
| ⚙️ **Configuration ** | Read-only view of current system configuration |
| 🛡️ **Security ** | IP reputation, rate limit status, blocked connections |
2026-02-02 22:21:55 +00:00
### API Endpoints
2026-02-11 16:32:49 +00:00
All management is done via TypedRequest over HTTP POST to `/typedrequest` :
2026-02-02 22:21:55 +00:00
```typescript
2026-02-11 16:32:49 +00:00
// Authentication
2026-02-12 10:15:26 +00:00
'adminLoginWithUsernameAndPassword' // Login with credentials → returns JWT identity
'verifyIdentity' // Verify JWT token validity
'adminLogout' // End admin session
2026-02-11 16:32:49 +00:00
2026-02-12 10:15:26 +00:00
// Statistics & Health
'getServerStatistics' // Uptime, CPU, memory, connections
'getHealthStatus' // System health check
'getCombinedMetrics' // All metrics in one call
2026-02-02 22:21:55 +00:00
2026-02-11 16:32:49 +00:00
// Email Operations
2026-02-12 10:15:26 +00:00
'getQueuedEmails' // Emails pending delivery
'getSentEmails' // Successfully delivered emails
'getFailedEmails' // Failed emails
'resendEmail' // Re-queue a failed email
'getBounceRecords' // Bounce records
'removeFromSuppressionList' // Unsuppress an address
2024-05-11 12:33:14 +02:00
2026-02-16 00:22:23 +00:00
// Certificates
'getCertificateOverview' // Domain-centric certificate status
'reprovisionCertificate' // Reprovision by route name (legacy)
'reprovisionCertificateDomain' // Reprovision by domain (preferred)
2026-02-03 23:26:51 +00:00
// Configuration (read-only)
2026-02-12 10:15:26 +00:00
'getConfiguration' // Current system config
2026-02-02 22:21:55 +00:00
// Logs
2026-02-12 10:15:26 +00:00
'getLogs' // Retrieve system logs
2026-02-02 22:21:55 +00:00
// RADIUS
2026-02-12 10:15:26 +00:00
'getRadiusSessions' // Active RADIUS sessions
'getRadiusClients' // List NAS clients
'getRadiusStatistics' // RADIUS stats
'setRadiusClient' // Add/update NAS client
'removeRadiusClient' // Remove NAS client
'getVlanMappings' // List VLAN mappings
'setVlanMapping' // Add/update VLAN mapping
'removeVlanMapping' // Remove VLAN mapping
'testVlanAssignment' // Test what VLAN a MAC gets
2024-05-11 12:33:14 +02:00
```
2025-05-22 13:10:45 +00:00
## API Reference
2025-03-15 16:09:18 +00:00
2025-05-22 13:10:45 +00:00
### DcRouter Class
2025-03-15 16:09:18 +00:00
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
import { DcRouter } from '@serve .zone/dcrouter';
const router = new DcRouter(options: IDcRouterOptions);
2025-03-15 16:09:18 +00:00
```
2025-05-22 13:10:45 +00:00
#### Methods
2026-02-11 16:32:49 +00:00
| Method | Description |
|--------|-------------|
| `start(): Promise<void>` | Start all configured services |
| `stop(): Promise<void>` | Gracefully stop all services |
| `updateSmartProxyConfig(config): Promise<void>` | Hot-update SmartProxy routes |
| `updateEmailConfig(config): Promise<void>` | Hot-update email configuration |
| `updateEmailRoutes(routes): Promise<void>` | Update email routing rules at runtime |
| `updateRadiusConfig(config): Promise<void>` | Hot-update RADIUS configuration |
| `getStats(): any` | Get real-time statistics from all services |
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
#### Properties
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
| Property | Type | Description |
|----------|------|-------------|
| `options` | `IDcRouterOptions` | Current configuration |
| `smartProxy` | `SmartProxy` | SmartProxy instance |
2026-02-16 00:22:23 +00:00
| `smartAcme` | `SmartAcme` | SmartAcme v9 certificate manager instance |
2026-02-12 10:15:26 +00:00
| `emailServer` | `UnifiedEmailServer` | Email server instance (from smartmta) |
2026-02-11 16:32:49 +00:00
| `dnsServer` | `DnsServer` | DNS server instance |
| `radiusServer` | `RadiusServer` | RADIUS server instance |
| `storageManager` | `StorageManager` | Storage backend |
| `opsServer` | `OpsServer` | OpsServer/dashboard instance |
| `metricsManager` | `MetricsManager` | Metrics collector |
| `cacheDb` | `CacheDb` | Cache database instance |
2026-02-16 00:22:23 +00:00
| `certProvisionScheduler` | `CertProvisionScheduler` | Per-domain backoff scheduler for cert provisioning |
| `certificateStatusMap` | `Map<string, ...>` | Domain-keyed certificate status from SmartProxy events |
2025-05-22 13:10:45 +00:00
2026-02-12 10:15:26 +00:00
### Re-exported Types
DcRouter re-exports key types from smartmta for convenience:
```typescript
import {
DcRouter,
IDcRouterOptions,
UnifiedEmailServer,
type IUnifiedEmailServerOptions,
type IEmailRoute,
type IEmailDomainConfig,
} from '@serve .zone/dcrouter';
```
2026-02-11 16:32:49 +00:00
## Sub-Modules
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
DcRouter is published as a monorepo with separately-installable interface and web packages:
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
| Package | Description | Install |
|---------|-------------|---------|
| [`@serve.zone/dcrouter` ](https://www.npmjs.com/package/@serve.zone/dcrouter ) | Main package — the full router | `pnpm add @serve.zone/dcrouter` |
| [`@serve.zone/dcrouter-interfaces` ](https://www.npmjs.com/package/@serve.zone/dcrouter-interfaces ) | TypedRequest interfaces for the OpsServer API | `pnpm add @serve.zone/dcrouter-interfaces` |
| [`@serve.zone/dcrouter-web` ](https://www.npmjs.com/package/@serve.zone/dcrouter-web ) | Web dashboard components | `pnpm add @serve.zone/dcrouter-web` |
2025-05-22 13:10:45 +00:00
2026-02-11 16:32:49 +00:00
You can also import interfaces directly from the main package:
2025-05-22 13:10:45 +00:00
```typescript
2026-02-11 16:32:49 +00:00
import { data, requests } from '@serve .zone/dcrouter/interfaces';
2025-05-22 13:10:45 +00:00
```
2025-05-08 00:39:43 +00:00
2026-02-02 22:21:55 +00:00
## Testing
2025-05-22 13:10:45 +00:00
2026-02-12 10:15:26 +00:00
DcRouter includes a comprehensive test suite covering all system components:
2026-02-02 22:21:55 +00:00
```bash
2026-02-12 10:15:26 +00:00
# Run all tests (10 files, 73 tests)
2026-02-02 22:21:55 +00:00
pnpm test
2026-02-11 16:32:49 +00:00
# Run a specific test file
2026-02-12 10:15:26 +00:00
tstest test/test.jwt-auth.ts --verbose
# Run with extended timeout
tstest test/test.opsserver-api.ts --verbose --timeout 60
```
### Test Coverage
| Test File | Area | Tests |
|-----------|------|-------|
| `test.contentscanner.ts` | Content scanning (spam, phishing, malware, attachments) | 13 |
| `test.dcrouter.email.ts` | Email config, domain and route setup | 4 |
| `test.dns-server-config.ts` | DNS record parsing, grouping, extraction | 5 |
| `test.dns-socket-handler.ts` | DNS socket handler and route generation | 6 |
| `test.errors.ts` | Error classes, handler, retry utilities | 5 |
| `test.ipreputationchecker.ts` | IP reputation, DNSBL, caching, risk classification | 10 |
| `test.jwt-auth.ts` | JWT login, verification, logout, invalid credentials | 8 |
| `test.opsserver-api.ts` | Health, statistics, configuration, log APIs | 6 |
| `test.protected-endpoint.ts` | Admin auth, identity verification, public endpoints | 8 |
| `test.storagemanager.ts` | Memory, filesystem, custom backends, concurrency | 8 |
2025-05-22 13:10:45 +00:00
2026-02-02 22:21:55 +00:00
## License and Legal Information
2025-05-22 13:10:45 +00:00
2026-02-02 22:21:55 +00:00
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE ](./LICENSE ) file.
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
### Trademarks
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
### Company Information
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
2025-05-23 19:03:44 +00:00
2026-02-02 22:21:55 +00:00
For any legal inquiries or further information, please contact us via email at hello@task .vc.
2025-05-22 13:10:45 +00:00
2026-02-02 22:21:55 +00:00
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.