Sync DNS2 production changes - removed obsolete test suite and refactored structure
This commit is contained in:
@@ -99,7 +99,7 @@ module.exports = function(ctx) {
|
||||
isUp: false,
|
||||
statusCode: 502,
|
||||
responseTime,
|
||||
error: error.message,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ module.exports = function(ctx) {
|
||||
isUp: isServiceUp(statusCode),
|
||||
statusCode,
|
||||
responseTime,
|
||||
url,
|
||||
url
|
||||
};
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ module.exports = function(ctx) {
|
||||
success: true,
|
||||
hasApiKey: !!(arrKey || svcKey),
|
||||
hasBasicAuth: !!username,
|
||||
username: username || null,
|
||||
username: username || null
|
||||
});
|
||||
} catch (error) {
|
||||
res.json({ success: true, hasApiKey: false, hasBasicAuth: false });
|
||||
@@ -249,7 +249,7 @@ module.exports = function(ctx) {
|
||||
services.forEach(service => addId(service.id));
|
||||
|
||||
const statusResults = await mapWithConcurrency(ids, PROBE_CONCURRENCY, (id) =>
|
||||
probeServiceStatus(id, serviceMap.get(id)),
|
||||
probeServiceStatus(id, serviceMap.get(id))
|
||||
);
|
||||
|
||||
const statuses = {};
|
||||
@@ -261,7 +261,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
checkedAt: new Date().toISOString(),
|
||||
statuses,
|
||||
statuses
|
||||
});
|
||||
}, 'services-status'));
|
||||
|
||||
@@ -343,7 +343,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
message: `Successfully imported ${services.length} services`,
|
||||
count: services.length,
|
||||
count: services.length
|
||||
});
|
||||
}, 'services-import'));
|
||||
|
||||
@@ -396,12 +396,12 @@ module.exports = function(ctx) {
|
||||
const oldDomain = ctx.buildDomain(oldSubdomain);
|
||||
const newDomain = ctx.buildDomain(newSubdomain);
|
||||
|
||||
const content = await ctx.caddy.read();
|
||||
let content = await ctx.caddy.read();
|
||||
|
||||
const escapedOldDomain = oldDomain.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const siteBlockRegex = new RegExp(
|
||||
`${escapedOldDomain}\\s*\\{[^{}]*(?:\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}[^{}]*)*\\}`,
|
||||
's',
|
||||
's'
|
||||
);
|
||||
|
||||
const oldBlockMatch = content.match(siteBlockRegex);
|
||||
@@ -414,7 +414,7 @@ module.exports = function(ctx) {
|
||||
const finalPort = port || existingPort;
|
||||
|
||||
const newConfig = ctx.caddy.generateConfig(newSubdomain, finalIp, finalPort, {
|
||||
tailscaleOnly: tailscaleOnly || false,
|
||||
tailscaleOnly: tailscaleOnly || false
|
||||
});
|
||||
|
||||
const caddyResult = await ctx.caddy.modify(c => c.replace(siteBlockRegex, newConfig));
|
||||
@@ -445,7 +445,7 @@ module.exports = function(ctx) {
|
||||
id: newSubdomain,
|
||||
port: port || services[serviceIndex].port,
|
||||
ip: ip || services[serviceIndex].ip,
|
||||
tailscaleOnly: tailscaleOnly || false,
|
||||
tailscaleOnly: tailscaleOnly || false
|
||||
};
|
||||
results.services = 'updated';
|
||||
} else {
|
||||
@@ -459,7 +459,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
message: `Service updated: ${oldSubdomain} -> ${newSubdomain}`,
|
||||
results,
|
||||
results
|
||||
});
|
||||
}, 'services-update'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user