v0.7.11 - Got api back working after switching to static build

This commit is contained in:
Your Name
2025-10-12 14:54:02 -04:00
parent 34bb1c34a2
commit 49ffc3d99e
7 changed files with 106 additions and 189 deletions

View File

@@ -1343,8 +1343,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
return -1;
}
// DEBUG: Log that we're checking admin authorization
log_info("DEBUG: Checking admin event authorization");
// Step 1: Verify event kind is admin type
cJSON *kind_json = cJSON_GetObjectItem(event, "kind");
@@ -1380,12 +1378,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
// Compare with our relay pubkey
const char* relay_pubkey = get_config_value("relay_pubkey");
char debug_msg1[256];
snprintf(debug_msg1, sizeof(debug_msg1), "DEBUG: Relay pubkey from config: %.64s", relay_pubkey ? relay_pubkey : "NULL");
log_info(debug_msg1);
char debug_msg2[256];
snprintf(debug_msg2, sizeof(debug_msg2), "DEBUG: Event p tag value: %.64s", tag_value->valuestring);
log_info(debug_msg2);
if (relay_pubkey && strcmp(tag_value->valuestring, relay_pubkey) == 0) {
targets_this_relay = 1;
break;
@@ -1396,7 +1388,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
if (!targets_this_relay) {
// Admin event for different relay - not an error, just not for us
log_info("DEBUG: Admin event not targeting this relay");
snprintf(error_buffer, error_buffer_size, "Admin event not targeting this relay");
return -1;
}
@@ -1411,12 +1402,6 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
// Get admin pubkey from configuration
const char* admin_pubkey = get_config_value("admin_pubkey");
char debug_msg3[256];
snprintf(debug_msg3, sizeof(debug_msg3), "DEBUG: Admin pubkey from config: %.64s", admin_pubkey ? admin_pubkey : "NULL");
log_info(debug_msg3);
char debug_msg4[256];
snprintf(debug_msg4, sizeof(debug_msg4), "DEBUG: Event pubkey: %.64s", pubkey_json->valuestring);
log_info(debug_msg4);
if (!admin_pubkey || strlen(admin_pubkey) == 0) {
log_warning("Unauthorized admin event attempt: no admin pubkey configured");
snprintf(error_buffer, error_buffer_size, "Unauthorized admin event attempt: no admin configured");
@@ -1435,20 +1420,16 @@ int is_authorized_admin_event(cJSON* event, char* error_buffer, size_t error_buf
return -1;
}
log_info("DEBUG: Pubkey comparison passed");
// Step 4: Verify event signature
if (nostr_verify_event_signature(event) != 0) {
log_warning("Unauthorized admin event attempt: invalid signature");
log_info("DEBUG: Signature verification failed");
snprintf(error_buffer, error_buffer_size, "Unauthorized admin event attempt: signature verification failed");
return -1;
}
log_info("DEBUG: Signature verification passed");
// All checks passed - authorized admin event
log_info("DEBUG: Admin event authorization successful");
return 0;
}
@@ -1751,15 +1732,14 @@ int main(int argc, char* argv[]) {
return 1;
}
// DEBUG: Check config table row count before database initialization
// Check config table row count before database initialization
{
sqlite3* temp_db = NULL;
if (sqlite3_open(g_database_path, &temp_db) == SQLITE_OK) {
sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(temp_db, "SELECT COUNT(*) FROM config", -1, &stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(stmt) == SQLITE_ROW) {
int count = sqlite3_column_int(stmt, 0);
printf("[DEBUG] Config table row count before init_database(): %d\n", count);
// Row count check completed
}
sqlite3_finalize(stmt);
}
@@ -1780,13 +1760,12 @@ int main(int argc, char* argv[]) {
return 1;
}
// DEBUG: Check config table row count after database initialization
// Check config table row count after database initialization
{
sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(g_db, "SELECT COUNT(*) FROM config", -1, &stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(stmt) == SQLITE_ROW) {
int count = sqlite3_column_int(stmt, 0);
printf("[DEBUG] Config table row count after init_database(): %d\n", count);
// Row count check completed
}
sqlite3_finalize(stmt);
}
@@ -1807,7 +1786,8 @@ int main(int argc, char* argv[]) {
}
cJSON_Delete(config_event);
} else {
log_warning("No configuration event found in existing database");
// This is expected for relays using table-based configuration
// No longer a warning - just informational
}
// Ensure pubkeys are in config table for existing relay
@@ -1833,18 +1813,6 @@ int main(int argc, char* argv[]) {
// If either pubkey is missing, call add_pubkeys_to_config_table to populate both
if (need_to_add_pubkeys) {
// DEBUG: Check config table row count before add_pubkeys_to_config_table()
{
sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(g_db, "SELECT COUNT(*) FROM config", -1, &stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(stmt) == SQLITE_ROW) {
int count = sqlite3_column_int(stmt, 0);
printf("[DEBUG] Config table row count before add_pubkeys_to_config_table(): %d\n", count);
}
sqlite3_finalize(stmt);
}
}
if (add_pubkeys_to_config_table() != 0) {
log_error("Failed to add pubkeys to config table for existing relay");
cleanup_configuration_system();
@@ -1852,18 +1820,6 @@ int main(int argc, char* argv[]) {
close_database();
return 1;
}
// DEBUG: Check config table row count after add_pubkeys_to_config_table()
{
sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(g_db, "SELECT COUNT(*) FROM config", -1, &stmt, NULL) == SQLITE_OK) {
if (sqlite3_step(stmt) == SQLITE_ROW) {
int count = sqlite3_column_int(stmt, 0);
printf("[DEBUG] Config table row count after add_pubkeys_to_config_table(): %d\n", count);
}
sqlite3_finalize(stmt);
}
}
}
// Apply CLI overrides for existing relay (port override should work even for existing relays)