@serve.zone/dcrouter 11.12.4 → 11.14.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.
Files changed (214) hide show
  1. package/dist_serve/bundle.js +705 -548
  2. package/dist_ts_interfaces/data/index.d.ts +1 -0
  3. package/dist_ts_interfaces/data/index.js +2 -1
  4. package/dist_ts_interfaces/data/remoteingress.d.ts +10 -1
  5. package/dist_ts_interfaces/data/vpn.d.ts +43 -0
  6. package/dist_ts_interfaces/data/vpn.js +2 -0
  7. package/dist_ts_interfaces/requests/index.d.ts +1 -0
  8. package/dist_ts_interfaces/requests/index.js +2 -1
  9. package/dist_ts_interfaces/requests/vpn.d.ts +135 -0
  10. package/dist_ts_interfaces/requests/vpn.js +3 -0
  11. package/package.json +2 -1
  12. package/readme.md +107 -3
  13. package/ts/00_commitinfo_data.ts +1 -1
  14. package/ts/classes.dcrouter.ts +126 -0
  15. package/ts/config/classes.route-config-manager.ts +20 -3
  16. package/ts/opsserver/classes.opsserver.ts +2 -0
  17. package/ts/opsserver/handlers/index.ts +2 -1
  18. package/ts/opsserver/handlers/vpn.handler.ts +257 -0
  19. package/ts/plugins.ts +2 -1
  20. package/ts/vpn/classes.vpn-manager.ts +378 -0
  21. package/ts/vpn/index.ts +1 -0
  22. package/ts_web/00_commitinfo_data.ts +1 -1
  23. package/ts_web/appstate.ts +164 -0
  24. package/ts_web/elements/index.ts +1 -0
  25. package/ts_web/elements/ops-dashboard.ts +6 -0
  26. package/ts_web/elements/ops-view-vpn.ts +330 -0
  27. package/ts_web/readme.md +17 -0
  28. package/ts_web/router.ts +1 -1
  29. package/dist_ts/00_commitinfo_data.d.ts +0 -8
  30. package/dist_ts/00_commitinfo_data.js +0 -9
  31. package/dist_ts/cache/classes.cache.cleaner.d.ts +0 -47
  32. package/dist_ts/cache/classes.cache.cleaner.js +0 -130
  33. package/dist_ts/cache/classes.cached.document.d.ts +0 -76
  34. package/dist_ts/cache/classes.cached.document.js +0 -100
  35. package/dist_ts/cache/classes.cachedb.d.ts +0 -60
  36. package/dist_ts/cache/classes.cachedb.js +0 -126
  37. package/dist_ts/cache/documents/classes.cached.email.d.ts +0 -125
  38. package/dist_ts/cache/documents/classes.cached.email.js +0 -337
  39. package/dist_ts/cache/documents/classes.cached.ip.reputation.d.ts +0 -119
  40. package/dist_ts/cache/documents/classes.cached.ip.reputation.js +0 -323
  41. package/dist_ts/cache/documents/index.d.ts +0 -2
  42. package/dist_ts/cache/documents/index.js +0 -3
  43. package/dist_ts/cache/index.d.ts +0 -4
  44. package/dist_ts/cache/index.js +0 -7
  45. package/dist_ts/classes.cert-provision-scheduler.d.ts +0 -54
  46. package/dist_ts/classes.cert-provision-scheduler.js +0 -118
  47. package/dist_ts/classes.dcrouter.d.ts +0 -356
  48. package/dist_ts/classes.dcrouter.js +0 -1592
  49. package/dist_ts/classes.storage-cert-manager.d.ts +0 -18
  50. package/dist_ts/classes.storage-cert-manager.js +0 -43
  51. package/dist_ts/config/classes.api-token-manager.d.ts +0 -46
  52. package/dist_ts/config/classes.api-token-manager.js +0 -150
  53. package/dist_ts/config/classes.route-config-manager.d.ts +0 -37
  54. package/dist_ts/config/classes.route-config-manager.js +0 -240
  55. package/dist_ts/config/index.d.ts +0 -3
  56. package/dist_ts/config/index.js +0 -5
  57. package/dist_ts/config/validator.d.ts +0 -104
  58. package/dist_ts/config/validator.js +0 -152
  59. package/dist_ts/errors/base.errors.d.ts +0 -224
  60. package/dist_ts/errors/base.errors.js +0 -320
  61. package/dist_ts/errors/error-handler.d.ts +0 -98
  62. package/dist_ts/errors/error-handler.js +0 -282
  63. package/dist_ts/errors/error.codes.d.ts +0 -115
  64. package/dist_ts/errors/error.codes.js +0 -136
  65. package/dist_ts/errors/index.d.ts +0 -54
  66. package/dist_ts/errors/index.js +0 -136
  67. package/dist_ts/errors/reputation.errors.d.ts +0 -183
  68. package/dist_ts/errors/reputation.errors.js +0 -292
  69. package/dist_ts/http3/http3-route-augmentation.d.ts +0 -50
  70. package/dist_ts/http3/http3-route-augmentation.js +0 -98
  71. package/dist_ts/http3/index.d.ts +0 -1
  72. package/dist_ts/http3/index.js +0 -2
  73. package/dist_ts/index.d.ts +0 -8
  74. package/dist_ts/index.js +0 -29
  75. package/dist_ts/logger.d.ts +0 -21
  76. package/dist_ts/logger.js +0 -81
  77. package/dist_ts/monitoring/classes.metricscache.d.ts +0 -32
  78. package/dist_ts/monitoring/classes.metricscache.js +0 -63
  79. package/dist_ts/monitoring/classes.metricsmanager.d.ts +0 -184
  80. package/dist_ts/monitoring/classes.metricsmanager.js +0 -744
  81. package/dist_ts/monitoring/index.d.ts +0 -1
  82. package/dist_ts/monitoring/index.js +0 -2
  83. package/dist_ts/opsserver/classes.opsserver.d.ts +0 -37
  84. package/dist_ts/opsserver/classes.opsserver.js +0 -85
  85. package/dist_ts/opsserver/handlers/admin.handler.d.ts +0 -31
  86. package/dist_ts/opsserver/handlers/admin.handler.js +0 -180
  87. package/dist_ts/opsserver/handlers/api-token.handler.d.ts +0 -6
  88. package/dist_ts/opsserver/handlers/api-token.handler.js +0 -62
  89. package/dist_ts/opsserver/handlers/certificate.handler.d.ts +0 -32
  90. package/dist_ts/opsserver/handlers/certificate.handler.js +0 -421
  91. package/dist_ts/opsserver/handlers/config.handler.d.ts +0 -7
  92. package/dist_ts/opsserver/handlers/config.handler.js +0 -192
  93. package/dist_ts/opsserver/handlers/email-ops.handler.d.ts +0 -30
  94. package/dist_ts/opsserver/handlers/email-ops.handler.js +0 -227
  95. package/dist_ts/opsserver/handlers/index.d.ts +0 -11
  96. package/dist_ts/opsserver/handlers/index.js +0 -12
  97. package/dist_ts/opsserver/handlers/logs.handler.d.ts +0 -25
  98. package/dist_ts/opsserver/handlers/logs.handler.js +0 -256
  99. package/dist_ts/opsserver/handlers/radius.handler.d.ts +0 -6
  100. package/dist_ts/opsserver/handlers/radius.handler.js +0 -295
  101. package/dist_ts/opsserver/handlers/remoteingress.handler.d.ts +0 -6
  102. package/dist_ts/opsserver/handlers/remoteingress.handler.js +0 -156
  103. package/dist_ts/opsserver/handlers/route-management.handler.d.ts +0 -14
  104. package/dist_ts/opsserver/handlers/route-management.handler.js +0 -117
  105. package/dist_ts/opsserver/handlers/security.handler.d.ts +0 -9
  106. package/dist_ts/opsserver/handlers/security.handler.js +0 -233
  107. package/dist_ts/opsserver/handlers/stats.handler.d.ts +0 -11
  108. package/dist_ts/opsserver/handlers/stats.handler.js +0 -403
  109. package/dist_ts/opsserver/helpers/guards.d.ts +0 -27
  110. package/dist_ts/opsserver/helpers/guards.js +0 -43
  111. package/dist_ts/opsserver/index.d.ts +0 -1
  112. package/dist_ts/opsserver/index.js +0 -2
  113. package/dist_ts/paths.d.ts +0 -26
  114. package/dist_ts/paths.js +0 -45
  115. package/dist_ts/plugins.d.ts +0 -80
  116. package/dist_ts/plugins.js +0 -114
  117. package/dist_ts/radius/classes.accounting.manager.d.ts +0 -231
  118. package/dist_ts/radius/classes.accounting.manager.js +0 -462
  119. package/dist_ts/radius/classes.radius.server.d.ts +0 -171
  120. package/dist_ts/radius/classes.radius.server.js +0 -386
  121. package/dist_ts/radius/classes.vlan.manager.d.ts +0 -128
  122. package/dist_ts/radius/classes.vlan.manager.js +0 -279
  123. package/dist_ts/radius/index.d.ts +0 -13
  124. package/dist_ts/radius/index.js +0 -14
  125. package/dist_ts/remoteingress/classes.remoteingress-manager.d.ts +0 -94
  126. package/dist_ts/remoteingress/classes.remoteingress-manager.js +0 -271
  127. package/dist_ts/remoteingress/classes.tunnel-manager.d.ts +0 -59
  128. package/dist_ts/remoteingress/classes.tunnel-manager.js +0 -165
  129. package/dist_ts/remoteingress/index.d.ts +0 -2
  130. package/dist_ts/remoteingress/index.js +0 -3
  131. package/dist_ts/security/classes.contentscanner.d.ts +0 -164
  132. package/dist_ts/security/classes.contentscanner.js +0 -642
  133. package/dist_ts/security/classes.ipreputationchecker.d.ts +0 -160
  134. package/dist_ts/security/classes.ipreputationchecker.js +0 -537
  135. package/dist_ts/security/classes.securitylogger.d.ts +0 -144
  136. package/dist_ts/security/classes.securitylogger.js +0 -235
  137. package/dist_ts/security/index.d.ts +0 -3
  138. package/dist_ts/security/index.js +0 -4
  139. package/dist_ts/sms/classes.smsservice.d.ts +0 -15
  140. package/dist_ts/sms/classes.smsservice.js +0 -72
  141. package/dist_ts/sms/config/sms.config.d.ts +0 -93
  142. package/dist_ts/sms/config/sms.config.js +0 -2
  143. package/dist_ts/sms/config/sms.schema.d.ts +0 -5
  144. package/dist_ts/sms/config/sms.schema.js +0 -121
  145. package/dist_ts/sms/index.d.ts +0 -1
  146. package/dist_ts/sms/index.js +0 -2
  147. package/dist_ts/storage/classes.storagemanager.d.ts +0 -83
  148. package/dist_ts/storage/classes.storagemanager.js +0 -348
  149. package/dist_ts/storage/index.d.ts +0 -1
  150. package/dist_ts/storage/index.js +0 -3
  151. package/dist_ts_apiclient/classes.apitoken.d.ts +0 -41
  152. package/dist_ts_apiclient/classes.apitoken.js +0 -115
  153. package/dist_ts_apiclient/classes.certificate.d.ts +0 -57
  154. package/dist_ts_apiclient/classes.certificate.js +0 -69
  155. package/dist_ts_apiclient/classes.config.d.ts +0 -7
  156. package/dist_ts_apiclient/classes.config.js +0 -11
  157. package/dist_ts_apiclient/classes.dcrouterapiclient.d.ts +0 -41
  158. package/dist_ts_apiclient/classes.dcrouterapiclient.js +0 -81
  159. package/dist_ts_apiclient/classes.email.d.ts +0 -30
  160. package/dist_ts_apiclient/classes.email.js +0 -52
  161. package/dist_ts_apiclient/classes.logs.d.ts +0 -21
  162. package/dist_ts_apiclient/classes.logs.js +0 -14
  163. package/dist_ts_apiclient/classes.radius.d.ts +0 -59
  164. package/dist_ts_apiclient/classes.radius.js +0 -95
  165. package/dist_ts_apiclient/classes.remoteingress.d.ts +0 -54
  166. package/dist_ts_apiclient/classes.remoteingress.js +0 -136
  167. package/dist_ts_apiclient/classes.route.d.ts +0 -42
  168. package/dist_ts_apiclient/classes.route.js +0 -154
  169. package/dist_ts_apiclient/classes.stats.d.ts +0 -47
  170. package/dist_ts_apiclient/classes.stats.js +0 -38
  171. package/dist_ts_apiclient/index.d.ts +0 -10
  172. package/dist_ts_apiclient/index.js +0 -14
  173. package/dist_ts_apiclient/plugins.d.ts +0 -3
  174. package/dist_ts_apiclient/plugins.js +0 -5
  175. package/dist_ts_web/00_commitinfo_data.d.ts +0 -8
  176. package/dist_ts_web/00_commitinfo_data.js +0 -9
  177. package/dist_ts_web/appstate.d.ts +0 -216
  178. package/dist_ts_web/appstate.js +0 -1064
  179. package/dist_ts_web/elements/index.d.ts +0 -12
  180. package/dist_ts_web/elements/index.js +0 -13
  181. package/dist_ts_web/elements/ops-dashboard.d.ts +0 -23
  182. package/dist_ts_web/elements/ops-dashboard.js +0 -317
  183. package/dist_ts_web/elements/ops-view-apitokens.d.ts +0 -13
  184. package/dist_ts_web/elements/ops-view-apitokens.js +0 -371
  185. package/dist_ts_web/elements/ops-view-certificates.d.ts +0 -22
  186. package/dist_ts_web/elements/ops-view-certificates.js +0 -528
  187. package/dist_ts_web/elements/ops-view-config.d.ts +0 -19
  188. package/dist_ts_web/elements/ops-view-config.js +0 -339
  189. package/dist_ts_web/elements/ops-view-emails.d.ts +0 -21
  190. package/dist_ts_web/elements/ops-view-emails.js +0 -165
  191. package/dist_ts_web/elements/ops-view-logs.d.ts +0 -13
  192. package/dist_ts_web/elements/ops-view-logs.js +0 -159
  193. package/dist_ts_web/elements/ops-view-network.d.ts +0 -71
  194. package/dist_ts_web/elements/ops-view-network.js +0 -764
  195. package/dist_ts_web/elements/ops-view-overview.d.ts +0 -22
  196. package/dist_ts_web/elements/ops-view-overview.js +0 -456
  197. package/dist_ts_web/elements/ops-view-remoteingress.d.ts +0 -20
  198. package/dist_ts_web/elements/ops-view-remoteingress.js +0 -494
  199. package/dist_ts_web/elements/ops-view-routes.d.ts +0 -12
  200. package/dist_ts_web/elements/ops-view-routes.js +0 -404
  201. package/dist_ts_web/elements/ops-view-security.d.ts +0 -21
  202. package/dist_ts_web/elements/ops-view-security.js +0 -574
  203. package/dist_ts_web/elements/shared/css.d.ts +0 -1
  204. package/dist_ts_web/elements/shared/css.js +0 -10
  205. package/dist_ts_web/elements/shared/index.d.ts +0 -2
  206. package/dist_ts_web/elements/shared/index.js +0 -3
  207. package/dist_ts_web/elements/shared/ops-sectionheading.d.ts +0 -5
  208. package/dist_ts_web/elements/shared/ops-sectionheading.js +0 -82
  209. package/dist_ts_web/index.d.ts +0 -1
  210. package/dist_ts_web/index.js +0 -10
  211. package/dist_ts_web/plugins.d.ts +0 -6
  212. package/dist_ts_web/plugins.js +0 -11
  213. package/dist_ts_web/router.d.ts +0 -19
  214. package/dist_ts_web/router.js +0 -91
