From 9330b01c28aebc865a3c0a51df8730196cb4152e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 23 May 2026 04:50:26 +0530 Subject: 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. --- tollgate_core/include/tollgate_core.h | 90 ------------------------------- tollgate_core/include/tollgate_platform.h | 68 ----------------------- 2 files changed, 158 deletions(-) delete mode 100644 tollgate_core/include/tollgate_core.h delete mode 100644 tollgate_core/include/tollgate_platform.h (limited to 'tollgate_core/include') 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 @@ -#ifndef TOLLGATE_CORE_H -#define TOLLGATE_CORE_H - -#include "tollgate_platform.h" -#include -#include - -int tollgate_core_init(const tollgate_platform_t *platform, uint32_t ap_ip); -void tollgate_core_tick(void); - -int tollgate_core_dns_start(uint32_t upstream_dns); -void tollgate_core_dns_stop(void); - -int tollgate_core_process_payment(uint32_t client_ip, const char *token_str); -int tollgate_core_process_share(uint32_t client_ip, const char *job_id, - const char *nonce, const char *ntime, const char *version); - -void tollgate_core_client_connected(const uint8_t *mac, uint32_t client_ip); -void tollgate_core_client_disconnected(const uint8_t *mac); - -bool tollgate_core_is_client_allowed(uint32_t client_ip); -bool tollgate_core_is_dns_running(void); - -char *tollgate_core_get_status_json(void); -char *tollgate_core_get_config_json(void); - -int tollgate_core_active_session_count(void); -int tollgate_core_allowed_client_count(void); -int tollgate_core_firewall_revoke_all(void); -void tollgate_core_firewall_set_mining_port(uint16_t port); -void tollgate_core_firewall_set_sandbox_mint_access(bool enable); - -bool tollgate_core_is_owner(uint32_t client_ip); -bool tollgate_core_is_owner_connected(void); - -double tollgate_core_get_hashprice(void); -void tollgate_core_set_nbits(uint32_t nbits); -const void *tollgate_core_get_current_job(void); -void tollgate_core_set_job(const void *job); - -int tollgate_core_stratum_client_start(void); -void tollgate_core_stratum_client_stop(void); - -int tollgate_core_stratum_proxy_init(uint16_t port); -void tollgate_core_stratum_proxy_get_stats(void *out); - -void tollgate_core_mining_init(void); - -void tollgate_core_beacon_start(void); - -void tollgate_core_market_init(void); -void tollgate_core_market_on_scan_result(const void *ie_data, int ie_len, - const uint8_t *bssid, int rssi); - -const void *tollgate_core_get_sessions_array(void); -int tollgate_core_get_sessions_array_size(void); -void *tollgate_core_find_session_by_ip(uint32_t ip); -void *tollgate_core_find_session_by_mac(const char *mac); -void *tollgate_core_session_create(uint32_t client_ip, uint64_t allotment_ms); -void *tollgate_core_session_create_bytes(uint32_t client_ip, uint64_t allotment_bytes); -void tollgate_core_session_extend(void *session, uint64_t additional_ms); -void tollgate_core_session_revoke(void *session); -int tollgate_core_session_add_bytes(uint32_t client_ip, uint64_t bytes); -bool tollgate_core_session_is_expired(const void *session); - -void tollgate_core_firewall_grant(uint32_t client_ip); -void tollgate_core_firewall_revoke(uint32_t client_ip); -int tollgate_core_firewall_get_mac_for_ip(uint32_t client_ip, char *mac_out, int mac_out_size); - -int tollgate_core_cashu_decode(const char *token_str, void *out); -int tollgate_core_cashu_check_states(const char *mint_url, const void *token, - void *states, int *state_count); -uint64_t tollgate_core_cashu_allotment(uint64_t amount, uint64_t price, uint64_t step_size); -bool tollgate_core_cashu_is_mint_accepted(const char *mint_url); -const char *tollgate_core_cashu_token_mint(const void *token); -uint64_t tollgate_core_cashu_token_amount(const void *token); - -void tollgate_core_mining_update_hashrate(uint32_t client_ip, bool accepted); -const void *tollgate_core_mining_get_client_stats(uint32_t client_ip); -double tollgate_core_mining_get_hashprice(void); -uint64_t tollgate_core_mining_shares_to_allotment_ms(double hashrate, double hashprice, - int price, int step_ms); -uint64_t tollgate_core_mining_shares_to_allotment_bytes(double hashrate, double hashprice, - int price, int step_bytes); -void tollgate_core_mining_set_nbits(uint32_t nbits); - -const tollgate_platform_t *tollgate_core_get_platform(void); -uint32_t tollgate_core_get_ap_ip(void); - -#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 @@ -#ifndef TOLLGATE_PLATFORM_H -#define TOLLGATE_PLATFORM_H - -#include -#include -#include - -typedef struct { - uint16_t (*get_price_sats)(void); - int32_t (*get_step_ms)(void); - int64_t (*get_step_bytes)(void); - const char* (*get_mint_url)(void); - const char* (*get_metric)(void); - - int64_t (*get_time_ms)(void); - - void (*log_info)(const char *tag, const char *fmt, ...); - void (*log_warn)(const char *tag, const char *fmt, ...); - void (*log_error)(const char *tag, const char *fmt, ...); - - bool (*wallet_receive)(const char *token); - bool (*wallet_send)(uint64_t amount, char *buf, size_t buf_len); - uint64_t (*wallet_balance)(void); - - int (*http_post)(const char *url, const char *headers, - const char *body, int body_len, - char *resp, int resp_len); - - bool (*create_task)(void (*fn)(void*), void *arg, - const char *name, int stack_bytes, int priority); - - int (*socket_udp)(void); - int (*socket_tcp)(void); - int (*socket_bind)(int fd, uint32_t ip, uint16_t port); - int (*socket_listen)(int fd, int backlog); - int (*socket_accept)(int fd, uint32_t *client_ip, uint16_t *client_port); - int (*socket_recvfrom)(int fd, void *buf, int len, - uint32_t *src_ip, uint16_t *src_port); - int (*socket_sendto)(int fd, const void *buf, int len, - uint32_t dest_ip, uint16_t dest_port); - int (*socket_read)(int fd, void *buf, int len); - int (*socket_write)(int fd, const void *buf, int len); - void (*socket_close)(int fd); - void (*socket_set_recv_timeout)(int fd, int ms); - - bool (*get_sta_mac_ip_list)(void *list_out, int max, int *count_out); - bool (*set_vendor_ie)(bool enable, const void *ie_data, int ie_len); - int (*arp_get_mac)(uint32_t ip, uint8_t *mac_out); - void (*napt_enable)(uint32_t ip, bool enable); - - bool (*mining_enabled)(void); - const char* (*get_stratum_host)(void); - uint16_t (*get_stratum_port)(void); - const char* (*get_stratum_user)(void); - const char* (*get_stratum_pass)(void); - uint16_t (*get_mining_port)(void); - uint64_t (*get_hashprice_override)(void); - - void (*fill_random)(void *buf, int len); - - int (*get_accepted_mint_count)(void); - const char* (*get_accepted_mint)(int index); - bool (*is_mint_reachable)(const char *mint_url); - bool (*mac_for_ip)(uint32_t ip, char *mac_out, int mac_out_size); - -} tollgate_platform_t; - -#endif -- cgit v1.2.3