Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1f712236a | ||
|
|
06e6c17b7b | ||
|
|
0751a7c55c |
@@ -112,6 +112,10 @@
|
||||
<td>Process ID</td>
|
||||
<td id="process-id">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WebSocket Connections</td>
|
||||
<td id="websocket-connections">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Active Subscriptions</td>
|
||||
<td id="active-subscriptions">-</td>
|
||||
|
||||
+28
-12
@@ -4492,6 +4492,9 @@ function updateStatsFromCpuMonitoringEvent(monitoringData) {
|
||||
if (monitoringData.process_id !== undefined) {
|
||||
updateStatsCell('process-id', monitoringData.process_id.toString());
|
||||
}
|
||||
if (monitoringData.active_connections !== undefined) {
|
||||
updateStatsCell('websocket-connections', monitoringData.active_connections.toString());
|
||||
}
|
||||
|
||||
if (monitoringData.memory_usage_mb !== undefined) {
|
||||
updateStatsCell('memory-usage', monitoringData.memory_usage_mb.toFixed(1) + ' MB');
|
||||
@@ -6206,7 +6209,7 @@ let ipBansCachedResults = null; // Cache last fetched results for client-side fi
|
||||
|
||||
// Load IP bans from database
|
||||
async function loadIpBans() {
|
||||
const query = "SELECT ip, failure_count, ban_count, banned_until, first_failure, has_authed_successfully, last_success_at, total_connections, total_failures, total_successes, first_seen FROM ip_bans ORDER BY banned_until DESC, total_failures DESC";
|
||||
const query = "SELECT ip, failure_count, ban_count, banned_until, first_failure, has_authed_successfully, last_success_at, total_connections, total_failures, total_successes, first_seen, idle_failure_count, idle_ban_count, idle_banned_until FROM ip_bans ORDER BY MAX(banned_until, idle_banned_until) DESC, total_failures DESC";
|
||||
await executeSqlQueryRaw(query, 'ip_bans_load');
|
||||
}
|
||||
|
||||
@@ -6255,20 +6258,22 @@ function handleIpBansResponse(responseData) {
|
||||
let currentlyBanned = 0;
|
||||
let totalBans = 0;
|
||||
|
||||
// Helper: is this row currently banned (auth or idle)
|
||||
const isRowBanned = row => (row.banned_until > now) || (row.idle_banned_until > now);
|
||||
const isRowExpired = row => !isRowBanned(row) && ((row.ban_count > 0) || (row.idle_ban_count > 0));
|
||||
|
||||
// Filter results based on current filter
|
||||
let filteredResults = results;
|
||||
if (ipBansFilter === 'banned') {
|
||||
filteredResults = results.filter(row => row.banned_until > now);
|
||||
filteredResults = results.filter(isRowBanned);
|
||||
} else if (ipBansFilter === 'expired') {
|
||||
filteredResults = results.filter(row => row.banned_until <= now && row.banned_until > 0);
|
||||
filteredResults = results.filter(isRowExpired);
|
||||
}
|
||||
|
||||
// Calculate stats
|
||||
// Calculate stats (include both auth and idle bans)
|
||||
results.forEach(row => {
|
||||
totalBans += parseInt(row.ban_count || 0);
|
||||
if (row.banned_until > now) {
|
||||
currentlyBanned++;
|
||||
}
|
||||
totalBans += parseInt(row.ban_count || 0) + parseInt(row.idle_ban_count || 0);
|
||||
if (isRowBanned(row)) currentlyBanned++;
|
||||
});
|
||||
|
||||
// Update stats
|
||||
@@ -6286,17 +6291,28 @@ function handleIpBansResponse(responseData) {
|
||||
// Render table
|
||||
const tbody = document.getElementById('ip-bans-tbody');
|
||||
tbody.innerHTML = filteredResults.map(row => {
|
||||
const isBanned = row.banned_until > now;
|
||||
const isBanned = isRowBanned(row);
|
||||
const isIdleBanned = row.idle_banned_until > now;
|
||||
const isAuthBanned = row.banned_until > now;
|
||||
const isWhitelisted = whitelistedIPs.has(row.ip);
|
||||
const status = isWhitelisted ? '⭐ Whitelisted' : (isBanned ? '🔴 Banned' : (row.ban_count > 0 ? '🟡 Expired' : '🟢 Clean'));
|
||||
const bannedUntil = row.banned_until > 0 ? new Date(row.banned_until * 1000).toLocaleString() : '-';
|
||||
let statusLabel;
|
||||
if (isWhitelisted) statusLabel = '⭐ Whitelisted';
|
||||
else if (isAuthBanned && isIdleBanned) statusLabel = '🔴 Banned (auth+idle)';
|
||||
else if (isAuthBanned) statusLabel = '🔴 Banned (auth)';
|
||||
else if (isIdleBanned) statusLabel = '🔴 Banned (idle)';
|
||||
else if ((row.ban_count > 0) || (row.idle_ban_count > 0)) statusLabel = '🟡 Expired';
|
||||
else statusLabel = '🟢 Clean';
|
||||
|
||||
// Show the later of the two ban expiry times
|
||||
const effectiveBannedUntil = Math.max(row.banned_until || 0, row.idle_banned_until || 0);
|
||||
const bannedUntil = effectiveBannedUntil > 0 ? new Date(effectiveBannedUntil * 1000).toLocaleString() : '-';
|
||||
const failures = row.total_failures || 0;
|
||||
const authedSuccessfully = row.has_authed_successfully ? '✅ Yes' : '❌ No';
|
||||
const connectionAttempts = row.total_connections || 0;
|
||||
|
||||
return `<tr>
|
||||
<td>${escapeHtml(row.ip)}</td>
|
||||
<td>${status}</td>
|
||||
<td>${statusLabel}</td>
|
||||
<td>${bannedUntil}</td>
|
||||
<td>${failures}</td>
|
||||
<td>${authedSuccessfully}</td>
|
||||
|
||||
@@ -13,6 +13,7 @@ extern void log_query_execution(const char* query_type, const char* sub_id,
|
||||
#include <pthread.h>
|
||||
#include <libwebsockets.h>
|
||||
#include <cjson/cJSON.h>
|
||||
extern int g_connection_count;
|
||||
#include <sqlite3.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -1291,6 +1292,9 @@ cJSON* query_cpu_metrics(void) {
|
||||
pid_t pid = getpid();
|
||||
cJSON_AddNumberToObject(cpu_stats, "process_id", (double)pid);
|
||||
|
||||
// Get active WebSocket connection count
|
||||
cJSON_AddNumberToObject(cpu_stats, "active_connections", (double)g_connection_count);
|
||||
|
||||
// Get memory usage from /proc/self/status
|
||||
FILE* mem_stat = fopen("/proc/self/status", "r");
|
||||
if (mem_stat) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
-2
@@ -13,8 +13,8 @@
|
||||
// Using CRELAY_ prefix to avoid conflicts with nostr_core_lib VERSION macros
|
||||
#define CRELAY_VERSION_MAJOR 1
|
||||
#define CRELAY_VERSION_MINOR 2
|
||||
#define CRELAY_VERSION_PATCH 43
|
||||
#define CRELAY_VERSION "v1.2.43"
|
||||
#define CRELAY_VERSION_PATCH 46
|
||||
#define CRELAY_VERSION "v1.2.46"
|
||||
|
||||
// Relay metadata (authoritative source for NIP-11 information)
|
||||
#define RELAY_NAME "C-Relay"
|
||||
|
||||
Reference in New Issue
Block a user