@serve.zone/dcrouter 11.23.4 → 12.0.0
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/00_commitinfo_data.js +2 -2
- package/dist_ts/classes.cert-provision-scheduler.d.ts +6 -8
- package/dist_ts/classes.cert-provision-scheduler.js +37 -17
- package/dist_ts/classes.dcrouter.d.ts +15 -29
- package/dist_ts/classes.dcrouter.js +96 -91
- package/dist_ts/classes.storage-cert-manager.d.ts +3 -6
- package/dist_ts/classes.storage-cert-manager.js +35 -25
- package/dist_ts/config/classes.api-token-manager.d.ts +1 -3
- package/dist_ts/config/classes.api-token-manager.js +45 -15
- package/dist_ts/config/classes.route-config-manager.d.ts +1 -3
- package/dist_ts/config/classes.route-config-manager.js +63 -25
- package/dist_ts/{cache → db}/classes.cache.cleaner.d.ts +3 -3
- package/dist_ts/db/classes.cache.cleaner.js +130 -0
- package/dist_ts/{cache → db}/classes.cached.document.js +1 -1
- package/dist_ts/db/classes.dcrouter-db.d.ts +70 -0
- package/dist_ts/db/classes.dcrouter-db.js +146 -0
- package/dist_ts/db/documents/classes.accounting-session.doc.d.ts +32 -0
- package/dist_ts/db/documents/classes.accounting-session.doc.js +214 -0
- package/dist_ts/db/documents/classes.acme-cert.doc.d.ts +13 -0
- package/dist_ts/db/documents/classes.acme-cert.doc.js +109 -0
- package/dist_ts/db/documents/classes.api-token.doc.d.ts +18 -0
- package/dist_ts/db/documents/classes.api-token.doc.js +127 -0
- package/dist_ts/{cache → db}/documents/classes.cached.email.js +3 -3
- package/dist_ts/{cache → db}/documents/classes.cached.ip.reputation.js +3 -3
- package/dist_ts/db/documents/classes.cert-backoff.doc.d.ts +11 -0
- package/dist_ts/db/documents/classes.cert-backoff.doc.js +97 -0
- package/dist_ts/db/documents/classes.proxy-cert.doc.d.ts +12 -0
- package/dist_ts/db/documents/classes.proxy-cert.doc.js +103 -0
- package/dist_ts/db/documents/classes.remote-ingress-edge.doc.d.ts +17 -0
- package/dist_ts/db/documents/classes.remote-ingress-edge.doc.js +130 -0
- package/dist_ts/db/documents/classes.route-override.doc.d.ts +10 -0
- package/dist_ts/db/documents/classes.route-override.doc.js +91 -0
- package/dist_ts/db/documents/classes.stored-route.doc.d.ts +12 -0
- package/dist_ts/db/documents/classes.stored-route.doc.js +103 -0
- package/dist_ts/db/documents/classes.vlan-mappings.doc.d.ts +15 -0
- package/dist_ts/db/documents/classes.vlan-mappings.doc.js +77 -0
- package/dist_ts/db/documents/classes.vpn-client.doc.d.ts +18 -0
- package/dist_ts/db/documents/classes.vpn-client.doc.js +136 -0
- package/dist_ts/db/documents/classes.vpn-server-keys.doc.d.ts +10 -0
- package/dist_ts/db/documents/classes.vpn-server-keys.doc.js +94 -0
- package/dist_ts/db/documents/index.d.ts +13 -0
- package/dist_ts/db/documents/index.js +20 -0
- package/dist_ts/{cache → db}/index.d.ts +1 -1
- package/dist_ts/db/index.js +9 -0
- package/dist_ts/opsserver/handlers/certificate.handler.js +66 -66
- package/dist_ts/opsserver/handlers/config.handler.js +14 -15
- package/dist_ts/paths.d.ts +0 -1
- package/dist_ts/paths.js +1 -2
- package/dist_ts/radius/classes.accounting.manager.d.ts +4 -12
- package/dist_ts/radius/classes.accounting.manager.js +80 -93
- package/dist_ts/radius/classes.radius.server.d.ts +1 -3
- package/dist_ts/radius/classes.radius.server.js +4 -6
- package/dist_ts/radius/classes.vlan.manager.d.ts +3 -7
- package/dist_ts/radius/classes.vlan.manager.js +21 -28
- package/dist_ts/radius/index.d.ts +1 -1
- package/dist_ts/radius/index.js +1 -1
- package/dist_ts/remoteingress/classes.remoteingress-manager.d.ts +3 -5
- package/dist_ts/remoteingress/classes.remoteingress-manager.js +41 -21
- package/dist_ts/security/classes.ipreputationchecker.d.ts +6 -21
- package/dist_ts/security/classes.ipreputationchecker.js +59 -138
- package/dist_ts/vpn/classes.vpn-manager.d.ts +4 -22
- package/dist_ts/vpn/classes.vpn-manager.js +40 -45
- package/dist_ts_oci_container/index.js +4 -4
- package/dist_ts_web/00_commitinfo_data.js +2 -2
- package/package.json +1 -1
- package/readme.storage.md +55 -91
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.cert-provision-scheduler.ts +35 -17
- package/ts/classes.dcrouter.ts +113 -125
- package/ts/classes.storage-cert-manager.ts +34 -22
- package/ts/config/classes.api-token-manager.ts +42 -11
- package/ts/config/classes.route-config-manager.ts +57 -22
- package/ts/{cache → db}/classes.cache.cleaner.ts +6 -6
- package/ts/db/classes.dcrouter-db.ts +179 -0
- package/ts/db/documents/classes.accounting-session.doc.ts +106 -0
- package/ts/db/documents/classes.acme-cert.doc.ts +41 -0
- package/ts/db/documents/classes.api-token.doc.ts +56 -0
- package/ts/{cache → db}/documents/classes.cached.email.ts +2 -2
- package/ts/{cache → db}/documents/classes.cached.ip.reputation.ts +2 -2
- package/ts/db/documents/classes.cert-backoff.doc.ts +35 -0
- package/ts/db/documents/classes.proxy-cert.doc.ts +38 -0
- package/ts/db/documents/classes.remote-ingress-edge.doc.ts +54 -0
- package/ts/db/documents/classes.route-override.doc.ts +32 -0
- package/ts/db/documents/classes.stored-route.doc.ts +38 -0
- package/ts/db/documents/classes.vlan-mappings.doc.ts +32 -0
- package/ts/db/documents/classes.vpn-client.doc.ts +57 -0
- package/ts/db/documents/classes.vpn-server-keys.doc.ts +31 -0
- package/ts/db/documents/index.ts +24 -0
- package/ts/{cache → db}/index.ts +6 -2
- package/ts/opsserver/handlers/certificate.handler.ts +67 -65
- package/ts/opsserver/handlers/config.handler.ts +13 -14
- package/ts/paths.ts +0 -1
- package/ts/radius/classes.accounting.manager.ts +81 -103
- package/ts/radius/classes.radius.server.ts +3 -6
- package/ts/radius/classes.vlan.manager.ts +20 -32
- package/ts/radius/index.ts +1 -1
- package/ts/remoteingress/classes.remoteingress-manager.ts +40 -22
- package/ts/security/classes.ipreputationchecker.ts +103 -196
- package/ts/vpn/classes.vpn-manager.ts +44 -75
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/dist_ts/cache/classes.cache.cleaner.js +0 -130
- package/dist_ts/cache/classes.cachedb.d.ts +0 -60
- package/dist_ts/cache/classes.cachedb.js +0 -126
- package/dist_ts/cache/documents/index.d.ts +0 -2
- package/dist_ts/cache/documents/index.js +0 -3
- package/dist_ts/cache/index.js +0 -7
- package/dist_ts/storage/classes.storagemanager.d.ts +0 -83
- package/dist_ts/storage/classes.storagemanager.js +0 -348
- package/dist_ts/storage/index.d.ts +0 -1
- package/dist_ts/storage/index.js +0 -3
- package/ts/cache/classes.cachedb.ts +0 -155
- package/ts/cache/documents/index.ts +0 -2
- package/ts/storage/classes.storagemanager.ts +0 -404
- package/ts/storage/index.ts +0 -2
- /package/dist_ts/{cache → db}/classes.cached.document.d.ts +0 -0
- /package/dist_ts/{cache → db}/documents/classes.cached.email.d.ts +0 -0
- /package/dist_ts/{cache → db}/documents/classes.cached.ip.reputation.d.ts +0 -0
- /package/ts/{cache → db}/classes.cached.document.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
7
|
+
export class RemoteIngressEdgeDoc extends plugins.smartdata.SmartDataDbDoc<RemoteIngressEdgeDoc, RemoteIngressEdgeDoc> {
|
|
8
|
+
@plugins.smartdata.unI()
|
|
9
|
+
@plugins.smartdata.svDb()
|
|
10
|
+
public id!: string;
|
|
11
|
+
|
|
12
|
+
@plugins.smartdata.svDb()
|
|
13
|
+
public name: string = '';
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.svDb()
|
|
16
|
+
public secret!: string;
|
|
17
|
+
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public listenPorts!: number[];
|
|
20
|
+
|
|
21
|
+
@plugins.smartdata.svDb()
|
|
22
|
+
public listenPortsUdp!: number[];
|
|
23
|
+
|
|
24
|
+
@plugins.smartdata.svDb()
|
|
25
|
+
public enabled!: boolean;
|
|
26
|
+
|
|
27
|
+
@plugins.smartdata.svDb()
|
|
28
|
+
public autoDerivePorts!: boolean;
|
|
29
|
+
|
|
30
|
+
@plugins.smartdata.svDb()
|
|
31
|
+
public tags!: string[];
|
|
32
|
+
|
|
33
|
+
@plugins.smartdata.svDb()
|
|
34
|
+
public createdAt!: number;
|
|
35
|
+
|
|
36
|
+
@plugins.smartdata.svDb()
|
|
37
|
+
public updatedAt!: number;
|
|
38
|
+
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static async findById(id: string): Promise<RemoteIngressEdgeDoc | null> {
|
|
44
|
+
return await RemoteIngressEdgeDoc.getInstance({ id });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static async findAll(): Promise<RemoteIngressEdgeDoc[]> {
|
|
48
|
+
return await RemoteIngressEdgeDoc.getInstances({});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public static async findEnabled(): Promise<RemoteIngressEdgeDoc[]> {
|
|
52
|
+
return await RemoteIngressEdgeDoc.getInstances({ enabled: true });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
7
|
+
export class RouteOverrideDoc extends plugins.smartdata.SmartDataDbDoc<RouteOverrideDoc, RouteOverrideDoc> {
|
|
8
|
+
@plugins.smartdata.unI()
|
|
9
|
+
@plugins.smartdata.svDb()
|
|
10
|
+
public routeName!: string;
|
|
11
|
+
|
|
12
|
+
@plugins.smartdata.svDb()
|
|
13
|
+
public enabled!: boolean;
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.svDb()
|
|
16
|
+
public updatedAt!: number;
|
|
17
|
+
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public updatedBy!: string;
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public static async findByRouteName(routeName: string): Promise<RouteOverrideDoc | null> {
|
|
26
|
+
return await RouteOverrideDoc.getInstance({ routeName });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static async findAll(): Promise<RouteOverrideDoc[]> {
|
|
30
|
+
return await RouteOverrideDoc.getInstances({});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
7
|
+
export class StoredRouteDoc extends plugins.smartdata.SmartDataDbDoc<StoredRouteDoc, StoredRouteDoc> {
|
|
8
|
+
@plugins.smartdata.unI()
|
|
9
|
+
@plugins.smartdata.svDb()
|
|
10
|
+
public id!: string;
|
|
11
|
+
|
|
12
|
+
@plugins.smartdata.svDb()
|
|
13
|
+
public route!: plugins.smartproxy.IRouteConfig;
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.svDb()
|
|
16
|
+
public enabled!: boolean;
|
|
17
|
+
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public createdAt!: number;
|
|
20
|
+
|
|
21
|
+
@plugins.smartdata.svDb()
|
|
22
|
+
public updatedAt!: number;
|
|
23
|
+
|
|
24
|
+
@plugins.smartdata.svDb()
|
|
25
|
+
public createdBy!: string;
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public static async findById(id: string): Promise<StoredRouteDoc | null> {
|
|
32
|
+
return await StoredRouteDoc.getInstance({ id });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static async findAll(): Promise<StoredRouteDoc[]> {
|
|
36
|
+
return await StoredRouteDoc.getInstances({});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
export interface IMacVlanMapping {
|
|
7
|
+
mac: string;
|
|
8
|
+
vlan: number;
|
|
9
|
+
description?: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
16
|
+
export class VlanMappingsDoc extends plugins.smartdata.SmartDataDbDoc<VlanMappingsDoc, VlanMappingsDoc> {
|
|
17
|
+
@plugins.smartdata.unI()
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public configId: string = 'vlan-mappings';
|
|
20
|
+
|
|
21
|
+
@plugins.smartdata.svDb()
|
|
22
|
+
public mappings!: IMacVlanMapping[];
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.mappings = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static async load(): Promise<VlanMappingsDoc | null> {
|
|
30
|
+
return await VlanMappingsDoc.getInstance({ configId: 'vlan-mappings' });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
7
|
+
export class VpnClientDoc extends plugins.smartdata.SmartDataDbDoc<VpnClientDoc, VpnClientDoc> {
|
|
8
|
+
@plugins.smartdata.unI()
|
|
9
|
+
@plugins.smartdata.svDb()
|
|
10
|
+
public clientId!: string;
|
|
11
|
+
|
|
12
|
+
@plugins.smartdata.svDb()
|
|
13
|
+
public enabled!: boolean;
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.svDb()
|
|
16
|
+
public serverDefinedClientTags?: string[];
|
|
17
|
+
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public description?: string;
|
|
20
|
+
|
|
21
|
+
@plugins.smartdata.svDb()
|
|
22
|
+
public assignedIp?: string;
|
|
23
|
+
|
|
24
|
+
@plugins.smartdata.svDb()
|
|
25
|
+
public noisePublicKey!: string;
|
|
26
|
+
|
|
27
|
+
@plugins.smartdata.svDb()
|
|
28
|
+
public wgPublicKey!: string;
|
|
29
|
+
|
|
30
|
+
@plugins.smartdata.svDb()
|
|
31
|
+
public wgPrivateKey?: string;
|
|
32
|
+
|
|
33
|
+
@plugins.smartdata.svDb()
|
|
34
|
+
public createdAt!: number;
|
|
35
|
+
|
|
36
|
+
@plugins.smartdata.svDb()
|
|
37
|
+
public updatedAt!: number;
|
|
38
|
+
|
|
39
|
+
@plugins.smartdata.svDb()
|
|
40
|
+
public expiresAt?: string;
|
|
41
|
+
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public static async findByClientId(clientId: string): Promise<VpnClientDoc | null> {
|
|
47
|
+
return await VpnClientDoc.getInstance({ clientId });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public static async findAll(): Promise<VpnClientDoc[]> {
|
|
51
|
+
return await VpnClientDoc.getInstances({});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static async findEnabled(): Promise<VpnClientDoc[]> {
|
|
55
|
+
return await VpnClientDoc.getInstances({ enabled: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as plugins from '../../plugins.js';
|
|
2
|
+
import { DcRouterDb } from '../classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
const getDb = () => DcRouterDb.getInstance().getDb();
|
|
5
|
+
|
|
6
|
+
@plugins.smartdata.Collection(() => getDb())
|
|
7
|
+
export class VpnServerKeysDoc extends plugins.smartdata.SmartDataDbDoc<VpnServerKeysDoc, VpnServerKeysDoc> {
|
|
8
|
+
@plugins.smartdata.unI()
|
|
9
|
+
@plugins.smartdata.svDb()
|
|
10
|
+
public configId: string = 'vpn-server-keys';
|
|
11
|
+
|
|
12
|
+
@plugins.smartdata.svDb()
|
|
13
|
+
public noisePrivateKey!: string;
|
|
14
|
+
|
|
15
|
+
@plugins.smartdata.svDb()
|
|
16
|
+
public noisePublicKey!: string;
|
|
17
|
+
|
|
18
|
+
@plugins.smartdata.svDb()
|
|
19
|
+
public wgPrivateKey!: string;
|
|
20
|
+
|
|
21
|
+
@plugins.smartdata.svDb()
|
|
22
|
+
public wgPublicKey!: string;
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static async load(): Promise<VpnServerKeysDoc | null> {
|
|
29
|
+
return await VpnServerKeysDoc.getInstance({ configId: 'vpn-server-keys' });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Cached/TTL document classes
|
|
2
|
+
export * from './classes.cached.email.js';
|
|
3
|
+
export * from './classes.cached.ip.reputation.js';
|
|
4
|
+
|
|
5
|
+
// Config document classes
|
|
6
|
+
export * from './classes.stored-route.doc.js';
|
|
7
|
+
export * from './classes.route-override.doc.js';
|
|
8
|
+
export * from './classes.api-token.doc.js';
|
|
9
|
+
|
|
10
|
+
// VPN document classes
|
|
11
|
+
export * from './classes.vpn-server-keys.doc.js';
|
|
12
|
+
export * from './classes.vpn-client.doc.js';
|
|
13
|
+
|
|
14
|
+
// Certificate document classes
|
|
15
|
+
export * from './classes.acme-cert.doc.js';
|
|
16
|
+
export * from './classes.proxy-cert.doc.js';
|
|
17
|
+
export * from './classes.cert-backoff.doc.js';
|
|
18
|
+
|
|
19
|
+
// Remote ingress document classes
|
|
20
|
+
export * from './classes.remote-ingress-edge.doc.js';
|
|
21
|
+
|
|
22
|
+
// RADIUS document classes
|
|
23
|
+
export * from './classes.vlan-mappings.doc.js';
|
|
24
|
+
export * from './classes.accounting-session.doc.js';
|
package/ts/{cache → db}/index.ts
RENAMED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
export * from './classes.
|
|
1
|
+
// Unified database manager
|
|
2
|
+
export * from './classes.dcrouter-db.js';
|
|
3
|
+
|
|
4
|
+
// TTL base class and constants
|
|
3
5
|
export * from './classes.cached.document.js';
|
|
6
|
+
|
|
7
|
+
// Cache cleaner
|
|
4
8
|
export * from './classes.cache.cleaner.js';
|
|
5
9
|
|
|
6
10
|
// Document classes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as plugins from '../../plugins.js';
|
|
2
2
|
import type { OpsServer } from '../classes.opsserver.js';
|
|
3
3
|
import * as interfaces from '../../../ts_interfaces/index.js';
|
|
4
|
+
import { AcmeCertDoc, ProxyCertDoc } from '../../db/index.js';
|
|
4
5
|
|
|
5
6
|
export class CertificateHandler {
|
|
6
7
|
constructor(private opsServerRef: OpsServer) {
|
|
@@ -187,30 +188,28 @@ export class CertificateHandler {
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
|
|
190
|
-
// Check persisted cert data from
|
|
191
|
+
// Check persisted cert data from smartdata document classes
|
|
191
192
|
if (status === 'unknown') {
|
|
192
193
|
const cleanDomain = domain.replace(/^\*\.?/, '');
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (certData.created) {
|
|
201
|
-
issuedAt = new Date(certData.created).toISOString();
|
|
194
|
+
const acmeDoc = await AcmeCertDoc.findByDomain(cleanDomain);
|
|
195
|
+
const proxyDoc = !acmeDoc ? await ProxyCertDoc.findByDomain(domain) : null;
|
|
196
|
+
|
|
197
|
+
if (acmeDoc?.validUntil) {
|
|
198
|
+
expiryDate = new Date(acmeDoc.validUntil).toISOString();
|
|
199
|
+
if (acmeDoc.created) {
|
|
200
|
+
issuedAt = new Date(acmeDoc.created).toISOString();
|
|
202
201
|
}
|
|
203
202
|
issuer = 'smartacme-dns-01';
|
|
204
|
-
} else if (
|
|
203
|
+
} else if (proxyDoc?.publicKey) {
|
|
205
204
|
// certStore has the cert — parse PEM for expiry
|
|
206
205
|
try {
|
|
207
|
-
const x509 = new plugins.crypto.X509Certificate(
|
|
206
|
+
const x509 = new plugins.crypto.X509Certificate(proxyDoc.publicKey);
|
|
208
207
|
expiryDate = new Date(x509.validTo).toISOString();
|
|
209
208
|
issuedAt = new Date(x509.validFrom).toISOString();
|
|
210
209
|
} catch { /* PEM parsing failed */ }
|
|
211
210
|
status = 'valid';
|
|
212
211
|
issuer = 'cert-store';
|
|
213
|
-
} else if (
|
|
212
|
+
} else if (acmeDoc || proxyDoc) {
|
|
214
213
|
status = 'valid';
|
|
215
214
|
issuer = 'cert-store';
|
|
216
215
|
}
|
|
@@ -366,18 +365,17 @@ export class CertificateHandler {
|
|
|
366
365
|
const dcRouter = this.opsServerRef.dcRouterRef;
|
|
367
366
|
const cleanDomain = domain.replace(/^\*\.?/, '');
|
|
368
367
|
|
|
369
|
-
// Delete from
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
];
|
|
368
|
+
// Delete from smartdata document classes
|
|
369
|
+
const acmeDoc = await AcmeCertDoc.findByDomain(cleanDomain);
|
|
370
|
+
if (acmeDoc) {
|
|
371
|
+
await acmeDoc.delete();
|
|
372
|
+
}
|
|
375
373
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
374
|
+
// Try both original domain and clean domain for proxy certs
|
|
375
|
+
for (const d of [domain, cleanDomain]) {
|
|
376
|
+
const proxyDoc = await ProxyCertDoc.findByDomain(d);
|
|
377
|
+
if (proxyDoc) {
|
|
378
|
+
await proxyDoc.delete();
|
|
381
379
|
}
|
|
382
380
|
}
|
|
383
381
|
|
|
@@ -408,43 +406,41 @@ export class CertificateHandler {
|
|
|
408
406
|
};
|
|
409
407
|
message?: string;
|
|
410
408
|
}> {
|
|
411
|
-
const dcRouter = this.opsServerRef.dcRouterRef;
|
|
412
409
|
const cleanDomain = domain.replace(/^\*\.?/, '');
|
|
413
410
|
|
|
414
|
-
// Try
|
|
415
|
-
|
|
416
|
-
if (
|
|
411
|
+
// Try AcmeCertDoc first (has full ICert fields)
|
|
412
|
+
const acmeDoc = await AcmeCertDoc.findByDomain(cleanDomain);
|
|
413
|
+
if (acmeDoc && acmeDoc.publicKey && acmeDoc.privateKey) {
|
|
417
414
|
return {
|
|
418
415
|
success: true,
|
|
419
416
|
cert: {
|
|
420
|
-
id:
|
|
421
|
-
domainName:
|
|
422
|
-
created:
|
|
423
|
-
validUntil:
|
|
424
|
-
privateKey:
|
|
425
|
-
publicKey:
|
|
426
|
-
csr:
|
|
417
|
+
id: acmeDoc.id || plugins.crypto.randomUUID(),
|
|
418
|
+
domainName: acmeDoc.domainName || domain,
|
|
419
|
+
created: acmeDoc.created || Date.now(),
|
|
420
|
+
validUntil: acmeDoc.validUntil || 0,
|
|
421
|
+
privateKey: acmeDoc.privateKey,
|
|
422
|
+
publicKey: acmeDoc.publicKey,
|
|
423
|
+
csr: acmeDoc.csr || '',
|
|
427
424
|
},
|
|
428
425
|
};
|
|
429
426
|
}
|
|
430
427
|
|
|
431
|
-
// Fallback: try
|
|
432
|
-
|
|
433
|
-
if (!
|
|
434
|
-
|
|
435
|
-
certData = await dcRouter.storageManager.getJSON(`/proxy-certs/${cleanDomain}`);
|
|
428
|
+
// Fallback: try ProxyCertDoc with original domain, then clean domain
|
|
429
|
+
let proxyDoc = await ProxyCertDoc.findByDomain(domain);
|
|
430
|
+
if (!proxyDoc || !proxyDoc.publicKey) {
|
|
431
|
+
proxyDoc = await ProxyCertDoc.findByDomain(cleanDomain);
|
|
436
432
|
}
|
|
437
433
|
|
|
438
|
-
if (
|
|
434
|
+
if (proxyDoc && proxyDoc.publicKey && proxyDoc.privateKey) {
|
|
439
435
|
return {
|
|
440
436
|
success: true,
|
|
441
437
|
cert: {
|
|
442
438
|
id: plugins.crypto.randomUUID(),
|
|
443
439
|
domainName: domain,
|
|
444
|
-
created:
|
|
445
|
-
validUntil:
|
|
446
|
-
privateKey:
|
|
447
|
-
publicKey:
|
|
440
|
+
created: proxyDoc.validFrom || Date.now(),
|
|
441
|
+
validUntil: proxyDoc.validUntil || 0,
|
|
442
|
+
privateKey: proxyDoc.privateKey,
|
|
443
|
+
publicKey: proxyDoc.publicKey,
|
|
448
444
|
csr: '',
|
|
449
445
|
},
|
|
450
446
|
};
|
|
@@ -476,26 +472,32 @@ export class CertificateHandler {
|
|
|
476
472
|
const dcRouter = this.opsServerRef.dcRouterRef;
|
|
477
473
|
const cleanDomain = cert.domainName.replace(/^\*\.?/, '');
|
|
478
474
|
|
|
479
|
-
// Save to
|
|
480
|
-
await
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
await
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
475
|
+
// Save to AcmeCertDoc (SmartAcme-compatible)
|
|
476
|
+
let acmeDoc = await AcmeCertDoc.findByDomain(cleanDomain);
|
|
477
|
+
if (!acmeDoc) {
|
|
478
|
+
acmeDoc = new AcmeCertDoc();
|
|
479
|
+
acmeDoc.domainName = cleanDomain;
|
|
480
|
+
}
|
|
481
|
+
acmeDoc.id = cert.id;
|
|
482
|
+
acmeDoc.created = cert.created;
|
|
483
|
+
acmeDoc.validUntil = cert.validUntil;
|
|
484
|
+
acmeDoc.privateKey = cert.privateKey;
|
|
485
|
+
acmeDoc.publicKey = cert.publicKey;
|
|
486
|
+
acmeDoc.csr = cert.csr || '';
|
|
487
|
+
await acmeDoc.save();
|
|
488
|
+
|
|
489
|
+
// Also save to ProxyCertDoc (proxy-cert format)
|
|
490
|
+
let proxyDoc = await ProxyCertDoc.findByDomain(cert.domainName);
|
|
491
|
+
if (!proxyDoc) {
|
|
492
|
+
proxyDoc = new ProxyCertDoc();
|
|
493
|
+
proxyDoc.domain = cert.domainName;
|
|
494
|
+
}
|
|
495
|
+
proxyDoc.publicKey = cert.publicKey;
|
|
496
|
+
proxyDoc.privateKey = cert.privateKey;
|
|
497
|
+
proxyDoc.ca = '';
|
|
498
|
+
proxyDoc.validUntil = cert.validUntil;
|
|
499
|
+
proxyDoc.validFrom = cert.created;
|
|
500
|
+
await proxyDoc.save();
|
|
499
501
|
|
|
500
502
|
// Update in-memory status map
|
|
501
503
|
dcRouter.certificateStatusMap.set(cert.domainName, {
|
|
@@ -33,11 +33,9 @@ export class ConfigHandler {
|
|
|
33
33
|
const resolvedPaths = dcRouter.resolvedPaths;
|
|
34
34
|
|
|
35
35
|
// --- System ---
|
|
36
|
-
const storageBackend: 'filesystem' | 'custom' | 'memory' = opts.
|
|
36
|
+
const storageBackend: 'filesystem' | 'custom' | 'memory' = opts.dbConfig?.mongoDbUrl
|
|
37
37
|
? 'custom'
|
|
38
|
-
:
|
|
39
|
-
? 'filesystem'
|
|
40
|
-
: 'memory';
|
|
38
|
+
: 'filesystem';
|
|
41
39
|
|
|
42
40
|
// Resolve proxy IPs: fall back to SmartProxy's runtime proxyIPs if not in opts
|
|
43
41
|
let proxyIps = opts.proxyIps || [];
|
|
@@ -55,7 +53,7 @@ export class ConfigHandler {
|
|
|
55
53
|
proxyIps,
|
|
56
54
|
uptime: Math.floor(process.uptime()),
|
|
57
55
|
storageBackend,
|
|
58
|
-
storagePath: opts.
|
|
56
|
+
storagePath: opts.dbConfig?.storagePath || resolvedPaths.defaultTsmDbPath,
|
|
59
57
|
};
|
|
60
58
|
|
|
61
59
|
// --- SmartProxy ---
|
|
@@ -151,15 +149,15 @@ export class ConfigHandler {
|
|
|
151
149
|
keyPath: opts.tls?.keyPath || null,
|
|
152
150
|
};
|
|
153
151
|
|
|
154
|
-
// ---
|
|
155
|
-
const
|
|
152
|
+
// --- Database ---
|
|
153
|
+
const dbConfig = opts.dbConfig;
|
|
156
154
|
const cache: interfaces.requests.IConfigData['cache'] = {
|
|
157
|
-
enabled:
|
|
158
|
-
storagePath:
|
|
159
|
-
dbName:
|
|
160
|
-
defaultTTLDays:
|
|
161
|
-
cleanupIntervalHours:
|
|
162
|
-
ttlConfig:
|
|
155
|
+
enabled: dbConfig?.enabled !== false,
|
|
156
|
+
storagePath: dbConfig?.storagePath || resolvedPaths.defaultTsmDbPath,
|
|
157
|
+
dbName: dbConfig?.dbName || 'dcrouter',
|
|
158
|
+
defaultTTLDays: 30,
|
|
159
|
+
cleanupIntervalHours: dbConfig?.cleanupIntervalHours || 1,
|
|
160
|
+
ttlConfig: {},
|
|
163
161
|
};
|
|
164
162
|
|
|
165
163
|
// --- RADIUS ---
|
|
@@ -185,7 +183,8 @@ export class ConfigHandler {
|
|
|
185
183
|
tlsMode = 'custom';
|
|
186
184
|
} else if (riCfg?.hubDomain) {
|
|
187
185
|
try {
|
|
188
|
-
const
|
|
186
|
+
const { ProxyCertDoc } = await import('../../db/index.js');
|
|
187
|
+
const stored = await ProxyCertDoc.findByDomain(riCfg.hubDomain);
|
|
189
188
|
if (stored?.publicKey && stored?.privateKey) {
|
|
190
189
|
tlsMode = 'acme';
|
|
191
190
|
}
|
package/ts/paths.ts
CHANGED
|
@@ -34,7 +34,6 @@ export function resolvePaths(baseDir?: string) {
|
|
|
34
34
|
dcrouterHomeDir: root,
|
|
35
35
|
dataDir: resolvedDataDir,
|
|
36
36
|
defaultTsmDbPath: plugins.path.join(root, 'tsmdb'),
|
|
37
|
-
defaultStoragePath: plugins.path.join(root, 'storage'),
|
|
38
37
|
dnsRecordsDir: plugins.path.join(resolvedDataDir, 'dns'),
|
|
39
38
|
};
|
|
40
39
|
}
|