Commit Graph
3215 Commits
Author SHA1 Message Date
jeka 8a5a5c361f Remove generated Makefile and temp file src/aa from repo (already in .gitignore) 2026-02-16 11:16:14 +03:00
jeka 8263db2726 Remove temp build files (cl, build_win.log) and update .gitignore 2026-02-16 10:44:53 +03:00
jeka 9c768bfd17 Fix timer leaks in ETCP: cancel retrans_timer, ack_resp_timer, and shaper_timer on connection close 2026-02-16 10:39:36 +03:00
jeka a0b02b9812 Fix port conflicts in test_pkt_normalizer_etcp - use unique ports 9041/9042 2026-02-16 10:35:26 +03:00
jeka 78dfdde400 Fix Windows test failures: proper WSAPoll error handling and FD_SETSIZE check 2026-02-16 10:33:43 +03:00
jeka 6dfeac03a8 1 2026-02-16 08:44:05 +03:00
Evgeny 603768052d Debug: Enable crypto packet dumps conditionally based on debug level 2026-02-16 08:15:51 +03:00
Evgeny a73e36b559 Fix mesh topology: try normal decryption first, then INIT
Reversed the decryption order:
1. If link exists with session_ready, try normal decryption first
2. If normal decryption succeeds, process packet normally (goto process_decrypted)
3. If normal decryption fails OR no link OR no session, try INIT decryption
4. If INIT succeeds, create new server-side connection and link

This is more efficient because:
- Most packets are regular data (use normal decryption)
- INIT packets are rare (only during connection setup)
- Works correctly for both standard client-server and mesh topologies

All 23 tests now pass.
2026-02-16 01:02:10 +03:00
Evgeny 27b02cef68 Fix mesh topology handling with fallback to normal decryption
When receiving packets on client links, try INIT decryption first.
If it fails (e.g., for INIT_RESPONSE packets), fallback to normal
decryption using the existing link's crypto context.

This fixes mesh topology where both nodes send INIT simultaneously,
while maintaining compatibility with standard client-server mode where
client links receive INIT_RESPONSE packets.

Changes:
- If link==NULL OR link is client (is_server==0), try INIT decryption
- On any INIT decryption error, if we have an existing link, goto normal_decrypt
- Added normal_decrypt label before standard packet processing
- This allows handling both incoming INIT (create server link) and
  incoming responses (use existing client link) correctly
2026-02-16 00:51:28 +03:00
Evgeny 1cc475e9b0 Rewrite test_routing_mesh to use programmatic config creation
Replaced file-based config creation with direct struct population.
This eliminates temporary files and makes the test cleaner.

Key changes:
- Added helper functions for creating config structures
- Create CFG_SERVER, CFG_CLIENT, CFG_CLIENT_LINK programmatically
- Use utun_instance_create_from_config() instead of file-based creation
- No temp directories or file cleanup needed

The test now builds configs in memory using helper functions like
make_sockaddr(), create_server(), create_client(), etc.
2026-02-15 23:56:18 +03:00
Evgeny 0a4373ffe1 Fix: Treat client links as INIT packets on receive
When receiving an INIT packet, the code was looking up existing links by
address. However, in a mesh topology where each node has both client and
server connections to peers, a client link created during initialization
would be found when receiving an incoming INIT packet from that peer.

This caused the code to try decrypting the INIT packet using the client
link's crypto context, which failed because the session keys weren't
properly established yet.

The fix checks if the found link is a client link (is_server==0) and if
so, treats the packet as a new INIT connection that needs to create a
server-side link instead.

Changed condition from:
  if (link==NULL)
to:
  if (link==NULL || link->is_server==0)
