diff options
| author | Your Name <you@example.com> | 2026-05-15 22:27:14 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-15 22:27:14 +0530 |
| commit | 1263d86314fc0760d9be8eea415ccecbc047a5eb (patch) | |
| tree | 778130f0beb59d52f68e0e5f11388bf4b1470130 /main/tollgate_main.c | |
| parent | a7d0a672d59bf8985a6fc0e61b49015fabd96513 (diff) | |
Phase 2 WIP: Cashu payment endpoints, session tracking, updated checklist
- Add cashu.c/h: Cashu token decode (cashuA/base64url), proof state check via mint API, allotment calculator
- Add session.c/h: time-based session management with allotment/expiry, spent secret tracking
- Add tollgate_api.c/h: HTTP server on :2121 with GET / (kind=10021 discovery), POST / (payment processing), /usage, /whoami
- Update captive portal HTML: replace Grant Free Access with Cashu token paste form + Pay & Connect button
- Update tollgate_main.c: wire in session manager, TollGate API, 1s session tick loop
- Add tests/phase2.mjs: Phase 2 test suite (discovery, invalid token, wrong mint, valid payment)
- Update CHECKLIST.md: reflect Phase 1 complete, Phase 2 in progress with known bugs
Known issues (not yet flashed):
- Stack overflow crash in httpd POST handler (need stack_size=16384 + heap allocations)
- cashu_decode_token uses 2KB stack buffer (needs heap alloc)
- Mint URL should be testnut.cashu.space (nofee.testnut has API compat issues)
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index 9eba61f..04f64b9 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include "dns_server.h" | 14 | #include "dns_server.h" |
| 15 | #include "captive_portal.h" | 15 | #include "captive_portal.h" |
| 16 | #include "firewall.h" | 16 | #include "firewall.h" |
| 17 | #include "session.h" | ||
| 18 | #include "tollgate_api.h" | ||
| 17 | 19 | ||
| 18 | #define MAX_STA_RETRY 5 | 20 | #define MAX_STA_RETRY 5 |
| 19 | #define AP_IP_ADDR "192.168.4.1" | 21 | #define AP_IP_ADDR "192.168.4.1" |
| @@ -105,9 +107,11 @@ static void start_services(void) | |||
| 105 | upstream_dns.addr = dns_addr->addr; | 107 | upstream_dns.addr = dns_addr->addr; |
| 106 | 108 | ||
| 107 | firewall_init(ap_ip_info.ip); | 109 | firewall_init(ap_ip_info.ip); |
| 110 | session_manager_init(); | ||
| 108 | 111 | ||
| 109 | dns_server_start(ap_ip_info.ip, upstream_dns); | 112 | dns_server_start(ap_ip_info.ip, upstream_dns); |
| 110 | captive_portal_start(); | 113 | captive_portal_start(); |
| 114 | tollgate_api_start(); | ||
| 111 | 115 | ||
| 112 | s_services_running = true; | 116 | s_services_running = true; |
| 113 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); | 117 | if (s_services_mutex) xSemaphoreGive(s_services_mutex); |
| @@ -123,6 +127,7 @@ static void stop_services(void) | |||
| 123 | } | 127 | } |
| 124 | 128 | ||
| 125 | captive_portal_stop(); | 129 | captive_portal_stop(); |
| 130 | tollgate_api_stop(); | ||
| 126 | dns_server_stop(); | 131 | dns_server_stop(); |
| 127 | firewall_disable_nat(); | 132 | firewall_disable_nat(); |
| 128 | firewall_revoke_all(); | 133 | firewall_revoke_all(); |
| @@ -218,4 +223,9 @@ void app_main(void) | |||
| 218 | ESP_ERROR_CHECK(esp_wifi_start()); | 223 | ESP_ERROR_CHECK(esp_wifi_start()); |
| 219 | 224 | ||
| 220 | ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection..."); | 225 | ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection..."); |
| 226 | |||
| 227 | while (1) { | ||
| 228 | vTaskDelay(pdMS_TO_TICKS(1000)); | ||
| 229 | session_tick(); | ||
| 230 | } | ||
| 221 | } | 231 | } |