@@ -2,3 +2,4 @@ export * from './auth.js';
2
2
  export * from './stats.js';
3
3
  export * from './remoteingress.js';
4
4
  export * from './route-management.js';
5
+ export * from './vpn.js';
@@ -2,4 +2,5 @@ export * from './auth.js';
2
2
  export * from './stats.js';
3
3
  export * from './remoteingress.js';
4
4
  export * from './route-management.js';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19pbnRlcmZhY2VzL2RhdGEvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLHVCQUF1QixDQUFDIn0=
5
+ export * from './vpn.js';
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19pbnRlcmZhY2VzL2RhdGEvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsVUFBVSxDQUFDIn0=
@@ -47,11 +47,20 @@ export interface IRouteRemoteIngress {
47
47
  * When absent, the route applies to all edges. */
48
48
  edgeFilter?: string[];
49
49
  }
50
+ /**
51
+ * Route-level VPN access configuration.
52
+ * When attached to a route, restricts access to VPN clients only.
53
+ */
54
+ export interface IRouteVpn {
55
+ /** Whether this route requires VPN access */
56
+ required: boolean;
57
+ }
50
58
  /**
51
59
  * Extended route config used within dcrouter.
52
- * Adds the optional `remoteIngress` property to SmartProxy's IRouteConfig.
60
+ * Adds optional `remoteIngress` and `vpn` properties to SmartProxy's IRouteConfig.
53
61
  * SmartProxy ignores unknown properties at runtime.
54
62
  */
