From c4ef71d673c9efae337c813b2313b09e3380a43d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Feb 2026 13:32:00 -0400 Subject: [PATCH] v1.2.2 - Add + to allowed subscription characters --- deploy_local.sh | 17 +++++------------ src/config.c | 30 ++++++++++++++++++++++++++++-- src/main.h | 4 ++-- src/subscriptions.c | 4 ++-- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/deploy_local.sh b/deploy_local.sh index c211875..6569e1b 100755 --- a/deploy_local.sh +++ b/deploy_local.sh @@ -1,19 +1,12 @@ #!/bin/bash +# Restart the service +sudo systemctl stop c-relay.service # Copy the binary to the deployment location -cp build/c_relay_x86 ~/Storage/c_relay/crelay - -# Copy the service file to systemd (use the main service file) -sudo cp systemd/c-relay.service /etc/systemd/system/c-relay-local.service - -# Reload systemd daemon to pick up the new service -sudo systemctl daemon-reload - -# Enable the service (if not already enabled) -sudo systemctl enable c-relay-local.service +cp build/c_relay_static_x86_64 ~/Storage/c_relay/crelay # Restart the service -sudo systemctl restart c-relay-local.service +sudo systemctl restart c-relay.service # Show service status -sudo systemctl status c-relay-local.service --no-pager -l +sudo systemctl status c-relay.service --no-pager -l diff --git a/src/config.c b/src/config.c index 391fded..2c3588a 100644 --- a/src/config.c +++ b/src/config.c @@ -2553,20 +2553,46 @@ int handle_kind_23456_unified(cJSON* event, char* error_message, size_t error_si snprintf(error_message, error_size, "error: failed to convert sender public key"); return -1; } + + DEBUG_LOG("=== NIP-44 DECRYPTION DEBUG (Level 5) ==="); + DEBUG_LOG("Relay privkey (first 16 chars): %.16s...", relay_privkey); + DEBUG_LOG("Sender pubkey: %s", sender_pubkey); + DEBUG_LOG("Content length: %zu", strlen(content)); + DEBUG_LOG("Content (first 100 chars): %.100s%s", content, strlen(content) > 100 ? "..." : ""); // Perform NIP-44 decryption (relay as recipient, admin as sender) + DEBUG_LOG("Calling nostr_nip44_decrypt..."); + DEBUG_LOG(" relay_privkey_bytes (first 8 bytes hex): %02x%02x%02x%02x%02x%02x%02x%02x...", + relay_privkey_bytes[0], relay_privkey_bytes[1], relay_privkey_bytes[2], relay_privkey_bytes[3], + relay_privkey_bytes[4], relay_privkey_bytes[5], relay_privkey_bytes[6], relay_privkey_bytes[7]); + DEBUG_LOG(" sender_pubkey_bytes (first 8 bytes hex): %02x%02x%02x%02x%02x%02x%02x%02x...", + sender_pubkey_bytes[0], sender_pubkey_bytes[1], sender_pubkey_bytes[2], sender_pubkey_bytes[3], + sender_pubkey_bytes[4], sender_pubkey_bytes[5], sender_pubkey_bytes[6], sender_pubkey_bytes[7]); + char decrypted_text[16384]; // Buffer for decrypted content (16KB) int decrypt_result = nostr_nip44_decrypt(relay_privkey_bytes, sender_pubkey_bytes, content, decrypted_text, sizeof(decrypted_text)); + DEBUG_LOG("nostr_nip44_decrypt returned: %d (NOSTR_SUCCESS=%d)", decrypt_result, NOSTR_SUCCESS); + // Clean up private key immediately after use memset(relay_privkey_bytes, 0, 32); free(relay_privkey); if (decrypt_result != NOSTR_SUCCESS) { - DEBUG_ERROR("error: NIP-44 decryption failed"); - snprintf(error_message, error_size, "error: NIP-44 decryption failed"); + DEBUG_ERROR("error: NIP-44 decryption failed with code %d", decrypt_result); + DEBUG_ERROR(" This means the encrypted content cannot be decrypted with the provided keys"); + DEBUG_ERROR(" Possible causes:"); + DEBUG_ERROR(" 1. Content was encrypted for a different relay pubkey"); + DEBUG_ERROR(" 2. Content format is incompatible (wrong NIP-44 version)"); + DEBUG_ERROR(" 3. Content is corrupted or malformed"); + snprintf(error_message, error_size, "error: NIP-44 decryption failed (code: %d)", decrypt_result); return -1; } + + DEBUG_LOG("✓ NIP-44 decryption successful!"); + DEBUG_LOG("Decrypted text length: %zu", strlen(decrypted_text)); + DEBUG_LOG("Decrypted text (first 200 chars): %.200s%s", decrypted_text, strlen(decrypted_text) > 200 ? "..." : ""); + DEBUG_LOG("=== END NIP-44 DECRYPTION DEBUG ==="); // Parse decrypted content as command array directly (NOT as NIP-17 inner event) // Kind 23456 events contain direct command arrays: ["command_name", arg1, arg2, ...] diff --git a/src/main.h b/src/main.h index 7357f78..810c5a6 100644 --- a/src/main.h +++ b/src/main.h @@ -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 1 -#define CRELAY_VERSION "v1.2.1" +#define CRELAY_VERSION_PATCH 2 +#define CRELAY_VERSION "v1.2.2" // Relay metadata (authoritative source for NIP-11 information) #define RELAY_NAME "C-Relay" diff --git a/src/subscriptions.c b/src/subscriptions.c index cfbeca2..4755af0 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -265,11 +265,11 @@ int validate_subscription_id(const char* sub_id) { return 0; // Empty or too long } - // Check for valid characters (alphanumeric, underscore, hyphen, colon, comma) + // Check for valid characters (alphanumeric, underscore, hyphen, colon, comma, plus) for (size_t i = 0; i < len; i++) { char c = sub_id[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || c == '_' || c == '-' || c == ':' || c == ',')) { + (c >= '0' && c <= '9') || c == '_' || c == '-' || c == ':' || c == ',' || c == '+')) { return 0; // Invalid character } }