Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d30357777e | |||
| 8c62eaca9d | |||
| 1050cf9144 | |||
| 538a617709 | |||
| eeecf7b586 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "site-gateway",
|
||||
"version": "0.11.65",
|
||||
"version": "0.11.70",
|
||||
"private": true,
|
||||
"description": "Site Gateway: simple self-hosted website publishing, reverse proxying, and automatic HTTPS.",
|
||||
"type": "module",
|
||||
|
||||
+2
-1
@@ -281,7 +281,8 @@ function renderPerformance() {
|
||||
$("#performance-sparkline").innerHTML = points.length ? `${gridLines}<path d="${areaPath}" fill="var(--green)" opacity="0.12" stroke="none" /><path d="${smoothLine}" fill="none" stroke="var(--green)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />` : "";
|
||||
if (!points.length) $("#performance-sparkline-labels").innerHTML = '<span class="axis-label" style="left:0;width:100%;top:45%;text-align:center">No request data for this window yet.</span>';
|
||||
const routes = data.routes || [];
|
||||
$("#performance-rows").innerHTML = routes.length ? routes.map(route => `<tr class="${selected && route.host === selected ? "row-highlight" : ""}"><td title="${escapeHtml(route.host)}">${escapeHtml(route.host)}</td><td>${route.hourRequests}</td><td>${route.dayRequests}</td><td>${route.dayErrors ? `<span class="http-status bad">${route.dayErrors}</span>` : "0"}</td><td>${route.dayAvgMs == null ? "—" : `${route.dayAvgMs} ms`}</td></tr>`).join("") : '<tr><td colspan="5" class="quiet-state">No requests have been logged yet.</td></tr>';
|
||||
const countCell = (count, errors, breakdown) => { const title = breakdown?.length ? ` title="${escapeHtml(breakdown.map(item => `${item.status}: ${item.count.toLocaleString()}`).join(" · "))}"` : ""; return `${count.toLocaleString()}${errors ? ` <span class="count-divider">·</span> <span class="http-status bad"${title}>${errors.toLocaleString()}</span>` : ""}`; };
|
||||
$("#performance-rows").innerHTML = routes.length ? routes.map(route => `<tr class="${selected && route.host === selected ? "row-highlight" : ""}"><td title="${escapeHtml(route.host)}">${escapeHtml(route.host)}</td><td>${countCell(route.hourRequests, route.hourErrors)}</td><td>${countCell(route.dayRequests, route.dayErrors, route.errorBreakdown)}</td><td>${route.dayAvgMs == null ? "—" : `${route.dayAvgMs} ms`}</td></tr>`).join("") : '<tr><td colspan="4" class="quiet-state">No requests have been logged yet.</td></tr>';
|
||||
if (selected) $(`#performance-rows tr.row-highlight`)?.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
|
||||
|
||||
+11
-9
File diff suppressed because one or more lines are too long
@@ -35,6 +35,7 @@ main{padding-top:24px}.utility-bar{display:flex;align-items:center;justify-conte
|
||||
.performance-sparkline-labels .time-label{position:absolute;bottom:0;color:var(--muted);font-size:.68rem;white-space:nowrap}
|
||||
.performance-sparkline-labels .time-label.time-label-end{transform:translateX(-100%)}.row-highlight{background:rgba(98,230,167,.08)}
|
||||
.user-head-actions{display:flex;align-items:center;gap:10px}
|
||||
[data-admin-panel="security"]>h2{margin-bottom:18px}[data-admin-panel="security"]>.dashboard-panel+.dashboard-panel,[data-admin-panel="security"]>.dashboard-panel+form{margin-top:18px}
|
||||
.user-role-select{appearance:none!important;-webkit-appearance:none!important;height:44px;min-height:44px;width:100%;box-sizing:border-box;padding:0 42px 0 12px;line-height:42px;border:1px solid var(--line);border-radius:9px;background-color:var(--panel);color:var(--text);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23f4f7fb' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 14px center;background-size:16px}
|
||||
:root[data-theme="light"] .user-role-select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23132033' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E")}
|
||||
@media(max-width:760px){.data-row{grid-template-columns:auto 1fr}.data-row>div:nth-of-type(n+2){grid-column:2}.feature-summary{gap:8px}.feature-summary>div{padding:13px}.log-toolbar{align-items:stretch;flex-direction:column}.log-toolbar label{min-width:0}}
|
||||
@@ -57,7 +58,7 @@ main{padding-top:24px}.utility-bar{display:flex;align-items:center;justify-conte
|
||||
dialog{max-height:calc(100vh - 28px);overflow:auto}
|
||||
.setup-dialog{width:min(520px,calc(100% - 28px))}.setup-dialog::backdrop{background:rgba(2,7,14,.9)}.setup-card{max-width:none}.setup-card .brand-mark{margin-bottom:24px}.setup-card h1{margin:0 0 10px;font-size:clamp(1.8rem,5vw,2.35rem);letter-spacing:-.04em}.setup-card>.muted{margin-bottom:22px}.setup-card .button{margin-top:20px}
|
||||
.feature-toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:16px}.certificates-view .feature-summary,#certificates-view .feature-summary{grid-template-columns:repeat(5,minmax(0,1fr))}.certificate-row{margin:0;border:0;border-top:1px solid var(--line);border-radius:0;background:transparent}.certificate-row:first-child{border-top:0}.certificate-row summary{display:grid;grid-template-columns:auto minmax(180px,1.2fr) minmax(220px,1fr);align-items:center;gap:16px;padding:18px 20px}.certificate-row summary>span{display:grid;gap:4px}.certificate-row small{color:var(--muted)}.certificate-details{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 22px;margin:0;padding:18px 54px 22px;background:rgba(8,16,29,.22);border-top:1px solid var(--line)}.certificate-details dt{color:var(--muted);font-size:.7rem}.certificate-details dd{margin:5px 0 0;overflow-wrap:anywhere;font-size:.8rem}.readiness-panel{margin-top:18px}.issue-link{width:100%;border:0;background:transparent;color:var(--text);text-align:left;cursor:pointer}.issue-link:hover{background:var(--panel2)}@media(max-width:900px){#certificates-view .feature-summary{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:600px){.feature-toolbar{align-items:stretch;flex-direction:column}.feature-toolbar .row-actions{justify-content:stretch}.feature-toolbar .button{flex:1}.certificate-row summary{grid-template-columns:auto 1fr}.certificate-row summary>span:last-child{grid-column:2}.certificate-details{grid-template-columns:1fr;padding-left:52px}}
|
||||
.settings-panel{max-width:none}.log-filters{display:flex;align-items:end;gap:12px}.log-filters label{min-width:210px;margin:0}#log-host,#log-status{width:100%;height:44px;min-height:44px;box-sizing:border-box;padding:0 12px;line-height:42px}.certificate-row summary{cursor:pointer}.certificate-row summary:hover{background:rgba(98,230,167,.06)}.certificate-row summary:focus{outline:none}.certificate-row summary:focus-visible{outline:2px solid var(--green);outline-offset:-2px}.certificate-details .danger-text{color:var(--danger)}#log-last-checked{color:var(--muted)}@media(max-width:760px){.log-filters{align-items:stretch;flex-direction:column}.log-filters label{min-width:0}}
|
||||
.settings-panel{max-width:none}.log-filters{display:flex;align-items:end;gap:12px}.log-filters label{min-width:210px;margin:0}.dashboard-panel>.log-filters{margin-bottom:16px}#log-host,#log-status{width:100%;height:44px;min-height:44px;box-sizing:border-box;padding:0 12px;line-height:42px}.certificate-row summary{cursor:pointer}.certificate-row summary:hover{background:rgba(98,230,167,.06)}.certificate-row summary:focus{outline:none}.certificate-row summary:focus-visible{outline:2px solid var(--green);outline-offset:-2px}.certificate-details .danger-text{color:var(--danger)}#log-last-checked{color:var(--muted)}@media(max-width:760px){.log-filters{align-items:stretch;flex-direction:column}.log-filters label{min-width:0}}
|
||||
.access-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:18px}.access-card h2{margin-top:20px}.access-card-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:20px}.access-card-stats span{display:grid;gap:4px}.access-card-stats strong{font-size:1.15rem}.access-card-stats small{color:var(--muted);font-size:.68rem}#access-list{border:0;background:transparent;overflow:visible;padding:0}.group-card{min-height:0}
|
||||
.credential-editor{margin-top:18px;padding-top:16px;border-top:1px solid var(--line)}.credential-editor-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.credential-editor-heading strong{font-size:.9rem}.credential-editor>.muted{font-size:.75rem;margin:7px 0}.credential-row{display:grid;grid-template-columns:1fr 1fr auto;align-items:end;gap:8px;margin-top:9px}.credential-row input{margin-top:0}.credential-row .button{padding:10px 11px;font-size:.72rem}@media(max-width:600px){.credential-row{grid-template-columns:1fr 1fr}.credential-row .button{grid-column:2;justify-self:end}}
|
||||
#app input,#app select,#app textarea{box-sizing:border-box}#app select{height:44px;min-height:44px;padding-top:0;padding-bottom:0;line-height:42px}
|
||||
@@ -272,9 +273,10 @@ select{appearance:none!important;-webkit-appearance:none!important;background-re
|
||||
.performance-table{width:100%;border-collapse:collapse;font-size:.82rem;table-layout:fixed}
|
||||
.performance-table th,.performance-table td{padding:13px 15px;text-align:left;border-top:1px solid var(--line);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.performance-table thead th{border-top:0;color:var(--muted);font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;white-space:normal}
|
||||
.performance-table th:nth-child(1),.performance-table td:nth-child(1){width:32%}
|
||||
.performance-table th:nth-child(2),.performance-table td:nth-child(2){width:14%}
|
||||
.performance-table th:nth-child(3),.performance-table td:nth-child(3){width:14%}
|
||||
.performance-table th:nth-child(4),.performance-table td:nth-child(4){width:19%;text-align:center}
|
||||
.performance-table th:nth-child(5),.performance-table td:nth-child(5){width:21%}
|
||||
@media(max-width:760px){.performance-table th:nth-child(2),.performance-table td:nth-child(2),.performance-table th:nth-child(3),.performance-table td:nth-child(3){display:none}.performance-table th:nth-child(1),.performance-table td:nth-child(1){width:46%}.performance-table th:nth-child(4),.performance-table td:nth-child(4){width:27%}.performance-table th:nth-child(5),.performance-table td:nth-child(5){width:27%}}
|
||||
.performance-table th:nth-child(1),.performance-table td:nth-child(1){width:34%}
|
||||
.performance-table th:nth-child(2),.performance-table td:nth-child(2){width:20%;text-align:center}
|
||||
.performance-table th:nth-child(3),.performance-table td:nth-child(3){width:23%;text-align:center}
|
||||
.performance-table th:nth-child(4),.performance-table td:nth-child(4){width:23%;text-align:center}
|
||||
.performance-table .count-divider{color:var(--muted);margin:0 2px}
|
||||
.performance-table td .http-status.bad[title]{cursor:help;text-decoration:underline dotted;text-underline-offset:3px}
|
||||
@media(max-width:760px){.performance-table th:nth-child(2),.performance-table td:nth-child(2){display:none}.performance-table th:nth-child(1),.performance-table td:nth-child(1){width:40%}.performance-table th:nth-child(3),.performance-table td:nth-child(3){width:30%}.performance-table th:nth-child(4),.performance-table td:nth-child(4){width:30%}}
|
||||
|
||||
+3
-1
@@ -1223,10 +1223,12 @@ app.get("/api/performance", (req, res, next) => {
|
||||
const host = normalizeDomain(req.query.host);
|
||||
const hours = Math.min(Math.max(Number.parseInt(req.query.hours, 10) || 6, 1), 168);
|
||||
const bucketMinutes = hours > 24 ? 60 : 15;
|
||||
const breakdownByHost = new Map();
|
||||
for (const row of storage.performanceErrorBreakdown()) { if (!breakdownByHost.has(row.host)) breakdownByHost.set(row.host, []); breakdownByHost.get(row.host).push({ status: row.status, count: row.count }); }
|
||||
res.json({
|
||||
checkedAt: new Date().toISOString(),
|
||||
liveRequests: storage.performanceLiveCount(60),
|
||||
routes: storage.performanceRoutes().map(row => ({ host: row.host, hourRequests: row.hourRequests || 0, hourErrors: row.hourErrors || 0, hourAvgMs: row.hourAvgMs != null ? Math.round(row.hourAvgMs) : null, dayRequests: row.dayRequests || 0, dayErrors: row.dayErrors || 0, dayAvgMs: row.dayAvgMs != null ? Math.round(row.dayAvgMs) : null })),
|
||||
routes: storage.performanceRoutes().map(row => ({ host: row.host, hourRequests: row.hourRequests || 0, hourErrors: row.hourErrors || 0, hourAvgMs: row.hourAvgMs != null ? Math.round(row.hourAvgMs) : null, dayRequests: row.dayRequests || 0, dayErrors: row.dayErrors || 0, dayAvgMs: row.dayAvgMs != null ? Math.round(row.dayAvgMs) : null, errorBreakdown: (breakdownByHost.get(row.host) || []).slice(0, 3) })),
|
||||
trend: storage.performanceTrend(host, hours, bucketMinutes),
|
||||
hosts: [...new Set([...sites, ...proxies, ...redirects].flatMap(item => normalizeDomains(item.domain, item.domains)))].sort()
|
||||
});
|
||||
|
||||
+9
-1
@@ -122,6 +122,14 @@ export async function openStorage(dataDir, backupsDir) {
|
||||
GROUP BY host ORDER BY dayRequests DESC
|
||||
`).all(hourCutoff, hourCutoff, hourCutoff, instanceId, dayCutoff);
|
||||
}
|
||||
function performanceErrorBreakdown(instanceId = LOCAL_INSTANCE_ID) {
|
||||
const dayCutoff = new Date(Date.now() - 86400000).toISOString();
|
||||
return db.prepare(`
|
||||
SELECT host, status, COUNT(*) AS count
|
||||
FROM access_events WHERE instance_id=? AND at>=? AND status>=400 AND host IS NOT NULL AND host!=''
|
||||
GROUP BY host, status ORDER BY count DESC
|
||||
`).all(instanceId, dayCutoff);
|
||||
}
|
||||
function performanceTrend(host = "", hours = 6, bucketMinutes = 15, instanceId = LOCAL_INSTANCE_ID) {
|
||||
const bucketMs = Math.max(1, Number(bucketMinutes) || 15) * 60000;
|
||||
const windowMs = Math.max(1, Number(hours) || 6) * 3600000;
|
||||
@@ -162,5 +170,5 @@ export async function openStorage(dataDir, backupsDir) {
|
||||
}
|
||||
function humanizeGatewayErrors(instanceId = LOCAL_INSTANCE_ID) { const friendly = "Gateway configuration rejected: HTTP upstream cannot use HTTPS transport. Disable upstream TLS verification or change the upstream URL to HTTPS."; const activity = db.prepare("SELECT id FROM activity_events WHERE instance_id=? AND message LIKE '%upstream address scheme is HTTP but transport is configured for HTTP+TLS%'").all(instanceId); const updateActivity = db.prepare("UPDATE activity_events SET message=? WHERE id=?"); for (const row of activity) updateActivity.run(friendly, row.id); const audit = db.prepare("SELECT id FROM audit_events WHERE instance_id=? AND action LIKE '%upstream address scheme is HTTP but transport is configured for HTTP+TLS%'").all(instanceId); const updateAudit = db.prepare("UPDATE audit_events SET action=? WHERE id=?"); for (const row of audit) updateAudit.run(friendly, row.id); return activity.length + audit.length; }
|
||||
const result = integrity(); if (result.length !== 1 || result[0] !== "ok") { db.close(); throw new Error(`SQLite integrity check failed: ${result.join(", ")}`); }
|
||||
return { db, databasePath, isNew, snapshot, loadCollection, saveCollection, loadSettings, saveSettings, integrity, recordAudit, listAudit, recordActivity, listActivity, humanizeGatewayErrors, recordAccessEvents, listAccessEvents, pruneEvents, previewPruneEvents, backupTo, performanceLiveCount, performanceRoutes, performanceTrend, close: () => db.close() };
|
||||
return { db, databasePath, isNew, snapshot, loadCollection, saveCollection, loadSettings, saveSettings, integrity, recordAudit, listAudit, recordActivity, listActivity, humanizeGatewayErrors, recordAccessEvents, listAccessEvents, pruneEvents, previewPruneEvents, backupTo, performanceLiveCount, performanceRoutes, performanceErrorBreakdown, performanceTrend, close: () => db.close() };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user