@serve.zone/dcrouter 11.0.25 → 11.0.27
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.
- package/dist_serve/bundle.js +1 -1
- package/dist_ts/classes.dcrouter.d.ts +337 -0
- package/dist_ts/classes.dcrouter.js +1405 -0
- package/dist_ts/config/classes.api-token-manager.d.ts +46 -0
- package/dist_ts/config/classes.api-token-manager.js +150 -0
- package/dist_ts/config/classes.route-config-manager.d.ts +35 -0
- package/dist_ts/config/index.d.ts +3 -0
- package/dist_ts/config/index.js +5 -0
- package/dist_ts/errors/error-handler.d.ts +98 -0
- package/dist_ts/errors/error-handler.js +282 -0
- package/dist_ts/errors/index.d.ts +54 -0
- package/dist_ts/errors/index.js +136 -0
- package/dist_ts/errors/reputation.errors.d.ts +183 -0
- package/dist_ts/errors/reputation.errors.js +292 -0
- package/dist_ts/index.d.ts +7 -0
- package/dist_ts/index.js +11 -0
- package/dist_ts/security/classes.contentscanner.d.ts +164 -0
- package/dist_ts/security/classes.contentscanner.js +642 -0
- package/dist_ts/security/classes.ipreputationchecker.d.ts +160 -0
- package/dist_ts/security/classes.ipreputationchecker.js +537 -0
- package/dist_ts/security/index.d.ts +3 -0
- package/dist_ts/security/index.js +4 -0
- package/dist_ts/sms/classes.smsservice.d.ts +15 -0
- package/dist_ts/sms/classes.smsservice.js +72 -0
- package/dist_ts/sms/config/sms.config.d.ts +93 -0
- package/dist_ts/sms/config/sms.config.js +2 -0
- package/dist_ts/sms/config/sms.schema.d.ts +5 -0
- package/dist_ts/sms/config/sms.schema.js +121 -0
- package/dist_ts/sms/index.d.ts +1 -0
- package/dist_ts/sms/index.js +2 -0
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/package.json +2 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
package/dist_serve/bundle.js
CHANGED
|
@@ -39328,4 +39328,4 @@ ibantools/jsnext/ibantools.js:
|
|
|
39328
39328
|
* @preferred
|
|
39329
39329
|
*)
|
|
39330
39330
|
*/
|
|
39331
|
-
//# sourceMappingURL=bundle-
|
|
39331
|
+
//# sourceMappingURL=bundle-1772721147050.js.map
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import * as paths from './paths.js';
|
|
3
|
+
import { UnifiedEmailServer, type IUnifiedEmailServerOptions, type IEmailRoute } from '@push.rocks/smartmta';
|
|
4
|
+
import { StorageManager, type IStorageConfig } from './storage/index.js';
|
|
5
|
+
import { CertProvisionScheduler } from './classes.cert-provision-scheduler.js';
|
|
6
|
+
import { CacheDb, CacheCleaner } from './cache/index.js';
|
|
7
|
+
import { OpsServer } from './opsserver/index.js';
|
|
8
|
+
import { MetricsManager } from './monitoring/index.js';
|
|
9
|
+
import { RadiusServer, type IRadiusServerConfig } from './radius/index.js';
|
|
10
|
+
import { RemoteIngressManager, TunnelManager } from './remoteingress/index.js';
|
|
11
|
+
import { RouteConfigManager, ApiTokenManager } from './config/index.js';
|
|
12
|
+
export interface IDcRouterOptions {
|
|
13
|
+
/** Base directory for all dcrouter data. Defaults to ~/.serve.zone/dcrouter */
|
|
14
|
+
baseDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Direct SmartProxy configuration - gives full control over HTTP/HTTPS and TCP/SNI traffic
|
|
17
|
+
* This is the preferred way to configure HTTP/HTTPS and general TCP/SNI traffic
|
|
18
|
+
*/
|
|
19
|
+
smartProxyConfig?: plugins.smartproxy.ISmartProxyOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Email server configuration
|
|
22
|
+
* This enables all email handling with pattern-based routing
|
|
23
|
+
*/
|
|
24
|
+
emailConfig?: IUnifiedEmailServerOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Custom email port configuration
|
|
27
|
+
* Allows configuring specific ports for email handling
|
|
28
|
+
* This overrides the default port mapping in the emailConfig
|
|
29
|
+
*/
|
|
30
|
+
emailPortConfig?: {
|
|
31
|
+
/** External to internal port mapping */
|
|
32
|
+
portMapping?: Record<number, number>;
|
|
33
|
+
/** Custom port configuration for specific ports */
|
|
34
|
+
portSettings?: Record<number, any>;
|
|
35
|
+
/** Path to store received emails */
|
|
36
|
+
receivedEmailsPath?: string;
|
|
37
|
+
};
|
|
38
|
+
/** TLS/certificate configuration */
|
|
39
|
+
tls?: {
|
|
40
|
+
/** Contact email for ACME certificates */
|
|
41
|
+
contactEmail: string;
|
|
42
|
+
/** Domain for main certificate */
|
|
43
|
+
domain?: string;
|
|
44
|
+
/** Path to certificate file (if not using auto-provisioning) */
|
|
45
|
+
certPath?: string;
|
|
46
|
+
/** Path to key file (if not using auto-provisioning) */
|
|
47
|
+
keyPath?: string;
|
|
48
|
+
/** Path to CA certificate file (for custom CAs) */
|
|
49
|
+
caPath?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The nameserver domains (e.g., ['ns1.example.com', 'ns2.example.com'])
|
|
53
|
+
* These will automatically get A records pointing to publicIp or proxyIps[0]
|
|
54
|
+
* These are what go in the NS records for ALL domains in dnsScopes
|
|
55
|
+
*/
|
|
56
|
+
dnsNsDomains?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Domains this DNS server is authoritative for (e.g., ['example.com', 'mail.example.org'])
|
|
59
|
+
* NS records will be auto-generated for these domains
|
|
60
|
+
* Any DNS record outside these scopes will trigger a warning
|
|
61
|
+
* Email domains with `internal-dns` mode must be included here
|
|
62
|
+
*/
|
|
63
|
+
dnsScopes?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* IPs of proxies that forward traffic to your server (optional)
|
|
66
|
+
* When defined AND useIngressProxy is true, A records with server IP are replaced with proxy IPs
|
|
67
|
+
* If not defined or empty, all A records use the real server IP
|
|
68
|
+
* Helps hide real server IP for security/privacy
|
|
69
|
+
*/
|
|
70
|
+
proxyIps?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Public IP address for nameserver A records (required if proxyIps not set)
|
|
73
|
+
* This is the IP that will be used for the nameserver domains (dnsNsDomains)
|
|
74
|
+
* If proxyIps is set, the first proxy IP will be used instead
|
|
75
|
+
*/
|
|
76
|
+
publicIp?: string;
|
|
77
|
+
/**
|
|
78
|
+
* DNS records to register
|
|
79
|
+
* Must be within the defined dnsScopes (or receive warning)
|
|
80
|
+
* Only need A, CNAME, TXT, MX records (NS records auto-generated, SOA handled by smartdns)
|
|
81
|
+
* Can use `useIngressProxy: false` to expose real server IP (defaults to true)
|
|
82
|
+
*/
|
|
83
|
+
dnsRecords?: Array<{
|
|
84
|
+
name: string;
|
|
85
|
+
type: 'A' | 'AAAA' | 'CNAME' | 'MX' | 'TXT' | 'NS' | 'SOA';
|
|
86
|
+
value: string;
|
|
87
|
+
ttl?: number;
|
|
88
|
+
useIngressProxy?: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
/** DNS challenge configuration for ACME (optional) */
|
|
91
|
+
dnsChallenge?: {
|
|
92
|
+
/** Cloudflare API key for DNS challenges */
|
|
93
|
+
cloudflareApiKey?: string;
|
|
94
|
+
};
|
|
95
|
+
/** Storage configuration */
|
|
96
|
+
storage?: IStorageConfig;
|
|
97
|
+
/**
|
|
98
|
+
* Cache database configuration using smartdata and LocalTsmDb
|
|
99
|
+
* Provides persistent caching for emails, IP reputation, bounces, etc.
|
|
100
|
+
*/
|
|
101
|
+
cacheConfig?: {
|
|
102
|
+
/** Enable cache database (default: true) */
|
|
103
|
+
enabled?: boolean;
|
|
104
|
+
/** Storage path for TsmDB data (default: ~/.serve.zone/dcrouter/tsmdb) */
|
|
105
|
+
storagePath?: string;
|
|
106
|
+
/** Database name (default: dcrouter) */
|
|
107
|
+
dbName?: string;
|
|
108
|
+
/** Default TTL in days for cached items (default: 30) */
|
|
109
|
+
defaultTTLDays?: number;
|
|
110
|
+
/** Cleanup interval in hours (default: 1) */
|
|
111
|
+
cleanupIntervalHours?: number;
|
|
112
|
+
/** TTL configuration per data type (in days) */
|
|
113
|
+
ttlConfig?: {
|
|
114
|
+
/** Email cache TTL (default: 30 days) */
|
|
115
|
+
emails?: number;
|
|
116
|
+
/** IP reputation cache TTL (default: 1 day) */
|
|
117
|
+
ipReputation?: number;
|
|
118
|
+
/** Bounce records TTL (default: 30 days) */
|
|
119
|
+
bounces?: number;
|
|
120
|
+
/** DKIM keys TTL (default: 90 days) */
|
|
121
|
+
dkimKeys?: number;
|
|
122
|
+
/** Suppression list TTL (default: 30 days, can be permanent) */
|
|
123
|
+
suppression?: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* RADIUS server configuration for network authentication
|
|
128
|
+
* Enables MAC Authentication Bypass (MAB) and VLAN assignment
|
|
129
|
+
*/
|
|
130
|
+
radiusConfig?: IRadiusServerConfig;
|
|
131
|
+
/**
|
|
132
|
+
* Remote Ingress configuration for edge tunnel nodes
|
|
133
|
+
* Enables edge nodes to accept incoming connections and tunnel them to this DcRouter
|
|
134
|
+
*/
|
|
135
|
+
remoteIngressConfig?: {
|
|
136
|
+
/** Enable remote ingress hub (default: false) */
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
/** Port for tunnel connections from edge nodes (default: 8443) */
|
|
139
|
+
tunnelPort?: number;
|
|
140
|
+
/** External hostname of this hub, embedded in connection tokens */
|
|
141
|
+
hubDomain?: string;
|
|
142
|
+
/** TLS configuration for the tunnel server */
|
|
143
|
+
tls?: {
|
|
144
|
+
certPath?: string;
|
|
145
|
+
keyPath?: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* DcRouter can be run on ingress and egress to and from a datacenter site.
|
|
151
|
+
*/
|
|
152
|
+
/**
|
|
153
|
+
* Context passed to HTTP routing rules
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* Context passed to port proxy (SmartProxy) routing rules
|
|
157
|
+
*/
|
|
158
|
+
export interface PortProxyRuleContext {
|
|
159
|
+
proxy: plugins.smartproxy.SmartProxy;
|
|
160
|
+
routes: plugins.smartproxy.IRouteConfig[];
|
|
161
|
+
}
|
|
162
|
+
export declare class DcRouter {
|
|
163
|
+
options: IDcRouterOptions;
|
|
164
|
+
resolvedPaths: ReturnType<typeof paths.resolvePaths>;
|
|
165
|
+
smartProxy?: plugins.smartproxy.SmartProxy;
|
|
166
|
+
smartAcme?: plugins.smartacme.SmartAcme;
|
|
167
|
+
dnsServer?: plugins.smartdns.dnsServerMod.DnsServer;
|
|
168
|
+
emailServer?: UnifiedEmailServer;
|
|
169
|
+
radiusServer?: RadiusServer;
|
|
170
|
+
storageManager: StorageManager;
|
|
171
|
+
opsServer: OpsServer;
|
|
172
|
+
metricsManager?: MetricsManager;
|
|
173
|
+
cacheDb?: CacheDb;
|
|
174
|
+
cacheCleaner?: CacheCleaner;
|
|
175
|
+
remoteIngressManager?: RemoteIngressManager;
|
|
176
|
+
tunnelManager?: TunnelManager;
|
|
177
|
+
routeConfigManager?: RouteConfigManager;
|
|
178
|
+
apiTokenManager?: ApiTokenManager;
|
|
179
|
+
detectedPublicIp: string | null;
|
|
180
|
+
private dnsLogWindowSecond;
|
|
181
|
+
private dnsLogWindowCount;
|
|
182
|
+
private dnsBatchCount;
|
|
183
|
+
private dnsBatchTimer;
|
|
184
|
+
certificateStatusMap: Map<string, {
|
|
185
|
+
status: "valid" | "failed";
|
|
186
|
+
routeNames: string[];
|
|
187
|
+
expiryDate?: string;
|
|
188
|
+
issuedAt?: string;
|
|
189
|
+
source?: string;
|
|
190
|
+
error?: string;
|
|
191
|
+
}>;
|
|
192
|
+
certProvisionScheduler?: CertProvisionScheduler;
|
|
193
|
+
typedrouter: plugins.typedrequest.TypedRouter<import("@api.global/typedrequest-interfaces").ITypedRequest>;
|
|
194
|
+
private constructorRoutes;
|
|
195
|
+
private qenv;
|
|
196
|
+
constructor(optionsArg: IDcRouterOptions);
|
|
197
|
+
start(): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Log comprehensive startup summary
|
|
200
|
+
*/
|
|
201
|
+
private logStartupSummary;
|
|
202
|
+
/**
|
|
203
|
+
* Set up the cache database (smartdata + LocalTsmDb)
|
|
204
|
+
*/
|
|
205
|
+
private setupCacheDb;
|
|
206
|
+
/**
|
|
207
|
+
* Set up SmartProxy with direct configuration and automatic email routes
|
|
208
|
+
*/
|
|
209
|
+
private setupSmartProxy;
|
|
210
|
+
/**
|
|
211
|
+
* Generate SmartProxy routes for email configuration
|
|
212
|
+
*/
|
|
213
|
+
private generateEmailRoutes;
|
|
214
|
+
/**
|
|
215
|
+
* Generate SmartProxy routes for DNS configuration
|
|
216
|
+
*/
|
|
217
|
+
private generateDnsRoutes;
|
|
218
|
+
/**
|
|
219
|
+
* Check if a domain matches a pattern (including wildcard support)
|
|
220
|
+
* @param domain The domain to check
|
|
221
|
+
* @param pattern The pattern to match against (e.g., "*.example.com")
|
|
222
|
+
* @returns Whether the domain matches the pattern
|
|
223
|
+
*/
|
|
224
|
+
private isDomainMatch;
|
|
225
|
+
/**
|
|
226
|
+
* Find the first route name that matches a given domain
|
|
227
|
+
*/
|
|
228
|
+
private findRouteNameForDomain;
|
|
229
|
+
/**
|
|
230
|
+
* Find ALL route names that match a given domain
|
|
231
|
+
*/
|
|
232
|
+
findRouteNamesForDomain(domain: string): string[];
|
|
233
|
+
/**
|
|
234
|
+
* Get the routes derived from constructor config (smartProxy + email + DNS).
|
|
235
|
+
* Used by RouteConfigManager as the "hardcoded" base.
|
|
236
|
+
*/
|
|
237
|
+
getConstructorRoutes(): plugins.smartproxy.IRouteConfig[];
|
|
238
|
+
stop(): Promise<void>;
|
|
239
|
+
/**
|
|
240
|
+
* Update SmartProxy configuration
|
|
241
|
+
* @param config New SmartProxy configuration
|
|
242
|
+
*/
|
|
243
|
+
updateSmartProxyConfig(config: plugins.smartproxy.ISmartProxyOptions): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Set up unified email handling with pattern-based routing
|
|
246
|
+
* This implements the consolidated emailConfig approach
|
|
247
|
+
*/
|
|
248
|
+
private setupUnifiedEmailHandling;
|
|
249
|
+
/**
|
|
250
|
+
* Update the unified email configuration
|
|
251
|
+
* @param config New email configuration
|
|
252
|
+
*/
|
|
253
|
+
updateEmailConfig(config: IUnifiedEmailServerOptions): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Stop all unified email components
|
|
256
|
+
*/
|
|
257
|
+
private stopUnifiedEmailComponents;
|
|
258
|
+
/**
|
|
259
|
+
* Update domain rules for email routing
|
|
260
|
+
* @param rules New domain rules to apply
|
|
261
|
+
*/
|
|
262
|
+
updateEmailRoutes(routes: IEmailRoute[]): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Get statistics from all components
|
|
265
|
+
*/
|
|
266
|
+
getStats(): any;
|
|
267
|
+
/**
|
|
268
|
+
* Register DNS records with the DNS server
|
|
269
|
+
* @param records Array of DNS records to register
|
|
270
|
+
*/
|
|
271
|
+
private registerDnsRecords;
|
|
272
|
+
/**
|
|
273
|
+
* Parse DNS record data based on record type
|
|
274
|
+
* @param type DNS record type
|
|
275
|
+
* @param value DNS record value
|
|
276
|
+
* @returns Parsed data for the DNS response
|
|
277
|
+
*/
|
|
278
|
+
private parseDnsRecordData;
|
|
279
|
+
/**
|
|
280
|
+
* Set up DNS server with socket handler for DoH
|
|
281
|
+
*/
|
|
282
|
+
private setupDnsWithSocketHandler;
|
|
283
|
+
/**
|
|
284
|
+
* Create DNS socket handler for DoH
|
|
285
|
+
*/
|
|
286
|
+
private createDnsSocketHandler;
|
|
287
|
+
/**
|
|
288
|
+
* Validate DNS configuration
|
|
289
|
+
*/
|
|
290
|
+
private validateDnsConfiguration;
|
|
291
|
+
/**
|
|
292
|
+
* Generate email DNS records for domains with internal-dns mode
|
|
293
|
+
*/
|
|
294
|
+
private generateEmailDnsRecords;
|
|
295
|
+
/**
|
|
296
|
+
* Load DKIM records from JSON files
|
|
297
|
+
* Reads all *.dkimrecord.json files from the DNS records directory
|
|
298
|
+
*/
|
|
299
|
+
private loadDkimRecords;
|
|
300
|
+
/**
|
|
301
|
+
* Initialize DKIM keys for all configured email domains
|
|
302
|
+
* This ensures DKIM records are available immediately at startup
|
|
303
|
+
*/
|
|
304
|
+
private initializeDkimForEmailDomains;
|
|
305
|
+
/**
|
|
306
|
+
* Generate authoritative DNS records (NS only) for all domains in dnsScopes
|
|
307
|
+
* SOA records are now automatically generated by smartdns with primaryNameserver setting
|
|
308
|
+
*/
|
|
309
|
+
private generateAuthoritativeRecords;
|
|
310
|
+
/**
|
|
311
|
+
* Extract the base domain from a DNS record name
|
|
312
|
+
*/
|
|
313
|
+
private extractDomain;
|
|
314
|
+
/**
|
|
315
|
+
* Apply proxy IP replacement logic to DNS records
|
|
316
|
+
*/
|
|
317
|
+
private applyProxyIpReplacement;
|
|
318
|
+
/**
|
|
319
|
+
* Detect the server's public IP address
|
|
320
|
+
*/
|
|
321
|
+
private detectServerPublicIp;
|
|
322
|
+
/**
|
|
323
|
+
* Set up Remote Ingress hub for edge tunnel connections
|
|
324
|
+
*/
|
|
325
|
+
private setupRemoteIngress;
|
|
326
|
+
/**
|
|
327
|
+
* Set up RADIUS server for network authentication
|
|
328
|
+
*/
|
|
329
|
+
private setupRadiusServer;
|
|
330
|
+
/**
|
|
331
|
+
* Update RADIUS configuration at runtime
|
|
332
|
+
*/
|
|
333
|
+
updateRadiusConfig(config: IRadiusServerConfig): Promise<void>;
|
|
334
|
+
}
|
|
335
|
+
export type { IUnifiedEmailServerOptions };
|
|
336
|
+
export type { IRadiusServerConfig };
|
|
337
|
+
export default DcRouter;
|