@serve.zone/dcrouter 17.9.6 → 17.10.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/deno.json +1 -1
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/config/classes.route-config-manager.js +3 -1
- package/dist_ts/dns/classes.gateway-route-dns-reconciler.d.ts +1 -0
- package/dist_ts/dns/classes.gateway-route-dns-reconciler.js +23 -10
- package/dist_ts/opsserver/handlers/gatewayclient.handler.js +19 -8
- package/dist_ts_interfaces/data/route-management.d.ts +2 -0
- package/dist_ts_interfaces/data/route-management.js +1 -1
- package/dist_ts_web/00_commitinfo_data.js +2 -2
- package/package.json +2 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/config/classes.route-config-manager.ts +2 -0
- package/ts/dns/classes.gateway-route-dns-reconciler.ts +23 -6
- package/ts/opsserver/handlers/gatewayclient.handler.ts +18 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
|
@@ -17,6 +17,7 @@ export interface IGatewayRouteDnsReconcileOptions {
|
|
|
17
17
|
gatewayClientId: string;
|
|
18
18
|
hostname?: string;
|
|
19
19
|
mode?: plugins.servezoneInterfaces.data.TGatewayRouteDnsMode;
|
|
20
|
+
proxied?: boolean;
|
|
20
21
|
delete?: boolean;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -131,7 +132,8 @@ export class GatewayRouteDnsReconciler {
|
|
|
131
132
|
const targetIp = optionsArg.delete
|
|
132
133
|
? undefined
|
|
133
134
|
: this.getDesiredTargetIp(optionsArg.gatewayClientId, hostname);
|
|
134
|
-
const
|
|
135
|
+
const proxied = optionsArg.proxied ?? false;
|
|
136
|
+
const workKey = this.buildWorkKey(optionsArg, hostname, mode, targetIp, proxied);
|
|
135
137
|
const latestIntent = this.latestIntentByHostname.get(hostname);
|
|
136
138
|
if (latestIntent?.workKey === workKey) return await latestIntent.promise;
|
|
137
139
|
|
|
@@ -154,6 +156,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
154
156
|
mode,
|
|
155
157
|
checkedAt,
|
|
156
158
|
targetIp,
|
|
159
|
+
proxied,
|
|
157
160
|
executionArg.providerZoneRefreshes,
|
|
158
161
|
);
|
|
159
162
|
});
|
|
@@ -181,6 +184,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
181
184
|
mode: Exclude<plugins.servezoneInterfaces.data.TGatewayRouteDnsMode, 'skip'>,
|
|
182
185
|
checkedAt: number,
|
|
183
186
|
targetIp: string | undefined,
|
|
187
|
+
proxied: boolean,
|
|
184
188
|
providerZoneRefreshes?: Map<string, Promise<IProviderZoneRefreshResult>>,
|
|
185
189
|
): Promise<TGatewayDnsResult> {
|
|
186
190
|
const claimOwnerId = this.buildClaimOwnerId(optionsArg.gatewayClientId, hostname);
|
|
@@ -293,9 +297,13 @@ export class GatewayRouteDnsReconciler {
|
|
|
293
297
|
const desired = records.find((recordArg) => recordArg.type === recordType
|
|
294
298
|
&& recordArg.value === targetIp
|
|
295
299
|
&& recordArg.ttl === GATEWAY_ROUTE_DNS_TTL
|
|
296
|
-
&& recordArg.proxied ===
|
|
300
|
+
&& recordArg.proxied === proxied);
|
|
297
301
|
if (mode === 'observe') {
|
|
298
|
-
const satisfied = records.some((recordArg) =>
|
|
302
|
+
const satisfied = records.some((recordArg) => {
|
|
303
|
+
return recordArg.type === recordType
|
|
304
|
+
&& recordArg.value === targetIp
|
|
305
|
+
&& recordArg.proxied === proxied;
|
|
306
|
+
});
|
|
299
307
|
return {
|
|
300
308
|
success: satisfied,
|
|
301
309
|
retryable: !satisfied,
|
|
@@ -327,7 +335,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
327
335
|
type: recordType,
|
|
328
336
|
value: targetIp,
|
|
329
337
|
ttl: GATEWAY_ROUTE_DNS_TTL,
|
|
330
|
-
proxied
|
|
338
|
+
proxied,
|
|
331
339
|
managedBy: GATEWAY_ROUTE_DNS_MANAGED_BY,
|
|
332
340
|
managedOwnerId: claimOwnerId,
|
|
333
341
|
managedRecordKey: stableKey,
|
|
@@ -373,7 +381,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
373
381
|
type: recordType,
|
|
374
382
|
value: targetIp,
|
|
375
383
|
ttl: GATEWAY_ROUTE_DNS_TTL,
|
|
376
|
-
proxied
|
|
384
|
+
proxied,
|
|
377
385
|
createdBy: GATEWAY_ROUTE_DNS_MANAGED_BY,
|
|
378
386
|
managedBy: GATEWAY_ROUTE_DNS_MANAGED_BY,
|
|
379
387
|
managedOwnerId: claimOwnerId,
|
|
@@ -453,7 +461,14 @@ export class GatewayRouteDnsReconciler {
|
|
|
453
461
|
activeOwners.add(claimOwnerId);
|
|
454
462
|
if (!isFirstRouteForClaim) continue;
|
|
455
463
|
const result = await this.reconcileRouteWithExecution(
|
|
456
|
-
{
|
|
464
|
+
{
|
|
465
|
+
externalKey,
|
|
466
|
+
gatewayClientId,
|
|
467
|
+
hostname,
|
|
468
|
+
mode: 'reconcile',
|
|
469
|
+
...(typeof route.metadata.gatewayDnsProxied === 'boolean'
|
|
470
|
+
? { proxied: route.metadata.gatewayDnsProxied } : {}),
|
|
471
|
+
},
|
|
457
472
|
{ respectCooldown: !force, providerZoneRefreshes },
|
|
458
473
|
);
|
|
459
474
|
if (!result.success) {
|
|
@@ -605,6 +620,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
605
620
|
hostnameArg: string,
|
|
606
621
|
modeArg: Exclude<plugins.servezoneInterfaces.data.TGatewayRouteDnsMode, 'skip'>,
|
|
607
622
|
targetIpArg: string | undefined,
|
|
623
|
+
proxiedArg: boolean,
|
|
608
624
|
): string {
|
|
609
625
|
return JSON.stringify({
|
|
610
626
|
hostname: hostnameArg,
|
|
@@ -613,6 +629,7 @@ export class GatewayRouteDnsReconciler {
|
|
|
613
629
|
mode: modeArg,
|
|
614
630
|
delete: optionsArg.delete === true,
|
|
615
631
|
targetIp: targetIpArg || null,
|
|
632
|
+
proxied: proxiedArg,
|
|
616
633
|
claims: this.getActiveClaimsForHostname(hostnameArg),
|
|
617
634
|
});
|
|
618
635
|
}
|
|
@@ -391,7 +391,7 @@ export class GatewayClientHandler {
|
|
|
391
391
|
async (dataArg) => {
|
|
392
392
|
const auth = await this.requireAuth(dataArg, 'gateway-clients:write');
|
|
393
393
|
this.assertCapability(auth, 'syncRoutes');
|
|
394
|
-
return await this.syncGatewayClientRoute(auth, dataArg.ownership, dataArg.route, dataArg.enabled, dataArg.delete, dataArg.sourceProfileRef, dataArg.dnsMode);
|
|
394
|
+
return await this.syncGatewayClientRoute(auth, dataArg.ownership, dataArg.route, dataArg.enabled, dataArg.delete, dataArg.sourceProfileRef, dataArg.dnsMode, dataArg.dnsProxied);
|
|
395
395
|
},
|
|
396
396
|
),
|
|
397
397
|
);
|
|
@@ -1053,6 +1053,8 @@ export class GatewayClientHandler {
|
|
|
1053
1053
|
ownership,
|
|
1054
1054
|
route,
|
|
1055
1055
|
sourceProfileRef: metadata.sourceBindings?.find((bindingArg) => bindingArg.sourceProfileRef)?.sourceProfileRef,
|
|
1056
|
+
dnsMode: metadata.gatewayDnsMode,
|
|
1057
|
+
dnsProxied: metadata.gatewayDnsProxied,
|
|
1056
1058
|
managePath: `/routes/${routeArg.id}`,
|
|
1057
1059
|
};
|
|
1058
1060
|
}
|
|
@@ -1209,6 +1211,7 @@ export class GatewayClientHandler {
|
|
|
1209
1211
|
deleteRoute?: boolean,
|
|
1210
1212
|
sourceProfileRef?: string,
|
|
1211
1213
|
dnsModeArg?: plugins.servezoneInterfaces.data.TGatewayRouteDnsMode,
|
|
1214
|
+
dnsProxiedArg?: boolean,
|
|
1212
1215
|
): Promise<plugins.servezoneInterfaces.data.IGatewayRouteSyncResult> {
|
|
1213
1216
|
const validatedRoute = route === undefined ? undefined : this.validateGatewayRouteConfig(route);
|
|
1214
1217
|
const resolvedOwnership = this.resolveGatewayClientOwnership(auth, ownership);
|
|
@@ -1227,6 +1230,8 @@ export class GatewayClientHandler {
|
|
|
1227
1230
|
return await this.withRouteSyncLock(externalKey, async () => {
|
|
1228
1231
|
const existingRoute = manager.findApiRouteByExternalKey(externalKey);
|
|
1229
1232
|
const dnsMode = dnsModeArg || existingRoute?.metadata?.gatewayDnsMode || 'skip';
|
|
1233
|
+
const dnsProxied = dnsProxiedArg
|
|
1234
|
+
?? existingRoute?.metadata?.gatewayDnsProxied;
|
|
1230
1235
|
const includeDns = dnsModeArg !== undefined || dnsMode !== 'skip';
|
|
1231
1236
|
if (dnsMode === 'observe') this.assertCapability(auth, 'readDnsRecords');
|
|
1232
1237
|
if (dnsMode === 'reconcile') this.assertCapability(auth, 'syncDnsRecords');
|
|
@@ -1236,6 +1241,7 @@ export class GatewayClientHandler {
|
|
|
1236
1241
|
externalKeyArg: string,
|
|
1237
1242
|
deleteArg = false,
|
|
1238
1243
|
effectiveModeArg = dnsMode,
|
|
1244
|
+
proxiedArg = dnsProxied,
|
|
1239
1245
|
) => {
|
|
1240
1246
|
const reconciler = this.opsServerRef.dcRouterRef.gatewayRouteDnsReconciler;
|
|
1241
1247
|
if (!reconciler) {
|
|
@@ -1256,6 +1262,8 @@ export class GatewayClientHandler {
|
|
|
1256
1262
|
mode: effectiveModeArg,
|
|
1257
1263
|
gatewayClientId: gatewayClientIdArg,
|
|
1258
1264
|
delete: deleteArg,
|
|
1265
|
+
...(!deleteArg && typeof proxiedArg === 'boolean'
|
|
1266
|
+
? { proxied: proxiedArg } : {}),
|
|
1259
1267
|
});
|
|
1260
1268
|
} catch (error) {
|
|
1261
1269
|
return {
|
|
@@ -1270,12 +1278,14 @@ export class GatewayClientHandler {
|
|
|
1270
1278
|
}
|
|
1271
1279
|
};
|
|
1272
1280
|
const reconcileDns = async (deleteArg = false, effectiveModeArg = dnsMode) => {
|
|
1281
|
+
const proxied = deleteArg ? undefined : dnsProxied;
|
|
1273
1282
|
return await reconcileDnsFor(
|
|
1274
1283
|
resolvedOwnership.hostname,
|
|
1275
1284
|
resolvedOwnership.gatewayClientId,
|
|
1276
1285
|
externalKey,
|
|
1277
1286
|
deleteArg,
|
|
1278
1287
|
effectiveModeArg,
|
|
1288
|
+
proxied,
|
|
1279
1289
|
);
|
|
1280
1290
|
};
|
|
1281
1291
|
|
|
@@ -1288,6 +1298,7 @@ export class GatewayClientHandler {
|
|
|
1288
1298
|
}
|
|
1289
1299
|
const snapshot = structuredClone(existingRoute);
|
|
1290
1300
|
const existingDnsMode = snapshot.metadata?.gatewayDnsMode || dnsMode;
|
|
1301
|
+
const existingDnsProxied = snapshot.metadata?.gatewayDnsProxied;
|
|
1291
1302
|
const disableResult = await manager.updateManagedRoute(existingRoute.id, {
|
|
1292
1303
|
enabled: false,
|
|
1293
1304
|
});
|
|
@@ -1330,6 +1341,7 @@ export class GatewayClientHandler {
|
|
|
1330
1341
|
snapshot.metadata?.externalKey || externalKey,
|
|
1331
1342
|
false,
|
|
1332
1343
|
'reconcile',
|
|
1344
|
+
existingDnsProxied,
|
|
1333
1345
|
);
|
|
1334
1346
|
}
|
|
1335
1347
|
return {
|
|
@@ -1367,6 +1379,8 @@ export class GatewayClientHandler {
|
|
|
1367
1379
|
gatewayClientAppId: resolvedOwnership.appId,
|
|
1368
1380
|
externalKey,
|
|
1369
1381
|
gatewayDnsMode: dnsMode,
|
|
1382
|
+
...(typeof dnsProxied === 'boolean'
|
|
1383
|
+
? { gatewayDnsProxied: dnsProxied } : {}),
|
|
1370
1384
|
};
|
|
1371
1385
|
const normalizedRoute = this.normalizeGatewayClientRoute(validatedRoute, resolvedOwnership, externalKey);
|
|
1372
1386
|
if (!normalizedRoute.ingress) {
|
|
@@ -1387,6 +1401,7 @@ export class GatewayClientHandler {
|
|
|
1387
1401
|
const snapshot = structuredClone(existingRoute);
|
|
1388
1402
|
const snapshotHostname = this.getRouteHostnames(snapshot.route)[0];
|
|
1389
1403
|
const snapshotDnsMode = snapshot.metadata?.gatewayDnsMode || 'skip';
|
|
1404
|
+
const snapshotDnsProxied = snapshot.metadata?.gatewayDnsProxied;
|
|
1390
1405
|
const snapshotGatewayClientId = snapshot.metadata?.gatewayClientId || resolvedOwnership.gatewayClientId;
|
|
1391
1406
|
const snapshotExternalKey = snapshot.metadata?.externalKey || externalKey;
|
|
1392
1407
|
const shouldCleanPreviousDns = snapshotDnsMode === 'reconcile'
|
|
@@ -1425,6 +1440,7 @@ export class GatewayClientHandler {
|
|
|
1425
1440
|
snapshotExternalKey,
|
|
1426
1441
|
false,
|
|
1427
1442
|
'reconcile',
|
|
1443
|
+
snapshotDnsProxied,
|
|
1428
1444
|
);
|
|
1429
1445
|
if (!restoredDns.success) {
|
|
1430
1446
|
cleanupDns.status = 'compensation-failed';
|
|
@@ -1451,6 +1467,7 @@ export class GatewayClientHandler {
|
|
|
1451
1467
|
snapshotExternalKey,
|
|
1452
1468
|
false,
|
|
1453
1469
|
'reconcile',
|
|
1470
|
+
snapshotDnsProxied,
|
|
1454
1471
|
);
|
|
1455
1472
|
if (!restoredDns.success) {
|
|
1456
1473
|
dns.status = 'compensation-failed';
|