Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa17aa1f78 | ||
|
|
7e560b4247 |
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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"],
|
||||
|
||||
50
relay.log
50
relay.log
@@ -1,50 +0,0 @@
|
||||
[34m[1m=== C Nostr Relay Server ===[0m
|
||||
[32m[SUCCESS][0m Database connection established
|
||||
[34m[INFO][0m Initializing configuration system...
|
||||
[34m[INFO][0m Configuration directory: %s
|
||||
/home/teknari/.config/c-relay
|
||||
[34m[INFO][0m Configuration file: %s
|
||||
/home/teknari/.config/c-relay/c_relay_config_event.json
|
||||
[34m[INFO][0m Initializing configuration database statements...
|
||||
[32m[SUCCESS][0m Configuration database statements initialized
|
||||
[34m[INFO][0m Generating missing configuration file...
|
||||
[34m[INFO][0m Using private key from environment variable
|
||||
[34m[INFO][0m Creating configuration Nostr event...
|
||||
[32m[SUCCESS][0m Configuration Nostr event created successfully
|
||||
Event ID: 03021d58b91941a3bb9284ee704e069c50c9ac09a20eb049d8de676757dde83a
|
||||
Public Key: 8d8fbfb027872f13ed09e9e61f1d09473f3bec24bcfa9183e76cc1ceb789eb5e
|
||||
[34m[INFO][0m Stored admin public key in configuration database
|
||||
Admin Public Key: 8d8fbfb027872f13ed09e9e61f1d09473f3bec24bcfa9183e76cc1ceb789eb5e
|
||||
[32m[SUCCESS][0m Configuration file written successfully
|
||||
File: /home/teknari/.config/c-relay/c_relay_config_event.json
|
||||
[32m[SUCCESS][0m Configuration file generated successfully
|
||||
[34m[INFO][0m Loading configuration from all sources...
|
||||
[34m[INFO][0m Configuration file found, attempting to load...
|
||||
[34m[INFO][0m Loading configuration from file...
|
||||
[34m[INFO][0m Validating configuration event...
|
||||
[34m[INFO][0m Configuration event structure validation passed
|
||||
[34m[INFO][0m Configuration tags validation passed (%d tags)
|
||||
Found 27 configuration tags
|
||||
[33m[WARNING][0m Signature verification not yet implemented - accepting event
|
||||
[32m[SUCCESS][0m Applied configuration from file
|
||||
Applied 27 configuration values
|
||||
[32m[SUCCESS][0m Configuration event validation and application completed
|
||||
[32m[SUCCESS][0m Configuration loaded from file successfully
|
||||
[32m[SUCCESS][0m File configuration loaded successfully
|
||||
[34m[INFO][0m Loading configuration from database...
|
||||
[32m[SUCCESS][0m Database configuration validated (%d entries)
|
||||
Found 27 configuration entries
|
||||
[32m[SUCCESS][0m Database configuration loaded
|
||||
[34m[INFO][0m Applying configuration to global variables...
|
||||
[32m[SUCCESS][0m Configuration applied to global variables
|
||||
[32m[SUCCESS][0m Configuration system initialized successfully
|
||||
[32m[SUCCESS][0m Relay information initialized with default values
|
||||
[34m[INFO][0m Initializing NIP-13 Proof of Work configuration
|
||||
[34m[INFO][0m PoW configured in basic validation mode
|
||||
[34m[INFO][0m PoW Configuration: enabled=true, min_difficulty=0, validation_flags=0x1, mode=full
|
||||
[34m[INFO][0m Initializing NIP-40 Expiration Timestamp configuration
|
||||
[34m[INFO][0m Expiration Configuration: enabled=true, strict_mode=true, filter_responses=true, grace_period=300 seconds
|
||||
[34m[INFO][0m Subscription limits: max_per_client=25, max_total=5000
|
||||
[34m[INFO][0m Starting relay server...
|
||||
[34m[INFO][0m Starting libwebsockets-based Nostr relay server...
|
||||
[32m[SUCCESS][0m WebSocket relay started on ws://127.0.0.1:8888
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
14
src/main.c
14
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user