v0.7.6 - Delete more old debugging prints
This commit is contained in:
29
src/main.c
29
src/main.c
@@ -219,13 +219,11 @@ void update_subscription_manager_config(void) {
|
||||
"Subscription limits: max_per_client=%d, max_total=%d",
|
||||
g_subscription_manager.max_subscriptions_per_client,
|
||||
g_subscription_manager.max_total_subscriptions);
|
||||
log_info(config_msg);
|
||||
}
|
||||
|
||||
// Signal handler for graceful shutdown
|
||||
void signal_handler(int sig) {
|
||||
if (sig == SIGINT || sig == SIGTERM) {
|
||||
log_info("Received shutdown signal");
|
||||
g_server_running = 0;
|
||||
}
|
||||
}
|
||||
@@ -287,10 +285,6 @@ int init_database(const char* database_path_override) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
char success_msg[256];
|
||||
snprintf(success_msg, sizeof(success_msg), "Database connection established: %s", db_path);
|
||||
log_success(success_msg);
|
||||
|
||||
// Check if database is already initialized by looking for the events table
|
||||
const char* check_sql = "SELECT name FROM sqlite_master WHERE type='table' AND name='events'";
|
||||
sqlite3_stmt* check_stmt;
|
||||
@@ -367,7 +361,6 @@ int init_database(const char* database_path_override) {
|
||||
if (error_msg) sqlite3_free(error_msg);
|
||||
return -1;
|
||||
}
|
||||
log_success("Created auth_rules table");
|
||||
|
||||
// Add indexes for auth_rules table
|
||||
const char* create_auth_rules_indexes_sql =
|
||||
@@ -385,7 +378,6 @@ int init_database(const char* database_path_override) {
|
||||
if (index_error_msg) sqlite3_free(index_error_msg);
|
||||
return -1;
|
||||
}
|
||||
log_success("Created auth_rules indexes");
|
||||
} else {
|
||||
// auth_rules table already exists, skipping creation
|
||||
}
|
||||
@@ -406,7 +398,6 @@ int init_database(const char* database_path_override) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_success("Database migration to v6 completed successfully");
|
||||
}
|
||||
} else {
|
||||
// Initialize database schema using embedded SQL
|
||||
@@ -425,7 +416,6 @@ int init_database(const char* database_path_override) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_success("Database schema initialized successfully");
|
||||
}
|
||||
} else {
|
||||
log_error("Failed to check existing database schema");
|
||||
@@ -440,7 +430,6 @@ void close_database() {
|
||||
if (g_db) {
|
||||
sqlite3_close(g_db);
|
||||
g_db = NULL;
|
||||
log_info("Database connection closed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,7 +660,6 @@ int store_event(cJSON* event) {
|
||||
}
|
||||
|
||||
free(tags_json);
|
||||
log_success("Event stored in database");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1159,7 +1147,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
|
||||
cJSON *tags = cJSON_GetObjectItem(event, "tags");
|
||||
if (!tags || !cJSON_IsArray(tags)) {
|
||||
// No tags array - treat as regular event for different relay
|
||||
log_info("Admin event has no tags array - treating as event for different relay");
|
||||
snprintf(error_buffer, error_buffer_size, "Admin event not targeting this relay (no tags)");
|
||||
return -1;
|
||||
}
|
||||
@@ -1226,7 +1213,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
|
||||
}
|
||||
|
||||
// All checks passed - authorized admin event
|
||||
log_info("Admin event authorization successful");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1323,7 +1309,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
char port_msg[128];
|
||||
snprintf(port_msg, sizeof(port_msg), "Port override specified: %d", cli_options.port_override);
|
||||
log_info(port_msg);
|
||||
} else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--admin-pubkey") == 0) {
|
||||
// Admin public key override option
|
||||
if (i + 1 >= argc) {
|
||||
@@ -1354,7 +1339,6 @@ int main(int argc, char* argv[]) {
|
||||
cli_options.admin_pubkey_override[sizeof(cli_options.admin_pubkey_override) - 1] = '\0';
|
||||
i++; // Skip the key argument
|
||||
|
||||
log_info("Admin public key override specified");
|
||||
} else if (strcmp(argv[i], "-r") == 0 || strcmp(argv[i], "--relay-privkey") == 0) {
|
||||
// Relay private key override option
|
||||
if (i + 1 >= argc) {
|
||||
@@ -1385,11 +1369,9 @@ int main(int argc, char* argv[]) {
|
||||
cli_options.relay_privkey_override[sizeof(cli_options.relay_privkey_override) - 1] = '\0';
|
||||
i++; // Skip the key argument
|
||||
|
||||
log_info("Relay private key override specified");
|
||||
} else if (strcmp(argv[i], "--strict-port") == 0) {
|
||||
// Strict port mode option
|
||||
cli_options.strict_port = 1;
|
||||
log_info("Strict port mode enabled - will fail if exact port is unavailable");
|
||||
} else {
|
||||
log_error("Unknown argument. Use --help for usage information.");
|
||||
print_usage(argv[0]);
|
||||
@@ -1412,7 +1394,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Check if this is first-time startup or existing relay
|
||||
if (is_first_time_startup()) {
|
||||
log_info("First-time startup detected");
|
||||
|
||||
// Initialize event-based configuration system
|
||||
if (init_configuration_system(NULL, NULL) != 0) {
|
||||
@@ -1446,7 +1427,6 @@ int main(int argc, char* argv[]) {
|
||||
nostr_cleanup();
|
||||
return 1;
|
||||
}
|
||||
log_success("Relay private key stored securely in database");
|
||||
} else {
|
||||
log_error("Relay private key not available from first-time startup");
|
||||
cleanup_configuration_system();
|
||||
@@ -1477,7 +1457,6 @@ int main(int argc, char* argv[]) {
|
||||
close_database();
|
||||
return 1;
|
||||
}
|
||||
log_info("Applied port override from command line");
|
||||
printf(" Port: %d (overriding default)\n", cli_options.port_override);
|
||||
}
|
||||
|
||||
@@ -1490,18 +1469,15 @@ int main(int argc, char* argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
log_success("Configuration populated directly in config table after database initialization");
|
||||
|
||||
// Now store the pubkeys in config table since database is available
|
||||
const char* admin_pubkey = get_admin_pubkey_cached();
|
||||
const char* relay_pubkey_from_cache = get_relay_pubkey_cached();
|
||||
if (admin_pubkey && strlen(admin_pubkey) == 64) {
|
||||
set_config_value_in_table("admin_pubkey", admin_pubkey, "string", "Administrator public key", "authentication", 0);
|
||||
log_success("Admin pubkey stored in config table for first-time startup");
|
||||
}
|
||||
if (relay_pubkey_from_cache && strlen(relay_pubkey_from_cache) == 64) {
|
||||
set_config_value_in_table("relay_pubkey", relay_pubkey_from_cache, "string", "Relay public key", "relay", 0);
|
||||
log_success("Relay pubkey stored in config table for first-time startup");
|
||||
}
|
||||
} else {
|
||||
// Find existing database file
|
||||
@@ -1569,7 +1545,6 @@ int main(int argc, char* argv[]) {
|
||||
if (apply_configuration_from_event(config_event) != 0) {
|
||||
log_warning("Failed to apply configuration from database");
|
||||
} else {
|
||||
log_success("Configuration loaded from database");
|
||||
|
||||
// Extract admin pubkey from the config event and store in config table for unified cache access
|
||||
cJSON* pubkey_obj = cJSON_GetObjectItem(config_event, "pubkey");
|
||||
@@ -1600,7 +1575,6 @@ int main(int argc, char* argv[]) {
|
||||
close_database();
|
||||
return 1;
|
||||
}
|
||||
log_info("Applied port override from command line for existing relay");
|
||||
printf(" Port: %d (overriding configured port)\n", cli_options.port_override);
|
||||
}
|
||||
|
||||
@@ -1631,7 +1605,6 @@ int main(int argc, char* argv[]) {
|
||||
close_database();
|
||||
return 1;
|
||||
}
|
||||
log_success("Unified request validator initialized");
|
||||
|
||||
// Initialize NIP-11 relay information
|
||||
init_relay_info();
|
||||
@@ -1645,7 +1618,6 @@ int main(int argc, char* argv[]) {
|
||||
// Update subscription manager configuration
|
||||
update_subscription_manager_config();
|
||||
|
||||
log_info("Starting relay server...");
|
||||
|
||||
// Start WebSocket Nostr relay server (port from configuration)
|
||||
int result = start_websocket_relay(-1, cli_options.strict_port); // Let config system determine port, pass strict_port flag
|
||||
@@ -1658,7 +1630,6 @@ int main(int argc, char* argv[]) {
|
||||
close_database();
|
||||
|
||||
if (result == 0) {
|
||||
log_success("Server shutdown complete");
|
||||
} else {
|
||||
log_error("Server shutdown with errors");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user