diff options
| author | Your Name <you@example.com> | 2026-05-23 04:50:26 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 04:50:26 +0530 |
| commit | 9330b01c28aebc865a3c0a51df8730196cb4152e (patch) | |
| tree | 60c3ae35b2550c737c228e81fd342c8d07af11af /tollgate_core/include | |
| parent | 851801f50f1282ab1db5f8a241dbd245f59e447e (diff) | |
Phase 6a-6d: Consolidate and clean up
6a: Delete dead standalone tollgate_core/ (12 files, never compiled)
6b: Rewrite dns_server.c as thin shim to component's tollgate_core_dns
- Fix component DNS to bind to AP IP instead of INADDR_ANY
6c: Rewrite stratum_proxy.c as thin shim with struct cast to component types
6d: Move sandbox logic into component's tollgate_core_firewall
- Add tollgate_core_fw_set_sandbox_ports/set_sandbox_mint_access
- Add is_sandbox_allowed() to component's ip4_canforward_filter
- Clean main/firewall.c to delegate filter to component
- Remove redundant DNS auth double-calls from main firewall
Add ROADMAP.md with full extraction plan and checklists
All 21 unit tests pass. ESP-IDF build passes.
Diffstat (limited to 'tollgate_core/include')
| -rw-r--r-- | tollgate_core/include/tollgate_core.h | 90 | ||||
| -rw-r--r-- | tollgate_core/include/tollgate_platform.h | 68 |
2 files changed, 0 insertions, 158 deletions
diff --git a/tollgate_core/include/tollgate_core.h b/tollgate_core/include/tollgate_core.h deleted file mode 100644 index bbae7cf..0000000 --- a/tollgate_core/include/tollgate_core.h +++ /dev/null | |||
| @@ -1,90 +0,0 @@ | |||
| 1 | #ifndef TOLLGATE_CORE_H | ||
| 2 | #define TOLLGATE_CORE_H | ||
| 3 | |||
| 4 | #include "tollgate_platform.h" | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stdint.h> | ||
| 7 | |||
| 8 | int tollgate_core_init(const tollgate_platform_t *platform, uint32_t ap_ip); | ||
| 9 | void tollgate_core_tick(void); | ||
| 10 | |||
| 11 | int tollgate_core_dns_start(uint32_t upstream_dns); | ||
| 12 | void tollgate_core_dns_stop(void); | ||
| 13 | |||
| 14 | int tollgate_core_process_payment(uint32_t client_ip, const char *token_str); | ||
| 15 | int tollgate_core_process_share(uint32_t client_ip, const char *job_id, | ||
| 16 | const char *nonce, const char *ntime, const char *version); | ||
| 17 | |||
| 18 | void tollgate_core_client_connected(const uint8_t *mac, uint32_t client_ip); | ||
| 19 | void tollgate_core_client_disconnected(const uint8_t *mac); | ||
| 20 | |||
| 21 | bool tollgate_core_is_client_allowed(uint32_t client_ip); | ||
| 22 | bool tollgate_core_is_dns_running(void); | ||
| 23 | |||
| 24 | char *tollgate_core_get_status_json(void); | ||
| 25 | char *tollgate_core_get_config_json(void); | ||
| 26 | |||
| 27 | int tollgate_core_active_session_count(void); | ||
| 28 | int tollgate_core_allowed_client_count(void); | ||
| 29 | int tollgate_core_firewall_revoke_all(void); | ||
| 30 | void tollgate_core_firewall_set_mining_port(uint16_t port); | ||
| 31 | void tollgate_core_firewall_set_sandbox_mint_access(bool enable); | ||
| 32 | |||
| 33 | bool tollgate_core_is_owner(uint32_t client_ip); | ||
| 34 | bool tollgate_core_is_owner_connected(void); | ||
| 35 | |||
| 36 | double tollgate_core_get_hashprice(void); | ||
| 37 | void tollgate_core_set_nbits(uint32_t nbits); | ||
| 38 | const void *tollgate_core_get_current_job(void); | ||
| 39 | void tollgate_core_set_job(const void *job); | ||
| 40 | |||
| 41 | int tollgate_core_stratum_client_start(void); | ||
| 42 | void tollgate_core_stratum_client_stop(void); | ||
| 43 | |||
| 44 | int tollgate_core_stratum_proxy_init(uint16_t port); | ||
| 45 | void tollgate_core_stratum_proxy_get_stats(void *out); | ||
| 46 | |||
| 47 | void tollgate_core_mining_init(void); | ||
| 48 | |||
| 49 | void tollgate_core_beacon_start(void); | ||
| 50 | |||
| 51 | void tollgate_core_market_init(void); | ||
| 52 | void tollgate_core_market_on_scan_result(const void *ie_data, int ie_len, | ||
| 53 | const uint8_t *bssid, int rssi); | ||
| 54 | |||
| 55 | const void *tollgate_core_get_sessions_array(void); | ||
| 56 | int tollgate_core_get_sessions_array_size(void); | ||
| 57 | void *tollgate_core_find_session_by_ip(uint32_t ip); | ||
| 58 | void *tollgate_core_find_session_by_mac(const char *mac); | ||
| 59 | void *tollgate_core_session_create(uint32_t client_ip, uint64_t allotment_ms); | ||
| 60 | void *tollgate_core_session_create_bytes(uint32_t client_ip, uint64_t allotment_bytes); | ||
| 61 | void tollgate_core_session_extend(void *session, uint64_t additional_ms); | ||
| 62 | void tollgate_core_session_revoke(void *session); | ||
| 63 | int tollgate_core_session_add_bytes(uint32_t client_ip, uint64_t bytes); | ||
| 64 | bool tollgate_core_session_is_expired(const void *session); | ||
| 65 | |||
| 66 | void tollgate_core_firewall_grant(uint32_t client_ip); | ||
| 67 | void tollgate_core_firewall_revoke(uint32_t client_ip); | ||
| 68 | int tollgate_core_firewall_get_mac_for_ip(uint32_t client_ip, char *mac_out, int mac_out_size); | ||
| 69 | |||
| 70 | int tollgate_core_cashu_decode(const char *token_str, void *out); | ||
| 71 | int tollgate_core_cashu_check_states(const char *mint_url, const void *token, | ||
| 72 | void *states, int *state_count); | ||
| 73 | uint64_t tollgate_core_cashu_allotment(uint64_t amount, uint64_t price, uint64_t step_size); | ||
| 74 | bool tollgate_core_cashu_is_mint_accepted(const char *mint_url); | ||
| 75 | const char *tollgate_core_cashu_token_mint(const void *token); | ||
| 76 | uint64_t tollgate_core_cashu_token_amount(const void *token); | ||
| 77 | |||
| 78 | void tollgate_core_mining_update_hashrate(uint32_t client_ip, bool accepted); | ||
| 79 | const void *tollgate_core_mining_get_client_stats(uint32_t client_ip); | ||
| 80 | double tollgate_core_mining_get_hashprice(void); | ||
| 81 | uint64_t tollgate_core_mining_shares_to_allotment_ms(double hashrate, double hashprice, | ||
| 82 | int price, int step_ms); | ||
| 83 | uint64_t tollgate_core_mining_shares_to_allotment_bytes(double hashrate, double hashprice, | ||
| 84 | int price, int step_bytes); | ||
| 85 | void tollgate_core_mining_set_nbits(uint32_t nbits); | ||
| 86 | |||
| 87 | const tollgate_platform_t *tollgate_core_get_platform(void); | ||
| 88 | uint32_t tollgate_core_get_ap_ip(void); | ||
| 89 | |||
| 90 | #endif | ||
diff --git a/tollgate_core/include/tollgate_platform.h b/tollgate_core/include/tollgate_platform.h deleted file mode 100644 index b553a83..0000000 --- a/tollgate_core/include/tollgate_platform.h +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 1 | #ifndef TOLLGATE_PLATFORM_H | ||
| 2 | #define TOLLGATE_PLATFORM_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stddef.h> | ||
| 7 | |||
| 8 | typedef struct { | ||
| 9 | uint16_t (*get_price_sats)(void); | ||
| 10 | int32_t (*get_step_ms)(void); | ||
| 11 | int64_t (*get_step_bytes)(void); | ||
| 12 | const char* (*get_mint_url)(void); | ||
| 13 | const char* (*get_metric)(void); | ||
| 14 | |||
| 15 | int64_t (*get_time_ms)(void); | ||
| 16 | |||
| 17 | void (*log_info)(const char *tag, const char *fmt, ...); | ||
| 18 | void (*log_warn)(const char *tag, const char *fmt, ...); | ||
| 19 | void (*log_error)(const char *tag, const char *fmt, ...); | ||
| 20 | |||
| 21 | bool (*wallet_receive)(const char *token); | ||
| 22 | bool (*wallet_send)(uint64_t amount, char *buf, size_t buf_len); | ||
| 23 | uint64_t (*wallet_balance)(void); | ||
| 24 | |||
| 25 | int (*http_post)(const char *url, const char *headers, | ||
| 26 | const char *body, int body_len, | ||
| 27 | char *resp, int resp_len); | ||
| 28 | |||
| 29 | bool (*create_task)(void (*fn)(void*), void *arg, | ||
| 30 | const char *name, int stack_bytes, int priority); | ||
| 31 | |||
| 32 | int (*socket_udp)(void); | ||
| 33 | int (*socket_tcp)(void); | ||
| 34 | int (*socket_bind)(int fd, uint32_t ip, uint16_t port); | ||
| 35 | int (*socket_listen)(int fd, int backlog); | ||
| 36 | int (*socket_accept)(int fd, uint32_t *client_ip, uint16_t *client_port); | ||
| 37 | int (*socket_recvfrom)(int fd, void *buf, int len, | ||
| 38 | uint32_t *src_ip, uint16_t *src_port); | ||
| 39 | int (*socket_sendto)(int fd, const void *buf, int len, | ||
| 40 | uint32_t dest_ip, uint16_t dest_port); | ||
| 41 | int (*socket_read)(int fd, void *buf, int len); | ||
| 42 | int (*socket_write)(int fd, const void *buf, int len); | ||
| 43 | void (*socket_close)(int fd); | ||
| 44 | void (*socket_set_recv_timeout)(int fd, int ms); | ||
| 45 | |||
| 46 | bool (*get_sta_mac_ip_list)(void *list_out, int max, int *count_out); | ||
| 47 | bool (*set_vendor_ie)(bool enable, const void *ie_data, int ie_len); | ||
| 48 | int (*arp_get_mac)(uint32_t ip, uint8_t *mac_out); | ||
| 49 | void (*napt_enable)(uint32_t ip, bool enable); | ||
| 50 | |||
| 51 | bool (*mining_enabled)(void); | ||
| 52 | const char* (*get_stratum_host)(void); | ||
| 53 | uint16_t (*get_stratum_port)(void); | ||
| 54 | const char* (*get_stratum_user)(void); | ||
| 55 | const char* (*get_stratum_pass)(void); | ||
| 56 | uint16_t (*get_mining_port)(void); | ||
| 57 | uint64_t (*get_hashprice_override)(void); | ||
| 58 | |||
| 59 | void (*fill_random)(void *buf, int len); | ||
| 60 | |||
| 61 | int (*get_accepted_mint_count)(void); | ||
| 62 | const char* (*get_accepted_mint)(int index); | ||
| 63 | bool (*is_mint_reachable)(const char *mint_url); | ||
| 64 | bool (*mac_for_ip)(uint32_t ip, char *mac_out, int mac_out_size); | ||
| 65 | |||
| 66 | } tollgate_platform_t; | ||
| 67 | |||
| 68 | #endif | ||