upleb.uk

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

summaryrefslogtreecommitdiff
path: root/components/tollgate_core
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-29 00:28:27 +0530
committerYour Name <you@example.com>2026-05-29 00:28:27 +0530
commit57bcd53b14e1f795aa94b079c463d41ba8c02e94 (patch)
treec7097430ecf961846c58931b897a63937f6cc1e1 /components/tollgate_core
parent5e603764266568084eaae9ec0e0b130e7f233402 (diff)
fix(firewall): remove blanket TCP allow for unpaid clientsfeature/tollgate-core-v2
The sandbox_mint_access=true default allowed ALL TCP forwarding from unpaid clients, completely bypassing the firewall. Fix: - Remove the blanket TCP allow when sandbox_mint_access is set - Only allow traffic to AP IP on specific ports (80, 2121, 4869, mining) - Allow ICMP to AP IP for diagnostics - Default sandbox_mint_access to false - Add port 4869 (local relay) to allowed sandbox ports Verified on Board B: unpaid clients blocked from internet, local services (portal, API, relay) still accessible.
Diffstat (limited to 'components/tollgate_core')
-rw-r--r--components/tollgate_core/src/tollgate_core_firewall.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/components/tollgate_core/src/tollgate_core_firewall.c b/components/tollgate_core/src/tollgate_core_firewall.c
index 4f12923..5dbdc7a 100644
--- a/components/tollgate_core/src/tollgate_core_firewall.c
+++ b/components/tollgate_core/src/tollgate_core_firewall.c
@@ -18,7 +18,6 @@
18static const char *TAG = "tg_core_fw"; 18static const char *TAG = "tg_core_fw";
19static esp_ip4_addr_t s_ap_ip; 19static esp_ip4_addr_t s_ap_ip;
20static uint16_t s_mining_port = 3333; 20static uint16_t s_mining_port = 3333;
21static bool s_sandbox_mint_access = false;
22 21
23typedef struct { 22typedef struct {
24 uint32_t ip; 23 uint32_t ip;
@@ -81,7 +80,7 @@ void tollgate_core_fw_set_sandbox_ports(uint16_t mining_port)
81 80
82void tollgate_core_fw_set_sandbox_mint_access(bool enabled) 81void tollgate_core_fw_set_sandbox_mint_access(bool enabled)
83{ 82{
84 s_sandbox_mint_access = enabled; 83 (void)enabled;
85} 84}
86 85
87static bool is_sandbox_allowed(struct pbuf *p) 86static bool is_sandbox_allowed(struct pbuf *p)
@@ -98,17 +97,16 @@ static bool is_sandbox_allowed(struct pbuf *p)
98 struct tcp_hdr *tcphdr = (struct tcp_hdr *)((uint8_t *)p->payload + IP_HLEN); 97 struct tcp_hdr *tcphdr = (struct tcp_hdr *)((uint8_t *)p->payload + IP_HLEN);
99 dst_port = lwip_ntohs(tcphdr->dest); 98 dst_port = lwip_ntohs(tcphdr->dest);
100 } 99 }
101 if (dst_port == 80 || dst_port == 2121 || dst_port == s_mining_port) { 100 if (dst_port == 80 || dst_port == 2121 || dst_port == 4869 || dst_port == s_mining_port) {
102 return true; 101 return true;
103 } 102 }
104 } 103 }
105 if (iphdr->_proto == IP_PROTO_UDP) { 104 if (iphdr->_proto == IP_PROTO_UDP) {
106 return true; 105 return true;
107 } 106 }
108 } 107 if (iphdr->_proto == 1) {
109 108 return true;
110 if (s_sandbox_mint_access && iphdr->_proto == IP_PROTO_TCP) { 109 }
111 return true;
112 } 110 }
113 111
114 return false; 112 return false;