v1.2.28 - Add debug_level config setting: live update every 60s without restart, default 0

This commit is contained in:
Your Name
2026-02-24 08:56:32 -04:00
parent c96736fa6a
commit d08f4e4221
5 changed files with 28 additions and 2 deletions
+14
View File
@@ -952,6 +952,20 @@ static int validate_config_field(const char* key, const char* value, char* error
return 0;
}
// Debug level (0-5)
if (strcmp(key, "debug_level") == 0) {
if (!is_valid_positive_integer(value) && strcmp(value, "0") != 0) {
snprintf(error_msg, error_size, "invalid debug_level '%s' (must be 0-5)", value);
return -1;
}
int val = atoi(value);
if (val < 0 || val > 5) {
snprintf(error_msg, error_size, "debug_level '%s' out of range (0-5)", value);
return -1;
}
return 0;
}
// IP auth failure ban settings
if (strcmp(key, "auth_fail_ban_enabled") == 0) {
if (!is_valid_boolean(value)) {
+4
View File
@@ -83,6 +83,10 @@ static const struct {
// IP-based rate limiting or access control (which would require firewall protection anyway)
{"trust_proxy_headers", "true"},
// Debug Level (0=none, 1=errors, 2=warnings, 3=info, 4=debug, 5=trace)
// Can be changed at runtime without restart via config_set admin command
{"debug_level", "0"},
// IP Auth Failure Ban Settings
// Ban IPs that repeatedly fail NIP-42 authentication
{"auth_fail_ban_enabled", "true"},
+2 -2
View File
@@ -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 27
#define CRELAY_VERSION "v1.2.27"
#define CRELAY_VERSION_PATCH 28
#define CRELAY_VERSION "v1.2.28"
// Relay metadata (authoritative source for NIP-11 information)
#define RELAY_NAME "C-Relay"
+8
View File
@@ -2497,6 +2497,14 @@ int start_websocket_relay(int port_override, int strict_port) {
int max_connection_seconds = get_config_int("max_connection_seconds", 86400);
if (current_time - last_connection_age_check >= 60) {
last_connection_age_check = current_time;
// Live debug level update: read from config table so it can be changed
// without restarting the relay (via config_set admin command or direct SQL)
int config_debug_level = get_config_int("debug_level", -1);
if (config_debug_level >= 0 && config_debug_level != g_debug_level) {
DEBUG_WARN("Debug level changed: %d -> %d", g_debug_level, config_debug_level);
g_debug_level = config_debug_level;
}
if (max_connection_seconds > 0) {
check_connection_age(max_connection_seconds);
} else {