2026-02-15 23:35:23 +03:00
Evgeny f7e1234d3d Mesh test с файлами конфигов - все еще ошибки расшифровки 2026-02-15 21:36:18 +03:00
Evgeny 59f01c6a15 WIP: исправление портов и добавление отладки в mesh test 2026-02-15 21:32:32 +03:00
Evgeny c1e2f061b9 Рефакторинг utun_instance_create - устранено дублирование кода
- Создана общая функция instance_init_common() для инициализации instance
- Упрощены utun_instance_create() и utun_instance_create_from_config()
- Удалено ~90 строк дублирующегося кода
- Обе функции теперь используют общую логику инициализации
2026-02-15 20:44:14 +03:00
Evgeny bee1e41b07 Добавлен тестовый режим для TUN интерфейса и тест роутинга mesh
- Добавлена опция tun_test_mode в конфиг для работы без реального TUN устройства
- Добавлены функции для работы с очередями TUN в тестовом режиме
- Добавлен API для программного создания instance из структуры конфига
- Создан тест test_routing_mesh.c с 3-instance mesh топологией
- Ключи генерируются автоматически и распределяются между instance
2026-02-15 20:37:10 +03:00
Evgeny 602d9174a4 Remove test binaries from git tracking (now ignored) 2026-02-15 18:57:23 +03:00
Evgeny 704554af84 Update .gitignore: add test binaries and all log files 2026-02-15 18:55:53 +03:00
Evgeny eb721be508 Simplify: Extract common crypto logic into helper functions for both OpenSSL and TinyCrypt 2026-02-15 18:47:49 +03:00
Evgeny 25f5b84bf9 Simplify: Remove unreachable duplicate code block in init_connections 2026-02-15 18:40:43 +03:00
Evgeny f4295d962e Simplify: Deduplicate queue cleanup in etcp_connection_close using helper functions 2026-02-15 18:39:03 +03:00
Evgeny ca16d175e6 Backup: before code simplification refactoring 2026-02-15 18:37:23 +03:00
jeka 806226c049 Remove test logs from git and add to .gitignore
- Remove tests/logs/ directory from git tracking
- Add tests/logs/ to .gitignore
2026-02-15 18:05:14 +03:00
jeka 10d6b28090 Update test logs after u_async fixes 2026-02-15 17:56:50 +03:00
jeka c8af35c4b9 Fix u_async: Windows socket registration, timers, and poll issues
- Remove FD_SETSIZE check for Windows sockets (can have any value)
- Fix process_timeouts to handle all expired timers (continue instead of break)
- Handle case when no sockets to poll (sleep instead of calling poll)
- Disable wakeup pipe on Windows (incompatible with WSAPoll)
- Add gettimeofday and ssize_t implementations for Windows
2026-02-15 17:38:45 +03:00
jeka 53c7330a7f Backup before fixing u_async socket registration bug 2026-02-15 17:25:34 +03:00
Evgeny e29ae4dea8 Add check.bat - Windows test runner script 2026-02-15 16:17:00 +03:00
Evgeny 28ff3a4776 Fix test_u_async_comprehensive: add Windows socketpair replacement using UDP sockets 2026-02-15 14:31:31 +03:00
Evgeny 20a3eaf73c Fix remaining test files: replace POSIX headers with platform_compat.h 2026-02-15 13:25:05 +03:00
Evgeny c75ac9d23b Fix test_u_async_comprehensive.c: replace POSIX headers with platform_compat.h 2026-02-15 13:18:34 +03:00
Evgeny 29d26cf139 Force rebuild of utun-ecc_platform_specific.o on every build to ensure platform-specific changes are picked up 2026-02-15 13:09:10 +03:00
Evgeny f510d78bb5 Fix Windows: use sys/time.h for gettimeofday, remove custom implementation 2026-02-15 12:57:53 +03:00
Evgeny 4403c46788 Fix Windows build: skip gettimeofday on MSYS2, force recompile ecc_platform_specific 2026-02-15 12:26:32 +03:00
Evgeny c2a178cd60 Touch ecc_platform_specific.c to force recompilation 2026-02-15 11:54:20 +03:00
Evgeny 8c84bda1a4 Fix ecc_platform_specific.c: check Windows first, fix typo (| to ||), add stdint.h 2026-02-15 04:47:53 +03:00
Evgeny 560e121d4c Fix tests Makefile.am: WIN_LIBS must be defined before COMMON_LIBS 2026-02-15 04:41:25 +03:00
Evgeny ada25ec4cc Add -ladvapi32 for Windows CryptGenRandom support 2026-02-15 04:36:47 +03:00
Evgeny f5faa7c834 Fix Windows build: add default_CSPRNG and improve build.sh error handling
- Add Windows implementation of default_CSPRNG() using CryptGenRandom
- Add fallback stub for platforms without CSPRNG support
- Fix build.sh to properly detect build failures (use PIPESTATUS)
- Show proper error message instead of "Build completed successfully" on failure
2026-02-15 04:34:05 +03:00
Evgeny 27f2edca40 Fix remaining Windows test build issues
- Remove sys/socket.h include from test_etcp_two_instances.c (Linux-only)
- Fix test_mkdtemp buffer overflow - use memcpy instead of strncpy
- Fix test_mkdtemp return value check (replace == NULL with != 0)
- Add Windows socket libraries (-lws2_32 -liphlpapi) to test builds
- All tests build successfully on Linux
2026-02-15 04:24:46 +03:00
Evgeny 4d486c7017 Fix test files for Windows cross-platform compatibility
- Create test_utils.h with cross-platform utility functions:
  * test_mkdtemp() - Windows uses GetTempPath + _mkdir, Linux uses mkdtemp
  * test_unlink() - Windows _unlink, Linux unlink
  * test_rmdir() - Windows _rmdir, Linux rmdir