55
63
  export type IDcRouterRouteConfig = IRouteConfig & {
56
64
  remoteIngress?: IRouteRemoteIngress;
65
+ vpn?: IRouteVpn;
57
66
  };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A registered VPN client (secrets excluded from API responses).
3
+ */
4
+ export interface IVpnClient {
5
+ clientId: string;
6
+ enabled: boolean;
7
+ tags?: string[];
8
+ description?: string;
9
+ assignedIp?: string;
10
+ createdAt: number;
11
+ updatedAt: number;
12
+ expiresAt?: string;
13
+ }
14
+ /**
15
+ * VPN server status.
16
+ */
17
+ export interface IVpnServerStatus {
18
+ running: boolean;
19
+ forwardingMode: 'tun' | 'socket';
20
+ subnet: string;
21
+ wgListenPort: number;
22
+ serverPublicKeys: {
23
+ noisePublicKey: string;
24
+ wgPublicKey: string;
25
+ } | null;
26
+ registeredClients: number;
27
+ connectedClients: number;
28
+ }
29
+ /**
30
+ * VPN client telemetry data.
31
+ */
32
+ export interface IVpnClientTelemetry {
33
+ clientId: string;
34
+ assignedIp: string;
35
+ bytesSent: number;
36
+ bytesReceived: number;
37
+ packetsDropped: number;
38
+ bytesDropped: number;
39
+ lastKeepaliveAt?: string;
40
+ keepalivesReceived: number;
41
+ rateLimitBytesPerSec?: number;
42
+ burstBytes?: number;
43
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidnBuLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHNfaW50ZXJmYWNlcy9kYXRhL3Zwbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -9,3 +9,4 @@ export * from './certificate.js';
9
9
  export * from './remoteingress.js';
10
10
  export * from './route-management.js';
11
11
  export * from './api-tokens.js';
12
+ export * from './vpn.js';
@@ -9,4 +9,5 @@ export * from './certificate.js';
9
9
  export * from './remoteingress.js';
10
10
  export * from './route-management.js';
11
11
  export * from './api-tokens.js';
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19pbnRlcmZhY2VzL3JlcXVlc3RzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLGlCQUFpQixDQUFDIn0=
12
+ export * from './vpn.js';
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c19pbnRlcmZhY2VzL3JlcXVlc3RzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsVUFBVSxDQUFDIn0=
@@ -0,0 +1,135 @@
1
+ import * as plugins from '../plugins.js';
2
+ import * as authInterfaces from '../data/auth.js';
3
+ import type { IVpnClient, IVpnServerStatus, IVpnClientTelemetry } from '../data/vpn.js';
4
+ /**
5
+ * Get all registered VPN clients.
6
+ */
7
+ export interface IReq_GetVpnClients extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_GetVpnClients> {
8
+ method: 'getVpnClients';
9
+ request: {
10
+ identity: authInterfaces.IIdentity;
11
+ };
12
+ response: {
13
+ clients: IVpnClient[];
14
+ };
15
+ }
16
+ /**
17
+ * Get VPN server status.
18
+ */
19
+ export interface IReq_GetVpnStatus extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_GetVpnStatus> {
20
+ method: 'getVpnStatus';
21
+ request: {
22
+ identity: authInterfaces.IIdentity;
23
+ };
24
+ response: {
25
+ status: IVpnServerStatus;
26
+ };
27
+ }
28
+ /**
29
+ * Create a new VPN client. Returns the config bundle (secrets only shown once).
30
+ */
31
+ export interface IReq_CreateVpnClient extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_CreateVpnClient> {
32
+ method: 'createVpnClient';
33
+ request: {
34
+ identity: authInterfaces.IIdentity;
35
+ clientId: string;
36
+ tags?: string[];
37
+ description?: string;
38
+ };
39
+ response: {
40
+ success: boolean;
41
+ client?: IVpnClient;
42
+ /** WireGuard .conf file content (only returned at creation) */
43
+ wireguardConfig?: string;
44
+ message?: string;
45
+ };
46
+ }
47
+ /**
48
+ * Delete a VPN client.
49
+ */
50
+ export interface IReq_DeleteVpnClient extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_DeleteVpnClient> {
51
+ method: 'deleteVpnClient';
52
+ request: {
53
+ identity: authInterfaces.IIdentity;
54
+ clientId: string;
55
+ };
56
+ response: {
57
+ success: boolean;
58
+ message?: string;
59
+ };
60
+ }
61
+ /**
62
+ * Enable a VPN client.
63
+ */
64
+ export interface IReq_EnableVpnClient extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_EnableVpnClient> {
65
+ method: 'enableVpnClient';
66
+ request: {
67
+ identity: authInterfaces.IIdentity;
68
+ clientId: string;
69
+ };
70
+ response: {
71
+ success: boolean;
72
+ message?: string;
73
+ };
74
+ }
75
+ /**
76
+ * Disable a VPN client.
77
+ */
78
+ export interface IReq_DisableVpnClient extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_DisableVpnClient> {
79
+ method: 'disableVpnClient';
80
+ request: {
81
+ identity: authInterfaces.IIdentity;
82
+ clientId: string;
83
+ };
84
+ response: {
85
+ success: boolean;
86
+ message?: string;
87
+ };
88
+ }
89
+ /**
90
+ * Rotate a VPN client's keys. Returns the new config bundle.
91
+ */
92
+ export interface IReq_RotateVpnClientKey extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_RotateVpnClientKey> {
93
+ method: 'rotateVpnClientKey';
94
+ request: {
95
+ identity: authInterfaces.IIdentity;
96
+ clientId: string;
97
+ };
98
+ response: {
99
+ success: boolean;
100
+ /** WireGuard .conf file content with new keys */
101
+ wireguardConfig?: string;
102
+ message?: string;
103
+ };
104
+ }
105
+ /**
106
+ * Export a VPN client config.
107
+ */
108
+ export interface IReq_ExportVpnClientConfig extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_ExportVpnClientConfig> {
109
+ method: 'exportVpnClientConfig';
110
+ request: {
111
+ identity: authInterfaces.IIdentity;
112
+ clientId: string;
113
+ format: 'smartvpn' | 'wireguard';
114
+ };
115
+ response: {
116
+ success: boolean;
117
+ config?: string;
118
+ message?: string;
119
+ };
120
+ }
121
+ /**
122
+ * Get telemetry for a specific VPN client.
123
+ */
124
+ export interface IReq_GetVpnClientTelemetry extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_GetVpnClientTelemetry> {
125
+ method: 'getVpnClientTelemetry';
126
+ request: {
127
+ identity: authInterfaces.IIdentity;
128
+ clientId: string;
129
+ };
130
+ response: {
131
+ success: boolean;
132
+ telemetry?: IVpnClientTelemetry;
133
+ message?: string;
134
+ };
135
+ }
@@ -0,0 +1,3 @@
1
+ import * as plugins from '../plugins.js';
2
+ import * as authInterfaces from '../data/auth.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidnBuLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHNfaW50ZXJmYWNlcy9yZXF1ZXN0cy92cG4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxLQUFLLGNBQWMsTUFBTSxpQkFBaUIsQ0FBQyJ9
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@serve.zone/dcrouter",
3
3
  "private": false,
4
- "version": "11.12.4",
4
+ "version": "11.14.0",
5
5
  "description": "A multifaceted routing service handling mail and SMS delivery functions.",
6
6
  "type": "module",
7
7
  "exports": {
@@ -59,6 +59,7 @@
59
59
  "@push.rocks/smartrx": "^3.0.10",
60
60
  "@push.rocks/smartstate": "^2.3.0",
61
61
  "@push.rocks/smartunique": "^3.0.9",
62
+ "@push.rocks/smartvpn": "1.12.0",
62
63
  "@push.rocks/taskbuffer": "^8.0.2",
63
64
  "@serve.zone/catalog": "^2.9.0",
64
65
  "@serve.zone/interfaces": "^5.3.0",
package/readme.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **dcrouter: The all-in-one gateway for your datacenter.** 🚀
6
6
 
7
- A comprehensive traffic routing solution that provides unified gateway capabilities for HTTP/HTTPS, TCP/SNI, email (SMTP), DNS, RADIUS, and remote edge ingress — all from a single process. Designed for enterprises requiring robust traffic management, automatic TLS certificate provisioning, distributed edge networking, and enterprise-grade email infrastructure.
7
+ A comprehensive traffic routing solution that provides unified gateway capabilities for HTTP/HTTPS, TCP/SNI, email (SMTP), DNS, RADIUS, VPN, and remote edge ingress — all from a single process. Designed for enterprises requiring robust traffic management, automatic TLS certificate provisioning, VPN-based access control, distributed edge networking, and enterprise-grade email infrastructure.
8
8
 
9
9
  ## Issue Reporting and Security
10
10
 
@@ -23,6 +23,7 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
23
23
  - [DNS Server](#dns-server)
24
24
  - [RADIUS Server](#radius-server)
25
25
  - [Remote Ingress](#remote-ingress)
26
+ - [VPN Access Control](#vpn-access-control)
26
27
  - [Certificate Management](#certificate-management)
27
28
  - [Storage & Caching](#storage--caching)
28
29
  - [Security Features](#security-features)
@@ -73,6 +74,14 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
73
74
  - **Real-time status monitoring** — connected/disconnected state, public IP, active tunnels, heartbeat tracking
74
75
  - **OpsServer dashboard** with enable/disable, edit, secret regeneration, token copy, and delete actions
75
76
 
77
+ ### 🔐 VPN Access Control (powered by [smartvpn](https://code.foss.global/push.rocks/smartvpn))
78
+ - **WireGuard + native transports** — standard WireGuard clients (iOS, Android, macOS, Windows, Linux) plus custom WebSocket/QUIC tunnels
79
+ - **Route-level VPN gating** — mark any route with `vpn: { required: true }` to restrict access to VPN clients only
80
+ - **Rootless operation** — auto-detects privileges: kernel TUN when running as root, userspace NAT (smoltcp) when not
81
+ - **Client management** — create, enable, disable, rotate keys, export WireGuard `.conf` files via OpsServer API
82
+ - **IP-based enforcement** — VPN clients get IPs from a configurable subnet; SmartProxy enforces `ipAllowList` per route
83
+ - **PROXY protocol v2** — in socket mode, the NAT engine sends PP v2 on outbound connections to preserve VPN client identity
84
+
76
85
  ### ⚡ High Performance
77
86
  - **Rust-powered proxy engine** via SmartProxy for maximum throughput
78
87
  - **Rust-powered MTA engine** via smartmta (TypeScript + Rust hybrid) for reliable email delivery
@@ -89,7 +98,7 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
89
98
  ### 🖥️ OpsServer Dashboard
90
99
  - **Web-based management interface** with real-time monitoring
91
100
  - **JWT authentication** with session persistence
92
- - **Live views** for connections, email queues, DNS queries, RADIUS sessions, certificates, remote ingress edges, and security events
101
+ - **Live views** for connections, email queues, DNS queries, RADIUS sessions, certificates, remote ingress edges, VPN clients, and security events
93
102
  - **Domain-centric certificate overview** with backoff status and one-click reprovisioning
94
103
  - **Remote ingress management** with connection token generation and one-click copy
95
104
  - **Read-only configuration display** — DcRouter is configured through code
@@ -248,6 +257,13 @@ const router = new DcRouter({
248
257
  hubDomain: 'hub.example.com',
249
258
  },
250
259
 
260
+ // VPN — restrict sensitive routes to VPN clients
261
+ vpnConfig: {
262
+ enabled: true,
263
+ serverEndpoint: 'vpn.example.com',
264
+ wgListenPort: 51820,
265
+ },
266
+
251
267
  // Persistent storage
252
268
  storage: { fsPath: '/var/lib/dcrouter/data' },
253
269
 
@@ -276,6 +292,7 @@ graph TB
276
292
  DNS[DNS Queries]
277
293
  RAD[RADIUS Clients]
278
294
  EDGE[Edge Nodes]
295
+ VPN[VPN Clients]
279
296
  end
280
297
 
281
298
  subgraph "DcRouter Core"
@@ -285,6 +302,7 @@ graph TB
285
302
  DS[SmartDNS Server<br/><i>Rust-powered</i>]
286
303
  RS[SmartRadius Server]
287
304
  RI[RemoteIngress Hub<br/><i>Rust data plane</i>]
305
+ VS[SmartVPN Server<br/><i>Rust data plane</i>]
288
306
  CM[Certificate Manager<br/><i>smartacme v9</i>]
289
307
  OS[OpsServer Dashboard]
290
308
  MM[Metrics Manager]
@@ -305,12 +323,14 @@ graph TB
305
323
  DNS --> DS
306
324
  RAD --> RS
307
325
  EDGE --> RI
326
+ VPN --> VS
308
327
 
309
328
  DC --> SP
310
329
  DC --> ES
311
330
  DC --> DS
312
331
  DC --> RS
313
332
  DC --> RI
333
+ DC --> VS
314
334
  DC --> CM
315
335
  DC --> OS
316
336
  DC --> MM
@@ -428,6 +448,17 @@ interface IDcRouterOptions {
428
448
  };
429
449
  };
430
450
 
451
+ // ── VPN ───────────────────────────────────────────────────────
452
+ /** VPN server for route-level access control */
453
+ vpnConfig?: {
454
+ enabled?: boolean; // default: false
455
+ subnet?: string; // default: '10.8.0.0/24'
456
+ wgListenPort?: number; // default: 51820
457
+ dns?: string[]; // DNS servers pushed to VPN clients
458
+ serverEndpoint?: string; // Hostname in generated client configs
459
+ forwardingMode?: 'tun' | 'socket'; // default: auto-detect (root → tun, else socket)
460
+ };
461
+
431
462
  // ── HTTP/3 (QUIC) ────────────────────────────────────────────
432
463
  /** HTTP/3 config — enabled by default on qualifying HTTPS routes */
433
464
  http3?: {
@@ -975,6 +1006,78 @@ The OpsServer Remote Ingress view provides:
975
1006
  | **Copy Token** | Generate and copy a base64url connection token to clipboard |
976
1007
  | **Delete** | Remove the edge registration |
977
1008
 
1009
+ ## VPN Access Control
1010
+
1011
+ DcRouter integrates [`@push.rocks/smartvpn`](https://code.foss.global/push.rocks/smartvpn) to provide VPN-based route access control. VPN clients connect via standard WireGuard or native WebSocket/QUIC transports, receive an IP from a configurable subnet, and can then access routes that are restricted to VPN-only traffic.
1012
+
1013
+ ### How It Works
1014
+
1015
+ 1. **SmartVPN daemon** runs inside dcrouter with a Rust data plane (WireGuard via `boringtun`, custom protocol via Noise IK)
1016
+ 2. Clients connect and get assigned an IP from the VPN subnet (e.g. `10.8.0.0/24`)
1017
+ 3. Routes with `vpn: { required: true }` get `security.ipAllowList` automatically injected with the VPN subnet
1018
+ 4. SmartProxy enforces the allowlist — only VPN-sourced traffic is accepted on those routes
1019
+
1020
+ ### Two Operating Modes
1021
+
1022
+ | Mode | Root Required? | How It Works |
1023
+ |------|---------------|-------------|
1024
+ | **TUN** (`forwardingMode: 'tun'`) | Yes | Kernel TUN device — VPN traffic enters the network stack with real VPN IPs |
1025
+ | **Socket** (`forwardingMode: 'socket'`) | No | Userspace NAT via smoltcp — outbound connections send PROXY protocol v2 to preserve VPN client IPs |
1026
+
1027
+ DcRouter auto-detects: if running as root, it uses TUN mode; otherwise, it falls back to socket mode. You can override this with the `forwardingMode` option.
1028
+
1029
+ ### Configuration
1030
+
1031
+ ```typescript
1032
+ const router = new DcRouter({
1033
+ vpnConfig: {
1034
+ enabled: true,
1035
+ subnet: '10.8.0.0/24', // VPN client IP pool (default)
1036
+ wgListenPort: 51820, // WireGuard UDP port (default)
1037
+ serverEndpoint: 'vpn.example.com', // Hostname in generated client configs
1038
+ dns: ['1.1.1.1', '8.8.8.8'], // DNS servers pushed to clients
1039
+ // forwardingMode: 'socket', // Override auto-detection
1040
+ },
1041
+ smartProxyConfig: {
1042
+ routes: [
1043
+ // This route is VPN-only — non-VPN clients are blocked
1044
+ {
1045
+ name: 'admin-panel',
1046
+ match: { domains: ['admin.example.com'], ports: [443] },
1047
+ action: {
1048
+ type: 'forward',
1049
+ targets: [{ host: '192.168.1.50', port: 8080 }],
1050
+ tls: { mode: 'terminate', certificate: 'auto' },
1051
+ },
1052
+ vpn: { required: true }, // 🔐 Only VPN clients can access this
1053
+ },
1054
+ // This route is public — anyone can access it
1055
+ {
1056
+ name: 'public-site',
1057
+ match: { domains: ['example.com'], ports: [443] },
1058
+ action: {
1059
+ type: 'forward',
1060
+ targets: [{ host: '192.168.1.10', port: 80 }],
1061
+ tls: { mode: 'terminate', certificate: 'auto' },
1062
+ },
1063
+ },
1064
+ ],
1065
+ },
1066
+ });
1067
+ ```
1068
+
1069
+ ### Client Management via OpsServer API
1070
+
1071
+ Once the VPN server is running, you can manage clients through the OpsServer dashboard or API:
1072
+
1073
+ - **Create client** — generates WireGuard keypairs, assigns IP, returns a ready-to-use `.conf` file
1074
+ - **Enable / Disable** — toggle client access without deleting
1075
+ - **Rotate keys** — generate fresh keypairs (invalidates old ones)
1076
+ - **Export config** — re-export in WireGuard or SmartVPN format
1077
+ - **Telemetry** — per-client bytes sent/received, keepalives, rate limiting
1078
+
1079
+ Standard WireGuard clients on any platform (iOS, Android, macOS, Windows, Linux) can connect using the generated `.conf` file or QR code — no custom VPN software needed.
1080
+
978
1081
  ## Certificate Management
979
1082
 
980
1083
  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:
@@ -1458,6 +1561,7 @@ The container exposes all service ports:
1458
1561
  | 1812, 1813 | UDP | RADIUS auth/acct |
1459
1562
  | 3000 | TCP | OpsServer dashboard |
1460
1563
  | 8443 | TCP | Remote ingress tunnels |
1564
+ | 51820 | UDP | WireGuard VPN |
1461
1565
  | 29000–30000 | TCP | Dynamic port range |
1462
1566
 
1463
1567
  ### Building the Image
@@ -1471,7 +1575,7 @@ The Docker build supports multi-platform (`linux/amd64`, `linux/arm64`) via [tsd
1471
1575
 
1472
1576
  ## License and Legal Information
1473
1577
 
1474
- This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](./license) file.
1578
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
1475
1579
 
1476
1580
  **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.
1477
1581
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/dcrouter',
6
- version: '11.12.4',
6
+ version: '11.14.0',
7
7
  description: 'A multifaceted routing service handling mail and SMS delivery functions.'
8
8
  }
@@ -22,6 +22,7 @@ import { OpsServer } from './opsserver/index.js';
22
22
  import { MetricsManager } from './monitoring/index.js';
23
23
  import { RadiusServer, type IRadiusServerConfig } from './radius/index.js';
24
24
  import { RemoteIngressManager, TunnelManager } from './remoteingress/index.js';
25
+ import { VpnManager, type IVpnManagerConfig } from './vpn/index.js';
25
26
  import { RouteConfigManager, ApiTokenManager } from './config/index.js';
26
27
  import { SecurityLogger, ContentScanner, IPReputationChecker } from './security/index.js';
27
28
  import { type IHttp3Config, augmentRoutesWithHttp3 } from './http3/index.js';
@@ -188,6 +189,26 @@ export interface IDcRouterOptions {
188
189
  keyPath?: string;
189
190
  };
190
191
  };
192
+
193
+ /**
194
+ * VPN server configuration.
195
+ * Enables VPN-based access control: routes with vpn.required are only
196
+ * accessible from VPN clients. Supports WireGuard + native (WS/QUIC) transports.
197
+ */
198
+ vpnConfig?: {
199
+ /** Enable VPN server (default: false) */
200
+ enabled?: boolean;
201
+ /** VPN subnet CIDR (default: '10.8.0.0/24') */
202
+ subnet?: string;
203
+ /** WireGuard UDP listen port (default: 51820) */
204
+ wgListenPort?: number;
205
+ /** DNS servers pushed to VPN clients */
206
+ dns?: string[];
207
+ /** Server endpoint hostname for client configs (e.g. 'vpn.example.com') */
208
+ serverEndpoint?: string;
209
+ /** Override forwarding mode. Default: auto-detect (tun if root, socket otherwise) */
210
+ forwardingMode?: 'tun' | 'socket';
211
+ };
191
212
  }
192
213
 
193
214
  /**
@@ -226,6 +247,9 @@ export class DcRouter {
226
247
  public remoteIngressManager?: RemoteIngressManager;
227
248
  public tunnelManager?: TunnelManager;
228
249
 
250
+ // VPN
251
+ public vpnManager?: VpnManager;
252
+
229
253
  // Programmatic config API
230
254
  public routeConfigManager?: RouteConfigManager;
231
255
  public apiTokenManager?: ApiTokenManager;
@@ -429,6 +453,7 @@ export class DcRouter {
429
453
  () => this.getConstructorRoutes(),
430
454
  () => this.smartProxy,
431
455
  () => this.options.http3,
456
+ () => this.options.vpnConfig?.enabled ? (this.options.vpnConfig.subnet || '10.8.0.0/24') : undefined,
432
457
  );
433
458
  this.apiTokenManager = new ApiTokenManager(this.storageManager);
434
459
  await this.apiTokenManager.initialize();
@@ -533,6 +558,25 @@ export class DcRouter {
533
558
  );
534
559
  }
535
560
 
561
+ // VPN Server: optional, depends on SmartProxy
562
+ if (this.options.vpnConfig?.enabled) {
563
+ this.serviceManager.addService(
564
+ new plugins.taskbuffer.Service('VpnServer')
565
+ .optional()
566
+ .dependsOn('SmartProxy')
567
+ .withStart(async () => {
568
+ await this.setupVpnServer();
569
+ })
570
+ .withStop(async () => {
571
+ if (this.vpnManager) {
572
+ await this.vpnManager.stop();
573
+ this.vpnManager = undefined;
574
+ }
575
+ })
576
+ .withRetry({ maxRetries: 3, baseDelayMs: 2000, maxDelayMs: 30_000 }),
577
+ );
578
+ }
579
+
536
580
  // Wire up aggregated events for logging
537
581
  this.serviceSubjectSubscription = this.serviceManager.serviceSubject.subscribe((event) => {
538
582
  const level = event.type === 'failed' ? 'error' : event.type === 'retrying' ? 'warn' : 'info';
@@ -616,6 +660,15 @@ export class DcRouter {
616
660
  logger.log('info', `RADIUS Service: auth=${this.options.radiusConfig.authPort || 1812}, acct=${this.options.radiusConfig.acctPort || 1813}, clients=${this.options.radiusConfig.clients?.length || 0}, VLANs=${vlanStats.totalMappings}, accounting=${this.options.radiusConfig.accounting?.enabled ? 'enabled' : 'disabled'}`);
617
661
  }
618
662
 
663
+ // VPN summary
664
+ if (this.vpnManager && this.options.vpnConfig?.enabled) {
665
+ const subnet = this.vpnManager.getSubnet();
666
+ const wgPort = this.options.vpnConfig.wgListenPort ?? 51820;
667
+ const mode = this.vpnManager.forwardingMode;
668
+ const clientCount = this.vpnManager.listClients().length;
669
+ logger.log('info', `VPN Service: mode=${mode}, subnet=${subnet}, wg=:${wgPort}, clients=${clientCount}`);
670
+ }
671
+
619
672
  // Remote Ingress summary
620
673
  if (this.tunnelManager && this.options.remoteIngressConfig?.enabled) {
621
674
  const edgeCount = this.remoteIngressManager?.getAllEdges().length || 0;
@@ -741,6 +794,11 @@ export class DcRouter {
741
794
  logger.log('info', 'HTTP/3: Augmented qualifying HTTPS routes with QUIC/H3 configuration');
742
795
  }
743
796
 
797
+ // VPN route security injection: restrict vpn.required routes to VPN subnet
798
+ if (this.options.vpnConfig?.enabled) {
799
+ routes = this.injectVpnSecurity(routes);
800
+ }
801
+
744
802
  // Cache constructor routes for RouteConfigManager
745
803
  this.constructorRoutes = [...routes];
746
804
 
@@ -892,6 +950,22 @@ export class DcRouter {
892
950
  smartProxyConfig.proxyIPs = ['127.0.0.1'];
893
951
  }
894
952
 
953
+ // When VPN is in socket mode, the userspace NAT engine sends PP v2 headers
954
+ // on outbound connections to SmartProxy to preserve VPN client tunnel IPs.
955
+ if (this.options.vpnConfig?.enabled) {
956
+ const vpnForwardingMode = this.options.vpnConfig.forwardingMode
957
+ ?? (process.getuid?.() === 0 ? 'tun' : 'socket');
958
+ if (vpnForwardingMode === 'socket') {
959
+ smartProxyConfig.acceptProxyProtocol = true;
960
+ if (!smartProxyConfig.proxyIPs) {
961
+ smartProxyConfig.proxyIPs = [];
962
+ }
963
+ if (!smartProxyConfig.proxyIPs.includes('127.0.0.1')) {
964
+ smartProxyConfig.proxyIPs.push('127.0.0.1');
965
+ }
966
+ }
967
+ }
968
+
895
969
  // Create SmartProxy instance
896
970
  logger.log('info', `Creating SmartProxy instance: routes=${smartProxyConfig.routes?.length}, acme=${smartProxyConfig.acme?.enabled}, certProvisionFunction=${!!smartProxyConfig.certProvisionFunction}`);
897
971
 
@@ -1996,6 +2070,58 @@ export class DcRouter {
1996
2070
  logger.log('info', `Remote Ingress hub started on port ${this.options.remoteIngressConfig.tunnelPort || 8443} with ${edgeCount} registered edge(s)`);
1997
2071
  }
1998
2072
 
2073
+ /**
2074
+ * Set up VPN server for VPN-based route access control.
2075
+ */
2076
+ private async setupVpnServer(): Promise<void> {
2077
+ if (!this.options.vpnConfig?.enabled) {
2078
+ return;
2079
+ }
2080
+
2081
+ logger.log('info', 'Setting up VPN server...');
2082
+
2083
+ this.vpnManager = new VpnManager(this.storageManager, {
2084
+ subnet: this.options.vpnConfig.subnet,
2085
+ wgListenPort: this.options.vpnConfig.wgListenPort,
2086
+ dns: this.options.vpnConfig.dns,
2087
+ serverEndpoint: this.options.vpnConfig.serverEndpoint,
2088
+ forwardingMode: this.options.vpnConfig.forwardingMode,
2089
+ });
2090
+
2091
+ await this.vpnManager.start();
2092
+ }
2093
+
2094
+ /**
2095
+ * Inject VPN security into routes that have vpn.required === true.
2096
+ * Adds the VPN subnet to security.ipAllowList so only VPN clients can access them.
2097
+ */
2098
+ private injectVpnSecurity(routes: plugins.smartproxy.IRouteConfig[]): plugins.smartproxy.IRouteConfig[] {
2099
+ const vpnSubnet = this.options.vpnConfig?.subnet || '10.8.0.0/24';
2100
+ let injectedCount = 0;
2101
+
2102
+ const result = routes.map((route) => {
2103
+ const dcrouterRoute = route as import('../ts_interfaces/data/remoteingress.js').IDcRouterRouteConfig;
2104
+ if (dcrouterRoute.vpn?.required) {
2105
+ injectedCount++;
2106
+ const existing = route.security?.ipAllowList || [];
2107
+ return {
2108
+ ...route,
2109
+ security: {
2110
+ ...route.security,
2111
+ ipAllowList: [...existing, vpnSubnet],
2112
+ },
2113
+ };
2114
+ }
2115
+ return route;
2116
+ });
2117
+
2118
+ if (injectedCount > 0) {
2119
+ logger.log('info', `VPN: Injected ipAllowList (${vpnSubnet}) into ${injectedCount} VPN-protected route(s)`);
2120
+ }
2121
+
2122
+ return result;
2123
+ }
2124
+
1999
2125
  /**
2000
2126
  * Set up RADIUS server for network authentication
2001
2127
  */