upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/wifistr.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 02:31:19 +0530
committerYour Name <you@example.com>2026-05-19 02:32:41 +0530
commit81f2dc52dc42d01c89dff45a5407ec40b8863052 (patch)
tree15018c2438639ca89dc6d33a5144c10d0b1c2af0 /main/wifistr.c
parent75688d55b3c8d13c8c9a50da9668ec408f684cb3 (diff)
feat: local Nostr relay with relay selection, sync, and integration tests
Local Nostr relay (NIP-01) on port 4869 with LittleFS 4MB storage. All events published locally first, then synced to public relays via REQ-diff. Relay selection via NIP-11 HTTP probing with NIP-77 scoring and auto-failover. Components: - wisp_relay: 16-file local relay (ws_server, storage_engine, sub_manager, broadcaster, relay_validator, router, handlers, rate_limiter, nip11, deletion, flash_monitor, relay_types) - esp_littlefs: LittleFS VFS integration (git submodule) - negentropy: for future NIP-77 binary sync (git submodule) New source files: - local_relay.c/h: thin wrapper for relay init/start/publish - relay_selector.c/h: NIP-11 probe + scoring + auto-failover - sync_manager.c/h: REQ-diff sync (primary 30min, fallback 6h) Bug fixes: - config.c: use-after-free (cJSON_Delete before seed_relays/sync parsing) - local_relay: moved init to app_main for boot-time start (not gated on STA IP) Flash layout: 4MB LittleFS partition at 0x500000 for relay_store Test results (Board B, live hardware): - Smoke: ping + HTTP 4869 + NIP-11: PASS - NIP-11 info document: 10/11 PASS - WS pub/sub (connect, REQ/EOSE, EVENT/OK, CLOSE, concurrent): 6/6 PASS - Unit tests (relay_validator + relay_selector): 13/13 PASS Hardware test make targets in physical-router-test-automation/: - make relay-build, relay-flash-b, relay-test-smoke/nip11/pubsub/sync/full
Diffstat (limited to 'main/wifistr.c')
-rw-r--r--main/wifistr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main/wifistr.c b/main/wifistr.c
index bf03b4d..543aaf6 100644
--- a/main/wifistr.c
+++ b/main/wifistr.c
@@ -2,6 +2,7 @@
2#include "identity.h" 2#include "identity.h"
3#include "nostr_event.h" 3#include "nostr_event.h"
4#include "config.h" 4#include "config.h"
5#include "local_relay.h"
5#include "esp_log.h" 6#include "esp_log.h"
6#include "esp_tls.h" 7#include "esp_tls.h"
7#include "esp_crt_bundle.h" 8#include "esp_crt_bundle.h"
@@ -216,8 +217,13 @@ esp_err_t wifistr_publish(void)
216 217
217 ESP_LOGI(TAG, "Wifistr event: %s", event_json); 218 ESP_LOGI(TAG, "Wifistr event: %s", event_json);
218 219
220 esp_err_t local_ret = local_relay_publish(event_json, strlen(event_json));
221 if (local_ret == ESP_OK) {
222 ESP_LOGI(TAG, "Published to local relay");
223 }
224
219 const tollgate_config_t *cfg = tollgate_config_get(); 225 const tollgate_config_t *cfg = tollgate_config_get();
220 esp_err_t last_err = ESP_FAIL; 226 esp_err_t last_err = local_ret;
221 227
222 for (int i = 0; i < cfg->nostr_relay_count; i++) { 228 for (int i = 0; i < cfg->nostr_relay_count; i++) {
223 esp_err_t err = ws_send_to_relay(cfg->nostr_relays[i], event_json); 229 esp_err_t err = ws_send_to_relay(cfg->nostr_relays[i], event_json);