- Update all test files to use test_utils.h
- Replace arpa/inet.h and netinet/in.h with platform_compat.h
- Replace unistd.h with conditional includes
- Replace mkdtemp(), unlink(), rmdir() with test_* versions

- Tests now build on both Linux and Windows
- Note: Some integration tests may fail on Linux due to test environment
2026-02-15 04:09:24 +03:00
Evgeny 0798b149ab Fix Windows build: use WSAPoll instead of poll for linking 2026-02-15 03:54:35 +03:00
Evgeny 84e6d59d77 Fix Windows build: wintun function pointer declarations
- Add * to Wintun function pointer declarations (wintun.h defines types as functions)
- Use (void *) cast in GetProcAddress to avoid errors
- All 22 tests pass on Linux
2026-02-15 03:49:47 +03:00
Evgeny 2a546c5fbc Fix Windows build: tun_windows.c function pointers and MIB_IPINTERFACE_ROW
- Fix function pointer declarations in tun_windows.c (removed broken macro)
- Use explicit GetProcAddress calls for each Wintun function
- Remove invalid fields from MIB_IPINTERFACE_ROW (PromiscuousMode, DadState, etc.)
- Add #ifndef _WIN32 around IF_NAMESIZE/if_indextoname in etcp_connections.c
- All 22 tests pass on Linux
2026-02-15 03:46:05 +03:00
Evgeny f51705c57d Fix Windows detection in configure.ac - check both host_os and host 2026-02-15 03:39:18 +03:00
Evgeny 8af2904033 Fix Windows build: net/if.h and route_lib.h forward declarations
- Wrap net/if.h include in #ifndef _WIN32 in etcp_connections.c
- Add forward declarations for ROUTE_TABLE and ROUTE_ENTRY in route_lib.h
- All 22 tests pass on Linux
2026-02-15 03:30:42 +03:00
Evgeny 605a928350 Fix Windows build: POSIX dependencies (netdb.h, fork, setsid, SIGHUP, etc.)
- Wrap POSIX headers (netdb.h, ifaddrs.h, net/if.h) in #ifndef _WIN32 in config_parser.c
- Add Windows stub for get_netif_index() - returns 0 (no interface binding)
- Wrap daemonize() function for Windows - returns 0 (no fork/setsid support)
- Replace setlinebuf() with setvbuf() for Windows compatibility
- Wrap SIGHUP signal handler in #ifndef _WIN32
- Add explicit poll() declaration for Windows in platform_compat.h
- All 22 tests pass on Linux
2026-02-15 03:26:02 +03:00
Evgeny c83fdeeaad Fix Windows build: add sa_family_t typedef, replace arpa/inet.h, fix ll_queue warnings
- Add sa_family_t typedef for Windows in platform_compat.h
- Add forward declaration of struct ll_queue in ll_queue.h to fix warnings
- Replace arpa/inet.h includes with platform_compat.h in:
  tun_linux.c, etcp_connections.c, route_lib.c, route_bgp.c,
  utun_instance.c, routing.c, utun.c, packet_dump.h, config_parser.c
- All 22 tests pass on Linux
2026-02-15 03:06:02 +03:00
Evgeny 9b1d43996e Remove #include <poll.h> from Windows section - already in winsock2.h 2026-02-15 02:58:32 +03:00
Evgeny 1bd4bf5d11 Fix Windows build errors: config_parser.h, poll(), localtime()
- Replace sys/socket.h with platform_compat.h in config_parser.h
- Add #include <poll.h> for Windows in platform_compat.h
- Fix localtime() type mismatch: cast tv.tv_sec to time_t
- All 22 tests pass on Linux
2026-02-15 02:56:08 +03:00
Evgeny 0688efcd0e Fix platform_compat.h - remove duplicate definitions for MSYS2
- Remove duplicate struct pollfd (already in winsock2.h)
- Remove duplicate struct timezone (already in time.h)
- Remove duplicate nanosleep (already in pthread_time.h)
- Add fcntl.h include for _O_BINARY
- Use platform_pipe/fcntl to avoid naming conflicts
- All 22 tests pass on Linux
2026-02-15 02:52:27 +03:00
Evgeny 0c43a633b9 Add platform_compat.h for Windows POSIX compatibility
- Add platform_compat.h with Windows implementations of:
  * gettimeofday() using GetSystemTimeAsFileTime
  * poll() using select()
  * pipe() using _pipe()
  * fcntl() using ioctlsocket for O_NONBLOCK
  * pollfd structure and POLL* constants
  * strcasecmp/strncasecmp macros

- Update debug_config.c and u_async.c/h to use platform_compat.h
- Remove POSIX-specific headers (arpa/inet.h, sys/time.h, etc.)
- All 22 tests pass on Linux
- Fixes build errors on Windows MSYS2
2026-02-15 02:46:41 +03:00