From 82f1fc0d5535eda3fc9eab799d81b3e220dbe4ef Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 20 May 2026 02:10:01 +0530 Subject: feat: add tollgate_core component + market config wiring - Add tollgate_core ESP-IDF component (skeleton: cashu, dns, firewall, session) - Add tollgate_platform.c with SPIFFS config backend - Wire market_enabled, market_scan_interval_s, client_auto_switch in config.c - Add lwip_tollgate_hooks.h (updated from feature branch) - Add E2E fix plan, tollgate_core design doc, WPA autodetect plan - Add integration test network helpers - Add CONSOLIDATION.md plan Reverts the broken merge (be4788b) that gutted config.c/tollgate_main.c/tollgate_api.c and replaces it with a clean addition on top of intact master. --- tests/integration/helpers/network.mjs | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/integration/helpers/network.mjs (limited to 'tests/integration/helpers/network.mjs') diff --git a/tests/integration/helpers/network.mjs b/tests/integration/helpers/network.mjs new file mode 100644 index 0000000..0d6013d --- /dev/null +++ b/tests/integration/helpers/network.mjs @@ -0,0 +1,67 @@ +import { execSync } from 'child_process'; + +const DEFAULT_IP = '10.192.45.1'; +const WIFI_IFACE = 'wlp59s0'; + +export function getPortalIP() { + return process.env.TOLLGATE_IP || DEFAULT_IP; +} + +export function curl(url, timeout = 30) { + try { + return execSync( + `curl -s -o /dev/null -w "%{http_code}" --connect-timeout ${timeout} --max-time ${timeout + 10} "${url}"`, + { encoding: 'utf8', timeout: (timeout + 10) * 1000 } + ).trim(); + } catch { + return null; + } +} + +export function curlBody(url, timeout = 30) { + try { + return execSync( + `curl -s --connect-timeout ${timeout} --max-time ${timeout + 10} "${url}"`, + { encoding: 'utf8', timeout: (timeout + 10) * 1000 } + ); + } catch { + return null; + } +} + +export function canPing(host = '8.8.8.8', count = 1) { + try { + const result = execSync( + `ping -c ${count} -W 3 -I ${WIFI_IFACE} ${host} 2>/dev/null`, + { encoding: 'utf8', timeout: 10000 } + ); + return result && !result.includes('100% packet loss'); + } catch { + return false; + } +} + +export function canResolve(domain, timeout = 5) { + try { + const result = execSync( + `dig +short +timeout=${timeout} +tries=1 ${domain} 2>&1`, + { encoding: 'utf8', timeout: (timeout + 2) * 1000 } + ).trim(); + return result.length > 0 && !result.includes('NXDOMAIN'); + } catch { + return false; + } +} + +export function dnsResolvesToSelf(domain) { + const ip = getPortalIP(); + try { + const result = execSync( + `dig +short +timeout=5 ${domain} @{ip} 2>&1`, + { encoding: 'utf8', timeout: 10000 } + ).trim(); + return result === ip; + } catch { + return false; + } +} -- cgit v1.2.3