diff options
| author | Your Name <you@example.com> | 2026-05-23 22:09:57 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 22:09:57 +0530 |
| commit | bf8e095b94fe500a9c35d7f2f616eb85569dbe5e (patch) | |
| tree | c6bb9a2b11d20aff855cc324f1c3d60751629d1f /components/tollgate_core | |
| parent | aec549f83d5084aa9fd16c00e1c09e06ac7471d4 (diff) | |
Phase 10a v1.2.0: MIT license, metadata update, full API docs
- Bump idf_component.yml to v1.2.0 with MIT license, targets, tags
- Add LICENSE (MIT) for IDF Component Registry compatibility
- Update CHANGELOG.md with v1.2.0 entries (portal, stratum_client, mint_health, client)
- Update README.md with all 13 modules documented, API reference table
- Add REMAINING_PLAN.md with full execution plan and checklist
- 25 unit tests pass, ESP-IDF build passes
Diffstat (limited to 'components/tollgate_core')
| -rw-r--r-- | components/tollgate_core/CHANGELOG.md | 10 | ||||
| -rw-r--r-- | components/tollgate_core/LICENSE | 21 | ||||
| -rw-r--r-- | components/tollgate_core/README.md | 74 | ||||
| -rw-r--r-- | components/tollgate_core/idf_component.yml | 18 |
4 files changed, 110 insertions, 13 deletions
diff --git a/components/tollgate_core/CHANGELOG.md b/components/tollgate_core/CHANGELOG.md index b6d664f..946c600 100644 --- a/components/tollgate_core/CHANGELOG.md +++ b/components/tollgate_core/CHANGELOG.md | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | # Changelog | 1 | # Changelog |
| 2 | 2 | ||
| 3 | ## 1.2.0 (2026-05-23) | ||
| 4 | |||
| 5 | - Added `tollgate_core_portal` — HTML template rendering, usage calculation, captive URI detection | ||
| 6 | - Added `tollgate_core_stratum_client` — Stratum V1 JSON protocol parsing, message building (subscribe, authorize, submit, mining.notify, mining.set_difficulty) | ||
| 7 | - Added `tollgate_core_mint_health` — mint health state tracking with recovery threshold (3 consecutive successes), reachable/unreachable transitions | ||
| 8 | - Added `tollgate_core_client` — upstream TollGate discovery JSON parsing (kind 10021), session response parsing (kind 1022), usage string parsing, renewal threshold check, price-per-minute calculation | ||
| 9 | - Added MIT license for IDF Component Registry compatibility | ||
| 10 | - 13 compiled source files, 14 headers, full platform abstraction via `tollgate_platform_t` | ||
| 11 | - 25 host unit tests covering all modules | ||
| 12 | |||
| 3 | ## 1.1.0 (2026-05-23) | 13 | ## 1.1.0 (2026-05-23) |
| 4 | 14 | ||
| 5 | - Added `tollgate_core_beacon` — WiFi vendor IE construction (hash_mint, hash_npub, build_ie) | 15 | - Added `tollgate_core_beacon` — WiFi vendor IE construction (hash_mint, hash_npub, build_ie) |
diff --git a/components/tollgate_core/LICENSE b/components/tollgate_core/LICENSE new file mode 100644 index 0000000..fc72599 --- /dev/null +++ b/components/tollgate_core/LICENSE | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) 2024-2026 orangesync.tech | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | of this software and associated documentation files (the "Software"), to deal | ||
| 7 | in the Software without restriction, including without limitation the rights | ||
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | copies of the Software, and to permit persons to whom the Software is | ||
| 10 | furnished to do so, subject to the following conditions: | ||
| 11 | |||
| 12 | The above copyright notice and this permission notice shall be included in all | ||
| 13 | copies or substantial portions of the Software. | ||
| 14 | |||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | SOFTWARE. | ||
diff --git a/components/tollgate_core/README.md b/components/tollgate_core/README.md index d83d634..57bab4d 100644 --- a/components/tollgate_core/README.md +++ b/components/tollgate_core/README.md | |||
| @@ -4,14 +4,27 @@ ESP-IDF component providing paid WiFi hotspot logic with Cashu e-cash payments. | |||
| 4 | 4 | ||
| 5 | ## Features | 5 | ## Features |
| 6 | 6 | ||
| 7 | - **Session management** — time-based and bytes-based sessions with auto-expiry | 7 | ### Session & Payment |
| 8 | - **Cashu token processing** — decode Cashu e-cash tokens, calculate allotments, multi-mint support | 8 | - **Session management** (`tollgate_core_session`) — time-based and bytes-based sessions with auto-expiry, extension, and revocation |
| 9 | - **Per-client firewall** — whitelist-based NAT filtering with sandbox mode | 9 | - **Cashu token processing** (`tollgate_core_cashu`) — decode Cashu e-cash tokens, calculate allotments, multi-mint support, proof state checking |
| 10 | - **DNS server** — per-client DNS hijack/forward with DoT rejection | 10 | - **Per-client firewall** (`tollgate_core_firewall`) — whitelist-based NAT filtering with sandbox mode for unauthenticated clients |
| 11 | - **Mining payment** — Stratum share tracking, hashprice calculation, difficulty conversion | 11 | |
| 12 | - **Stratum proxy** — transparent TCP proxy for mining traffic with job management | 12 | ### Network |
| 13 | - **Beacon price** — WiFi vendor IE construction for price/mint/geohash advertising | 13 | - **DNS server** (`tollgate_core_dns`) — per-client DNS hijack/forward with DoT rejection |
| 14 | - **Market scanner** — discover and compare nearby TollGate prices | 14 | - **Stratum proxy** (`tollgate_core_stratum_proxy`) — transparent TCP proxy for mining traffic with job management |
| 15 | |||
| 16 | ### Mining | ||
| 17 | - **Mining payment** (`tollgate_core_mining`) — Stratum share tracking, hashprice calculation, difficulty conversion, share-to-allotment mapping | ||
| 18 | - **Stratum client** (`tollgate_core_stratum_client`) — Stratum V1 JSON protocol parsing (mining.notify, mining.set_difficulty), message construction (subscribe, authorize, submit) | ||
| 19 | |||
| 20 | ### Discovery & Market | ||
| 21 | - **Beacon price** (`tollgate_core_beacon`) — WiFi vendor IE construction for price/mint/geohash advertising | ||
| 22 | - **Market scanner** (`tollgate_core_market`) — discover and compare nearby TollGate prices via vendor IEs | ||
| 23 | - **Mint health** (`tollgate_core_mint_health`) — mint health state tracking with recovery threshold, reachable/unreachable transitions | ||
| 24 | |||
| 25 | ### Portal & Client | ||
| 26 | - **Portal rendering** (`tollgate_core_portal`) — HTML template rendering with multi-key substitution, usage calculation, captive URI detection | ||
| 27 | - **TollGate client** (`tollgate_core_client`) — upstream TollGate discovery JSON parsing, session/usage response parsing, renewal threshold logic, price comparison | ||
| 15 | 28 | ||
| 16 | ## Integration | 29 | ## Integration |
| 17 | 30 | ||
| @@ -26,7 +39,15 @@ static tollgate_platform_t platform = { | |||
| 26 | .get_mint_url = my_get_mint_url, | 39 | .get_mint_url = my_get_mint_url, |
| 27 | .get_metric = my_get_metric, | 40 | .get_metric = my_get_metric, |
| 28 | .get_time_ms = my_get_time_ms, | 41 | .get_time_ms = my_get_time_ms, |
| 29 | // ... other callbacks | 42 | .spend_proofs = my_spend_proofs, |
| 43 | .get_stratum_url = my_get_stratum_url, | ||
| 44 | .get_stratum_port = my_get_stratum_port, | ||
| 45 | .get_stratum_user = my_get_stratum_user, | ||
| 46 | .get_stratum_pass = my_get_stratum_pass, | ||
| 47 | .get_mining_port = my_get_mining_port, | ||
| 48 | .get_hashprice_sats_per_ghs_day = my_get_hashprice, | ||
| 49 | .on_share_accepted = my_on_share_accepted, | ||
| 50 | .get_hashrate = my_get_hashrate, | ||
| 30 | }; | 51 | }; |
| 31 | ``` | 52 | ``` |
| 32 | 53 | ||
| @@ -54,9 +75,40 @@ tollgate_core_process_payment(client_ip, cashu_token_string); | |||
| 54 | 75 | ||
| 55 | Call `tollgate_core_tick()` periodically (e.g., every second) to expire sessions. | 76 | Call `tollgate_core_tick()` periodically (e.g., every second) to expire sessions. |
| 56 | 77 | ||
| 78 | ### 5. Use sub-modules directly | ||
| 79 | |||
| 80 | ```c | ||
| 81 | #include "tollgate_core_portal.h" | ||
| 82 | char *html = tollgate_core_portal_render(template, subs, nsubs); | ||
| 83 | |||
| 84 | #include "tollgate_core_stratum_client.h" | ||
| 85 | tollgate_core_stratum_build_subscribe(buf, size, req_id); | ||
| 86 | |||
| 87 | #include "tollgate_core_mint_health.h" | ||
| 88 | tollgate_core_mint_health_update(&state, idx, probe_ok, status, err, time); | ||
| 89 | |||
| 90 | #include "tollgate_core_client.h" | ||
| 91 | bool renew = tollgate_core_client_should_renew(remaining, allotment, threshold); | ||
| 92 | ``` | ||
| 93 | |||
| 57 | ## API Reference | 94 | ## API Reference |
| 58 | 95 | ||
| 59 | See `include/tollgate_core.h` for the public API and `include/tollgate_platform.h` for platform callbacks. | 96 | | Header | Description | |
| 97 | |--------|-------------| | ||
| 98 | | `tollgate_core.h` | Main API: init, process_payment, tick, status queries | | ||
| 99 | | `tollgate_platform.h` | Platform callback struct definition | | ||
| 100 | | `tollgate_core_session.h` | Session create/find/extend/revoke | | ||
| 101 | | `tollgate_core_cashu.h` | Token decode, checkstate, allotment | | ||
| 102 | | `tollgate_core_firewall.h` | Client grant/revoke, sandbox ports | | ||
| 103 | | `tollgate_core_dns.h` | DNS start/stop | | ||
| 104 | | `tollgate_core_mining.h` | Share tracking, hashprice, difficulty | | ||
| 105 | | `tollgate_core_stratum_proxy.h` | Proxy init/stop, job management | | ||
| 106 | | `tollgate_core_beacon.h` | IE construction, mint/npub hashing | | ||
| 107 | | `tollgate_core_market.h` | Market table, price comparison | | ||
| 108 | | `tollgate_core_portal.h` | Template rendering, usage calc, captive URIs | | ||
| 109 | | `tollgate_core_stratum_client.h` | Stratum V1 protocol parsing | | ||
| 110 | | `tollgate_core_mint_health.h` | Mint health state tracking | | ||
| 111 | | `tollgate_core_client.h` | Discovery/session parsing, renewal logic | | ||
| 60 | 112 | ||
| 61 | ## Dependencies | 113 | ## Dependencies |
| 62 | 114 | ||
| @@ -68,4 +120,4 @@ See `include/tollgate_core.h` for the public API and `include/tollgate_platform. | |||
| 68 | 120 | ||
| 69 | ## License | 121 | ## License |
| 70 | 122 | ||
| 71 | Proprietary — see repository for details. | 123 | MIT — see [LICENSE](LICENSE). |
diff --git a/components/tollgate_core/idf_component.yml b/components/tollgate_core/idf_component.yml index cdf2ee3..05337d3 100644 --- a/components/tollgate_core/idf_component.yml +++ b/components/tollgate_core/idf_component.yml | |||
| @@ -1,11 +1,25 @@ | |||
| 1 | version: "1.1.0" | 1 | version: "1.2.0" |
| 2 | description: | | 2 | description: | |
| 3 | TollGate core component for paid WiFi hotspots with Cashu e-cash payments. | 3 | TollGate core component for paid WiFi hotspots with Cashu e-cash payments. |
| 4 | Provides session management, per-client DNS/firewall, Cashu token processing, | 4 | Provides session management, per-client DNS/firewall, Cashu token processing, |
| 5 | mining payment tracking, beacon price advertising, and market scanning. | 5 | mining payment tracking, beacon price advertising, market scanning, |
| 6 | portal template rendering, Stratum protocol parsing, mint health tracking, | ||
| 7 | and upstream TollGate client logic. | ||
| 6 | Platform-agnostic via tollgate_platform_t callbacks for easy integration | 8 | Platform-agnostic via tollgate_platform_t callbacks for easy integration |
| 7 | with any ESP32 firmware (TollGate, NerdQAxePlus, BitAxe, etc.). | 9 | with any ESP32 firmware (TollGate, NerdQAxePlus, BitAxe, etc.). |
| 8 | url: https://git.orangesync.tech/npub12m5exm2uk3xa674cc5r0hlyvccs5xxn7qv83ezuteefv5972nquq4j4szl/esp32-tollgate | 10 | url: https://git.orangesync.tech/npub12m5exm2uk3xa674cc5r0hlyvccs5xxn7qv83ezuteefv5972nquq4j4szl/esp32-tollgate |
| 11 | license: "MIT" | ||
| 12 | targets: | ||
| 13 | - esp32s3 | ||
| 14 | tags: | ||
| 15 | - wifi | ||
| 16 | - hotspot | ||
| 17 | - cashu | ||
| 18 | - payment | ||
| 19 | - mining | ||
| 20 | - captive-portal | ||
| 21 | - stratum | ||
| 22 | - nostr | ||
| 9 | dependencies: | 23 | dependencies: |
| 10 | idf: | 24 | idf: |
| 11 | version: ">=5.3.0" | 25 | version: ">=5.3.0" |