# @serve.zone/dcrouter The core DcRouter package — a unified datacenter gateway orchestrator. 🚀 This is the main entry point for DcRouter. It provides the `DcRouter` class that wires together SmartProxy, smartmta, SmartDNS, SmartRadius, RemoteIngress, and the OpsServer dashboard into a single cohesive service. ## 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. ## Installation ```bash pnpm add @serve.zone/dcrouter ``` ## Usage ```typescript import { DcRouter } from '@serve.zone/dcrouter'; const router = new DcRouter({ smartProxyConfig: { routes: [ { name: 'web-app', match: { domains: ['example.com'], ports: [443] }, action: { type: 'forward', targets: [{ host: '192.168.1.10', port: 8080 }], tls: { mode: 'terminate', certificate: 'auto' } } } ], acme: { email: 'admin@example.com', enabled: true, useProduction: true } } }); await router.start(); // OpsServer dashboard at http://localhost:3000 // Graceful shutdown await router.stop(); ``` ## Module Structure ``` ts/ ├── index.ts # Main exports (DcRouter, re-exported smartmta types) ├── classes.dcrouter.ts # DcRouter orchestrator class + IDcRouterOptions ├── classes.cert-provision-scheduler.ts # Per-domain cert backoff scheduler ├── classes.storage-cert-manager.ts # SmartAcme cert manager backed by StorageManager ├── logger.ts # Structured logging utility ├── paths.ts # Centralized data directory paths ├── plugins.ts # All dependency imports ├── cache/ # Cache database (smartdata + LocalTsmDb) │ ├── classes.cachedb.ts # CacheDb singleton │ ├── classes.cachecleaner.ts # TTL-based cleanup │ └── documents/ # Cached document models ├── config/ # Configuration utilities ├── errors/ # Error classes and retry logic ├── monitoring/ # MetricsManager (SmartMetrics integration) ├── opsserver/ # OpsServer dashboard + API handlers │ ├── classes.opsserver.ts # HTTP server + TypedRouter setup │ └── handlers/ # TypedRequest handlers by domain │ ├── admin.handler.ts # Auth (login/logout/verify) │ ├── stats.handler.ts # Statistics + health │ ├── config.handler.ts # Configuration (read-only) │ ├── logs.handler.ts # Log retrieval │ ├── email.handler.ts # Email operations │ ├── certificate.handler.ts # Certificate management │ ├── radius.handler.ts # RADIUS management │ └── remoteingress.handler.ts # Remote ingress edge + token management ├── radius/ # RADIUS server integration ├── remoteingress/ # Remote ingress hub integration │ ├── classes.remoteingress-manager.ts # Edge CRUD + port derivation │ └── classes.tunnel-manager.ts # Rust hub lifecycle + status tracking ├── security/ # Security utilities ├── sms/ # SMS integration └── storage/ # StorageManager (filesystem/custom/memory) ``` ## Exports ```typescript // Main class export { DcRouter, IDcRouterOptions } from './classes.dcrouter.js'; // Re-exported from smartmta export { UnifiedEmailServer } from '@push.rocks/smartmta'; export type { IUnifiedEmailServerOptions, IEmailRoute, IEmailDomainConfig } from '@push.rocks/smartmta'; // RADIUS export { RadiusServer, IRadiusServerConfig } from './radius/index.js'; // Remote Ingress export { RemoteIngressManager, TunnelManager } from './remoteingress/index.js'; ``` ## Key Classes ### `DcRouter` The central orchestrator. Accepts `IDcRouterOptions` and manages the lifecycle of all sub-services: | Config Section | Service Started | Package | |----------------|----------------|---------| | `smartProxyConfig` | SmartProxy (HTTP/HTTPS/TCP/SNI) | `@push.rocks/smartproxy` | | `emailConfig` | UnifiedEmailServer (SMTP) | `@push.rocks/smartmta` | | `dnsNsDomains` + `dnsScopes` | DnsServer (UDP + DoH) | `@push.rocks/smartdns` | | `radiusConfig` | RadiusServer (auth + accounting) | `@push.rocks/smartradius` | | `remoteIngressConfig` | RemoteIngressManager + TunnelManager | `@serve.zone/remoteingress` | | `tls` + `dnsChallenge` | SmartAcme (ACME cert provisioning) | `@push.rocks/smartacme` | | `cacheConfig` | CacheDb (embedded MongoDB) | `@push.rocks/smartdata` | | *(always)* | OpsServer (dashboard + API) | `@api.global/typedserver` | | *(always)* | MetricsManager | `@push.rocks/smartmetrics` | ### `RemoteIngressManager` Manages CRUD for remote ingress edge registrations. Persists edges via StorageManager. Provides port derivation from routes tagged with `remoteIngress.enabled`. ### `TunnelManager` Manages the Rust-based RemoteIngressHub lifecycle. Syncs allowed edges, tracks connection status, and exposes edge statuses (connected, publicIp, activeTunnels, lastHeartbeat). ## License and Legal Information This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](../LICENSE) file. **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. ### Trademarks 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. 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. ### Company Information Task Venture Capital GmbH Registered at District Court Bremen HRB 35230 HB, Germany For any legal inquiries or further information, please contact us via email at hello@task.vc. 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.