diff --git a/db/c_nostr_relay.db-shm b/db/c_nostr_relay.db-shm index f3c0e56..4d80fe2 100644 Binary files a/db/c_nostr_relay.db-shm and b/db/c_nostr_relay.db-shm differ diff --git a/db/c_nostr_relay.db-wal b/db/c_nostr_relay.db-wal index 310a42b..87e7174 100644 Binary files a/db/c_nostr_relay.db-wal and b/db/c_nostr_relay.db-wal differ diff --git a/docs/config_schema_design.md b/docs/config_schema_design.md index 2c80f49..8c6d2a0 100644 --- a/docs/config_schema_design.md +++ b/docs/config_schema_design.md @@ -142,7 +142,7 @@ INSERT OR IGNORE INTO server_config (key, value, description, config_type, data_ ('relay_description', 'High-performance C Nostr relay with SQLite storage', 'Relay description', 'user', 'string', 0), ('relay_contact', '', 'Contact information', 'user', 'string', 0), ('relay_pubkey', '', 'Relay public key', 'user', 'string', 0), -('relay_software', 'https://github.com/laantungir/c-relay', 'Software URL', 'user', 'string', 0), +('relay_software', 'https://git.laantungir.net/laantungir/c-relay.git', 'Software URL', 'user', 'string', 0), ('relay_version', '0.2.0', 'Software version', 'user', 'string', 0), -- NIP-13 Proof of Work diff --git a/docs/file_config_design.md b/docs/file_config_design.md index 099d4e8..e08e25a 100644 --- a/docs/file_config_design.md +++ b/docs/file_config_design.md @@ -66,7 +66,7 @@ The configuration file contains a signed Nostr event (kind 33334) with relay con ["relay_contact", ""], ["relay_pubkey", ""], - ["relay_software", "https://github.com/laantungir/c-relay"], + ["relay_software", "https://git.laantungir.net/laantungir/c-relay.git"], ["relay_version", "0.2.0"], ["max_event_tags", "100"], diff --git a/relay.pid b/relay.pid index 42a4827..a1f85d6 100644 --- a/relay.pid +++ b/relay.pid @@ -1 +1 @@ -793733 +871512 diff --git a/src/config.c b/src/config.c index ae9793b..3bac140 100644 --- a/src/config.c +++ b/src/config.c @@ -721,7 +721,6 @@ cJSON* create_config_nostr_event(const char* privkey_hex) { static const default_config_t defaults[] = { // Administrative settings - {"admin_pubkey", ""}, {"admin_enabled", "false"}, // Server core settings @@ -734,7 +733,7 @@ cJSON* create_config_nostr_event(const char* privkey_hex) { {"relay_description", "High-performance C Nostr relay with SQLite storage"}, {"relay_contact", ""}, {"relay_pubkey", ""}, - {"relay_software", "https://github.com/teknari/c-relay"}, + {"relay_software", "https://git.laantungir.net/laantungir/c-relay.git"}, {"relay_version", "0.2.0"}, // NIP-13 Proof of Work @@ -776,7 +775,8 @@ cJSON* create_config_nostr_event(const char* privkey_hex) { const char* key = (const char*)sqlite3_column_text(stmt, 0); const char* value = (const char*)sqlite3_column_text(stmt, 1); - if (key && value) { + // Skip admin_pubkey since it's redundant (already in event.pubkey) + if (key && value && strcmp(key, "admin_pubkey") != 0) { cJSON* tag = cJSON_CreateArray(); cJSON_AddItemToArray(tag, cJSON_CreateString(key)); cJSON_AddItemToArray(tag, cJSON_CreateString(value)); @@ -978,7 +978,7 @@ int generate_config_file_if_missing(void) { cJSON* pubkey_obj = cJSON_GetObjectItem(event, "pubkey"); if (pubkey_obj && cJSON_IsString(pubkey_obj)) { const char* admin_pubkey = cJSON_GetStringValue(pubkey_obj); - if (set_database_config("relay_admin_pubkey", admin_pubkey, "system") == 0) { + if (set_database_config("admin_pubkey", admin_pubkey, "system") == 0) { log_info("Stored admin public key in configuration database"); printf(" Admin Public Key: %s\n", admin_pubkey); } else { diff --git a/src/config.h b/src/config.h index 61e788a..db609e2 100644 --- a/src/config.h +++ b/src/config.h @@ -26,9 +26,9 @@ #define RELAY_URL_MAX_LENGTH 256 #define RELAY_CONTACT_MAX_LENGTH 128 #define RELAY_PUBKEY_MAX_LENGTH 65 -#define DATABASE_PATH "db/c_nostr_relay.db" // Default configuration values (used as fallbacks if database config fails) +#define DEFAULT_DATABASE_PATH "db/c_nostr_relay.db" #define DEFAULT_PORT 8888 #define DEFAULT_HOST "127.0.0.1" #define MAX_CLIENTS 100 diff --git a/src/main.c b/src/main.c index c82c292..26a1fb2 100644 --- a/src/main.c +++ b/src/main.c @@ -1306,7 +1306,7 @@ void init_relay_info() { if (relay_software) { strncpy(g_relay_info.software, relay_software, sizeof(g_relay_info.software) - 1); } else { - strncpy(g_relay_info.software, "https://github.com/laantungir/c-relay", sizeof(g_relay_info.software) - 1); + strncpy(g_relay_info.software, "https://git.laantungir.net/laantungir/c-relay.git", sizeof(g_relay_info.software) - 1); } const char* relay_version = get_config_value("relay_version"); @@ -1940,13 +1940,21 @@ int validate_event_expiration(cJSON* event, char* error_message, size_t error_si // Initialize database connection int init_database() { - int rc = sqlite3_open(DATABASE_PATH, &g_db); + // Use configurable database path, falling back to default + const char* db_path = get_config_value("database_path"); + if (!db_path) { + db_path = DEFAULT_DATABASE_PATH; + } + + int rc = sqlite3_open(db_path, &g_db); if (rc != SQLITE_OK) { log_error("Cannot open database"); return -1; } - log_success("Database connection established"); + char success_msg[256]; + snprintf(success_msg, sizeof(success_msg), "Database connection established: %s", db_path); + log_success(success_msg); return 0; }