upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/tollgate_core/include/tollgate_core.h10
-rw-r--r--components/tollgate_core/include/tollgate_platform.h8
-rw-r--r--components/tollgate_core/src/tollgate_core_firewall.c4
3 files changed, 21 insertions, 1 deletions
diff --git a/components/tollgate_core/include/tollgate_core.h b/components/tollgate_core/include/tollgate_core.h
index aa5d4a1..6a17cbd 100644
--- a/components/tollgate_core/include/tollgate_core.h
+++ b/components/tollgate_core/include/tollgate_core.h
@@ -7,6 +7,10 @@
7#include <stdbool.h> 7#include <stdbool.h>
8#include <stdint.h> 8#include <stdint.h>
9 9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
10esp_err_t tollgate_core_init(const tollgate_platform_t *platform, esp_ip4_addr_t ap_ip); 14esp_err_t tollgate_core_init(const tollgate_platform_t *platform, esp_ip4_addr_t ap_ip);
11 15
12esp_err_t tollgate_core_dns_start(esp_ip4_addr_t upstream_dns); 16esp_err_t tollgate_core_dns_start(esp_ip4_addr_t upstream_dns);
@@ -31,10 +35,14 @@ int tollgate_core_allowed_client_count(void);
31bool tollgate_core_is_owner(uint32_t client_ip); 35bool tollgate_core_is_owner(uint32_t client_ip);
32bool tollgate_core_is_owner_connected(void); 36bool tollgate_core_is_owner_connected(void);
33 37
34esp_err_t tollgate_core_stratum_proxy_start(uint16_t port); 38esp_err_t tollgate_core_stratum_proxy_init(uint16_t port);
35void tollgate_core_stratum_proxy_stop(void); 39void tollgate_core_stratum_proxy_stop(void);
36void tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty); 40void tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty);
37double tollgate_core_calc_hashprice(double hashrate_ghs); 41double tollgate_core_calc_hashprice(double hashrate_ghs);
38char *tollgate_core_get_mining_status_json(void); 42char *tollgate_core_get_mining_status_json(void);
39 43
44#ifdef __cplusplus
45}
46#endif
47
40#endif 48#endif
diff --git a/components/tollgate_core/include/tollgate_platform.h b/components/tollgate_core/include/tollgate_platform.h
index 6c144fa..79e25cf 100644
--- a/components/tollgate_core/include/tollgate_platform.h
+++ b/components/tollgate_core/include/tollgate_platform.h
@@ -4,6 +4,10 @@
4#include <stdint.h> 4#include <stdint.h>
5#include <stdbool.h> 5#include <stdbool.h>
6 6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
7typedef struct { 11typedef struct {
8 uint16_t (*get_price_sats)(void); 12 uint16_t (*get_price_sats)(void);
9 int32_t (*get_step_ms)(void); 13 int32_t (*get_step_ms)(void);
@@ -26,4 +30,8 @@ typedef struct {
26 double (*get_hashrate)(void); 30 double (*get_hashrate)(void);
27} tollgate_platform_t; 31} tollgate_platform_t;
28 32
33#ifdef __cplusplus
34}
35#endif
36
29#endif 37#endif
diff --git a/components/tollgate_core/src/tollgate_core_firewall.c b/components/tollgate_core/src/tollgate_core_firewall.c
index e5d61d8..ad0697e 100644
--- a/components/tollgate_core/src/tollgate_core_firewall.c
+++ b/components/tollgate_core/src/tollgate_core_firewall.c
@@ -3,7 +3,9 @@
3#include "esp_log.h" 3#include "esp_log.h"
4#include "esp_wifi.h" 4#include "esp_wifi.h"
5#include "esp_wifi_ap_get_sta_list.h" 5#include "esp_wifi_ap_get_sta_list.h"
6#ifdef CONFIG_LWIP_IPV4_NAPT
6#include "lwip/lwip_napt.h" 7#include "lwip/lwip_napt.h"
8#endif
7#include "lwip/etharp.h" 9#include "lwip/etharp.h"
8#include "lwip/netif.h" 10#include "lwip/netif.h"
9#include "lwip/prot/ip4.h" 11#include "lwip/prot/ip4.h"
@@ -61,7 +63,9 @@ esp_err_t tollgate_core_fw_init(esp_ip4_addr_t ap_ip)
61 s_ap_ip = ap_ip; 63 s_ap_ip = ap_ip;
62 memset(s_clients, 0, sizeof(s_clients)); 64 memset(s_clients, 0, sizeof(s_clients));
63 s_client_count = 0; 65 s_client_count = 0;
66#ifdef CONFIG_LWIP_IPV4_NAPT
64 ip_napt_enable(s_ap_ip.addr, 1); 67 ip_napt_enable(s_ap_ip.addr, 1);
68#endif
65 ESP_LOGI(TAG, "Firewall initialized with AP IP=" IPSTR " (NAT always on, per-client filter)", IP2STR(&s_ap_ip)); 69 ESP_LOGI(TAG, "Firewall initialized with AP IP=" IPSTR " (NAT always on, per-client filter)", IP2STR(&s_ap_ip));
66 return ESP_OK; 70 return ESP_OK;
67} 71}