Evgeny
0f8df44b2b
build: out-of-tree VPATH build, tests run once with colored timing
...
- Root Makefile: hand-written bootstrap delegating to build/
- Makefile.am: simplified to SUBDIRS + clean-local
- build.sh: delegates to make, autoreconf only
- tests: removed duplicate TESTS run, added colored [PASS]/[FAIL]/[SKIP] with timing
- .gitignore: added /build/ for out-of-tree artifacts
Result: 0 .o files in source dirs, 29/29 tests pass
2026-04-27 13:48:22 +03:00
Evgeny
d0d4199273
etcp: unified send hook via etcp_udp_send, remove loss_rate, add dummynet_filter inline mode, rewrite BGP test
...
- Add etcp_udp_send_fn_t hook typedef, send_hook/send_hook_ctx fields to ETCP_LINK
- Implement etcp_udp_send() wrapper — all UDP sends go through one point
- Remove loss_rate from ETCP_SOCKET, CFG_SERVER, config parser, send path
- Add dummynet_filter: inline send-hook with loss/delay, no proxy socket needed
- Rewrite test_bgp_route_exchange: 3-node chain A(2 links)↔B↔C, 7 phases
with dummynet_filter-based link failure/recovery simulation
- Clean up tests: remove skeleton test_routing_mesh, 6 debug/stale test files
- Refactor test_etcp_simple_traffic and test_pkt_normalizer_etcp (remove debug spam)
- Fix test_etcp_two_instances: remove private field access, fix false PASS on timeout
2026-04-27 12:43:52 +03:00
Evgeny
e7c32d9ac1
1
2026-04-26 19:58:37 +03:00
Evgeny
7d03749522
1
2026-04-26 19:53:05 +03:00
Evgeny
61fee27478
congestion: burst-based BW measurement + adaptive inflight (slow start/cong avoidance/loss response)
...
New features:
- get_time_us() in lib/u_async.c/h for µs-precision timing
- Burst measurement (ETCP_SECTION_MEAS_TS 0x07, MEAS_RESP 0x08, FILLER 0x09)
- 12 MTU packets sent at line rate, receiver measures inter-packet gaps
- Burst triggered when link saturated + min 500ms interval
- Result: measured BW -> bandwidth for shaper, burst_target_bdp for window cap
- 3-phase adaptive inflight in link_stats_timer_cb:
- Slow start: windows doubles each RTT, exits on loss/RTT spike/threshold
- Congestion avoidance: additive increase, proportional RTT shrink, multiplicative loss shrink
- Burst target cap: inflight_lim <= burst_target_bdp * 1.1
- Dynamic optimal_inflight = sum(link->inflight_lim_bytes), recalculated on change
- Adaptive win_timebase = rtt/2 (was hardcoded 10ms)
Fixes:
- dummynet.c: shaper formula fixed (80000 -> 80)
- dummynet.c: queue_data_put call fixed (3 args -> 2)
- etcp.c: SIZE ERROR format string (missing log_name argument)
- etcp_request_pkt: FILLER leaves room for PAYLOAD overhead
Tests:
- test_etcp_congestion.c: single-threaded, 5-phase BW/delay/loss test
- sender + receiver + dummynet in one uasync
- CSV metrics output every 100ms
- All 29 existing tests pass
2026-04-26 00:17:32 +03:00
Evgeny
edfe665837
log: move individual ping logs from INFO/TRACE to DEBUG level
2026-04-25 21:59:34 +03:00
Evgeny
6c057ca89a
fix BGP: delay up_cbk until connection initialized, fix send_table_request leak
2026-04-25 21:46:35 +03:00
Evgeny
a356eedc0d
cleanup BGP/connection logging
...
- Consolidate on_up/on_down to single INFO line with peer_id
- Remove DEBUG_CATEGORY_DEBUG duplications from route_bgp.c
- NODEINFO: inline lightweight dump (no malloc), verbose log -> DEBUG
- NAT_INFO: remove hex dump duplications, single clean INFO line
- Send NODEINFO per-recipient: INFO->DEBUG_DEBUG
- Per-ping callbacks: INFO->DEBUG_TRACE
- Per-packet traffic direction: INFO->DEBUG_TRACE
- route_insert/delete: use node_id instead of pointer
- Add cancel_all log, add_to_senders conn name
- send_full_table: ERROR->WARN for consistency checks
- is_local_subnet: DEBUG->TRACE
- Fix etcp_send_ping BGP category
2026-04-25 20:06:48 +03:00
Evgeny
227a1aafad
cleanup debug logging
2026-04-25 19:43:51 +03:00
Evgeny
048d1c18b1
fix: restore lost if(changed) block in update_my_nodeinfo + add debug warnings
2026-04-25 19:41:17 +03:00
Evgeny
bbebc74bdb
fix etcpmon keyboard: move Tab/Enter/Esc from WndProc to message loop pre-translate
2026-04-25 19:27:01 +03:00
Evgeny
973c00e544
add etcpmon keyboard navigation: Tab between Server/Port, Enter=Connect, Esc=Disconnect
2026-04-25 19:22:00 +03:00
Evgeny
fb76b4252f
fix etcpmon: stray brace in nat_type_to_string, add pipefail to build scripts
2026-04-25 19:14:28 +03:00
Evgeny
456d274e12
fix mass_update: remove git remote http->https rewrite (port 443 blocked on remotes)
2026-04-25 19:08:08 +03:00
Evgeny
c391d497b4
fix mass_update: skip tests build, fix git http redirect, speed up deploy
2026-04-25 19:06:18 +03:00
Evgeny
4e040b2891
fix mass_update: add pipefail so make errors stop the update script
2026-04-25 18:54:07 +03:00
Evgeny
f6ef38aa5d
update documentation
2026-04-25 18:42:20 +03:00
Evgeny
9c509d4c86
add connectivity probing + NAT type rename OPEN->EIM, RESTRICTED->STRICT
...
- Rename NAT types: OPEN->EIM, RESTRICTED->STRICT across all code
- Add flat addr list {type,ip,port,socket_id} to NODEINFO (NODEINFO_IPV4_ADDR)
- Add NODEINFO_IPV4_SOCKET_META for per-socket metadata
- Add NODE_CONNECTIVITY with per-type probe status and min_rtt
- New module: route_connectivity.c/h (probing engine with socket fallback)
- STRICT verified addresses excluded from NODEINFO broadcast
- Trigger probing on new/updated BGP node, cancel on remove/withdraw
- Update NAT type names in etcpmon GUI
2026-04-25 18:41:45 +03:00
Evgeny
39544e6b2b
Fix: Add bounds/mtu checks, underflow protection and null deref fix for ETCP robustness
2026-04-25 12:38:05 +03:00
Evgeny
2fadec947b
Fix: Split multi-var init and rename s_net/d_net to src_net/dst_net to avoid MSYS2 S_un macro conflict
2026-04-25 01:21:38 +03:00
Evgeny
595d2b177b
Refactor: Replace custom tc_hton*/tc_ntoh* with standard htobe16/be16toh/htobe32/be32toh, move htobe16/be16toh to platform_compat.h
2026-04-25 01:16:09 +03:00
Evgeny
69b49d424b
Fix: Include platform_compat.h before winsock2.h in debug_config.h so tc_htonl/tc_htons macros are defined first
2026-04-25 01:02:50 +03:00
Evgeny
6284a95267
Fix: Define tc_htonl/tc_htons as macros before winsock2.h to avoid struct-in_addr redefinition
2026-04-25 00:59:50 +03:00
Evgeny
8cb05da11c
Fix: Add forward declaration of struct UTUN_INSTANCE in route_node.h
2026-04-25 00:54:20 +03:00
Evgeny
aafa0cfcab
Fix: Add portable tc_htonl/tc_htons/tc_ntohl/tc_ntohs macros, replace winsock2-incompatible hton*/nto* in NAT test files
2026-04-25 00:52:33 +03:00
Evgeny
3dd8fa4085
Fix: Remove arpa/inet.h from test_nat_stress.c and test_nat_transport.c, use platform_compat.h for byte-order funcs
2026-04-25 00:50:46 +03:00
Evgeny
ba30f2adc6
Fix: Remove arpa/inet.h from test_nat_engine.c, use platform_compat.h for byte-order funcs
2026-04-25 00:48:40 +03:00
Evgeny
907ef244c6
NAT: Full Cone (EIM) NAT with ETCP_ID_NAT protocol, per-node routing, and comprehensive test suite
...
- New ETCP protocol ETCP_ID_NAT (0x02) for NAT traffic between nodes
- eim_nat.c/h: Pure NAT engine (table, port allocation, checksum updates, egress/ingress)
- nat_transport.c/h: Transport layer (NAT TUN, ETCP binding, client/provider roles)
- route_bgp_find_conn_for_node(): shared utility for optimal connection lookup
- tun_init_nat(): dedicated TUN creation for NAT
- Config: [nat] section with tun_ip, port_start/end, nat_via, forward rules
- Fix: csum_update_ip/transport use htonl() halves (correct on LE systems)
- Fix: IP_FRAG_MF_MASK changed to 0x2000 (after ntohs, MF is bit 13)
- Tests: 26 engine unit + 4 transport integration + 7 stress (29 total)
2026-04-25 00:43:25 +03:00
Evgeny
b7da11c2bf
Crypto: Refactored ETCP header size calculations with offsetof-based defines, increased CCM tag to 16 bytes
2026-04-24 16:03:07 +03:00
Evgeny
a66edb8f5f
Crypto: Added SHA256-based KDF for session key derivation from ECDH shared secret
2026-04-24 15:43:58 +03:00
Evgeny
11d511797a
Fix compiler warnings: remove incorrect address-of operator and add getpid for Windows
...
- etcp_connections.c:1142: remove & before addr in sockaddr_storage_to_str call
- test_etcp_simple_traffic.c: add #include <process.h> and #define getpid _getpid for Windows
2026-04-24 14:48:29 +03:00
Evgeny
45a181370f
Add htobe32/be32toh macros for Windows build
2026-04-24 14:44:24 +03:00
Evgeny
27df3355f1
Fix getmyip.h Windows build: use winsock2.h instead of sys/socket.h
2026-04-24 14:39:12 +03:00
Evgeny
e0ce9fefc3
Fix allowed_keys check to only apply to ETCP_INIT packets, not PING/PONG
...
The allowed_keys authorization was incorrectly checking all INIT-decrypted
packets including PING/PONG. Moved the check after packet type validation
so it only applies to ETCP_INIT_REQUEST/NOINIT (incoming connection requests).
Fixes test_etcp_ping and test_nat_detection failures.
2026-04-24 14:37:08 +03:00
Evgeny
6aedf5fe91
Replace buggy get_default_route_ip() with get_outgoing_local_ip() for reliable local IP detection
...
- Add lib/getmyip.c/h with get_outgoing_local_ip() using UDP connect+getsockname
- Update etcp_socket_add() to use new function for 0.0.0.0 and :: bindings
- Support both IPv4 (8.8.8.8) and IPv6 (2001:4860:4860::8888) auto-detection
- Remove broken get_default_route_ip() from platform_compat (it returned gateway IP, not local IP)
- Keep get_interface_ip_by_index() for explicit interface bindings
- Update Makefile.am to include new getmyip module
2026-04-24 14:07:41 +03:00
Evgeny
724a9ff5c7
Add getmyip module for reliable local IP detection
...
- New lib/getmyip.c/h with get_outgoing_ip(), get_default_local_ip(), get_local_ip_by_index()
- Uses UDP connect + getsockname instead of /proc/net/route parsing
- Supports both IPv4 and IPv6
- Updated etcp_socket_add() to use new functions for interface_addr detection
2026-04-24 13:58:24 +03:00
Evgeny
697aee0351
Socket info: show config and netif IP in log, monitor shows interface IP
2026-04-24 01:23:52 +03:00
jeka
30413ebce0
1
2026-04-24 00:43:59 +03:00
Evgeny
20f3ba092f
Config: Added [allowed_keys] section to sample config with documentation
2026-04-24 00:21:00 +03:00
Evgeny
e39979bfac
Config: Added [allowed_keys] section for client public key authorization on server
...
- Added CFG_ALLOWED_KEY struct with binary key storage (64 bytes) for fast memcmp comparison
- Implemented parsing of [allowed_keys] section with allow_all flag and per-key entries
- Added key validation in etcp_connections.c server handler (errorcode=8 for rejected keys)
- Default behavior: deny all if [allowed_keys] section is missing or allow_all=0 with no keys
- Added proper memory cleanup and debug logging for allowed_keys configuration
- Updated all test configs to include [allowed_keys] allow_all=1 for backward compatibility
2026-04-24 00:16:30 +03:00
Evgeny
3625a4e5d5
Restart NAT check when client address changes in INIT_REQUEST
2026-04-23 23:56:49 +03:00
Evgeny
a3063ea47a
NODEINFO: Add nat_addr/nat_port fields, use interface_addr for addr/port
2026-04-23 23:21:12 +03:00
Evgeny
f02603f8ac
Add socket type (public/nat/private) to handshake and skip private nodes in NAT detection
2026-04-23 22:44:43 +03:00
Evgeny
bd749c1484
GUI: Widen sockets list 1.5x, shrink action field, move Send below
2026-04-23 22:11:02 +03:00
Evgeny
0c748501c8
GUI: Add NAT address to socket display in etcpmon
2026-04-23 22:02:42 +03:00
Evgeny
72c6b6f197
Reset NAT check status on etcp_conn_reinit when session_id changes
...
When peer's random session_id changes, etcp_conn_reinit() is called.
Previously NAT check status was not reset, so route_bgp_new_conn()
skipped NAT re-detection because nat_check_status was still
NAT_CHECK_IN_PROGRESS from the previous session.
Now etcp_conn_reinit():
- Cancels pending NAT-ping requests via route_ping_cancel_for_conn()
- Resets nat_type and nat_check_status to UNKNOWN/NONE for all links
This ensures NAT type is re-detected for all links after reinit.
2026-04-23 20:00:09 +03:00
Evgeny
4b9bffffbd
Debug: Add diagnostic logging for PONG handling to trace ping response issues
2026-04-23 13:18:59 +03:00
Charlie Root
d3d95c3c19
1
2026-04-22 23:15:41 +00:00
Evgeny
bcb1c37c87
Fix two more UAF in route_bgp: move DEBUG_INFO before etcp_send
...
- route_bgp_send_nat_info: moved ip_to_str(pkt->nat_ip) log before etcp_send
- route_bgp_send_nat_check_req: moved ip_to_str(pkt->interface_ip) log before etcp_send
Both were reading from pkt memory that could be freed by etcp_send callback.
2026-04-23 02:09:09 +03:00
Evgeny
3959ed8afe
Fix use-after-free: read request_id before etcp_send frees req_pkt
...
req_pkt memory could be freed by etcp_send callback before pending->request_id
was assigned. Store request_id in local variable and use it for pending.
2026-04-23 01:59:41 +03:00