Phase 1: Add ESLint/Prettier config + baseline auto-fixes
This commit is contained in:
@@ -16,7 +16,7 @@ module.exports = function(ctx) {
|
||||
success: true,
|
||||
installed: false,
|
||||
connected: false,
|
||||
message: 'Tailscale not available or not running'
|
||||
message: 'Tailscale not available or not running',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ module.exports = function(ctx) {
|
||||
os: peer.OS,
|
||||
online: peer.Online,
|
||||
lastSeen: peer.LastSeen,
|
||||
user: peer.UserID
|
||||
user: peer.UserID,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -44,11 +44,11 @@ module.exports = function(ctx) {
|
||||
hostname: status.Self?.HostName,
|
||||
ip: localIP,
|
||||
tailnetName: status.MagicDNSSuffix,
|
||||
online: status.Self?.Online
|
||||
online: status.Self?.Online,
|
||||
},
|
||||
config: ctx.tailscale.config,
|
||||
devices,
|
||||
deviceCount: devices.length
|
||||
deviceCount: devices.length,
|
||||
});
|
||||
}, 'tailscale-status'));
|
||||
|
||||
@@ -65,7 +65,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'Tailscale configuration updated',
|
||||
config: ctx.tailscale.config
|
||||
config: ctx.tailscale.config,
|
||||
});
|
||||
}, 'tailscale-config'));
|
||||
|
||||
@@ -83,7 +83,7 @@ module.exports = function(ctx) {
|
||||
isTailscale,
|
||||
clientIP,
|
||||
forwardedFor: forwardedFor || null,
|
||||
realIP: realIP || null
|
||||
realIP: realIP || null,
|
||||
});
|
||||
}, 'tailscale-check'));
|
||||
|
||||
@@ -102,7 +102,7 @@ module.exports = function(ctx) {
|
||||
hostname: peer.HostName,
|
||||
ip: peer.TailscaleIPs?.[0],
|
||||
os: peer.OS,
|
||||
user: peer.UserID
|
||||
user: peer.UserID,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ module.exports = function(ctx) {
|
||||
ip: status.Self.TailscaleIPs?.[0],
|
||||
os: status.Self.OS,
|
||||
user: status.Self.UserID,
|
||||
isSelf: true
|
||||
isSelf: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ module.exports = function(ctx) {
|
||||
return ctx.errorResponse(res, 400, 'subdomain is required');
|
||||
}
|
||||
|
||||
let content = await ctx.caddy.read();
|
||||
const content = await ctx.caddy.read();
|
||||
const domain = ctx.buildDomain(subdomain);
|
||||
|
||||
const blockRegex = new RegExp(`(${domain.replace('.', '\\.')}\\s*\\{[^}]*\\})`, 's');
|
||||
@@ -149,7 +149,7 @@ module.exports = function(ctx) {
|
||||
|
||||
const newConfig = ctx.caddy.generateConfig(subdomain, ip, port || '80', {
|
||||
tailscaleOnly: tailscaleOnly !== false,
|
||||
allowedIPs: allowedIPs || []
|
||||
allowedIPs: allowedIPs || [],
|
||||
});
|
||||
|
||||
const caddyResult = await ctx.caddy.modify(c => c.replace(blockRegex, newConfig));
|
||||
@@ -170,7 +170,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
message: `Service ${domain} is now ${tailscaleOnly !== false ? 'protected by' : 'no longer restricted to'} Tailscale`,
|
||||
tailscaleOnly: tailscaleOnly !== false
|
||||
tailscaleOnly: tailscaleOnly !== false,
|
||||
});
|
||||
}, 'tailscale-protect'));
|
||||
|
||||
@@ -188,7 +188,7 @@ module.exports = function(ctx) {
|
||||
const tokenRes = await fetch(TAILSCALE.OAUTH_TOKEN_URL, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: `client_id=${encodeURIComponent(clientId)}&client_secret=${encodeURIComponent(clientSecret)}&grant_type=client_credentials`
|
||||
body: `client_id=${encodeURIComponent(clientId)}&client_secret=${encodeURIComponent(clientSecret)}&grant_type=client_credentials`,
|
||||
});
|
||||
|
||||
if (!tokenRes.ok) {
|
||||
@@ -199,7 +199,7 @@ module.exports = function(ctx) {
|
||||
|
||||
// Test with the device list to verify scopes
|
||||
const testRes = await fetch(`${TAILSCALE.API_BASE}/tailnet/${encodeURIComponent(tailnet)}/devices`, {
|
||||
headers: { Authorization: `Bearer ${tokenData.access_token}` }
|
||||
headers: { Authorization: `Bearer ${tokenData.access_token}` },
|
||||
});
|
||||
|
||||
if (!testRes.ok) {
|
||||
@@ -259,7 +259,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
devices: ctx.tailscale.config.devices || [],
|
||||
lastSync: ctx.tailscale.config.lastSync
|
||||
lastSync: ctx.tailscale.config.lastSync,
|
||||
});
|
||||
}, 'tailscale-api-devices'));
|
||||
|
||||
@@ -274,7 +274,7 @@ module.exports = function(ctx) {
|
||||
res.json({
|
||||
success: true,
|
||||
devices: devices || [],
|
||||
lastSync: ctx.tailscale.config.lastSync
|
||||
lastSync: ctx.tailscale.config.lastSync,
|
||||
});
|
||||
}, 'tailscale-sync'));
|
||||
|
||||
@@ -287,7 +287,7 @@ module.exports = function(ctx) {
|
||||
}
|
||||
|
||||
const aclRes = await fetch(`${TAILSCALE.API_BASE}/tailnet/${encodeURIComponent(tailnet)}/acl`, {
|
||||
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' }
|
||||
headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' },
|
||||
});
|
||||
if (!aclRes.ok) {
|
||||
return ctx.errorResponse(res, aclRes.status, `ACL fetch failed: HTTP ${aclRes.status}`);
|
||||
@@ -299,7 +299,7 @@ module.exports = function(ctx) {
|
||||
groups: Object.keys(acl.groups || {}),
|
||||
tagOwners: Object.keys(acl.tagOwners || {}),
|
||||
aclRuleCount: (acl.acls || []).length,
|
||||
sshRuleCount: (acl.ssh || []).length
|
||||
sshRuleCount: (acl.ssh || []).length,
|
||||
};
|
||||
|
||||
res.json({ success: true, acl, summary });
|
||||
|
||||
Reference in New Issue
Block a user