Commit Graph
11 Commits
Author SHA1 Message Date
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 d74ab1c1c6 Add name parameter to uasync_set_timeout for timer identification in dumps 2026-04-21 19:06:45 +03:00
jeka de053a00c0 cleanup tests (winsock) 2026-03-04 17:27:33 +03:00
jeka fcdd07ba94 фиксы тестов (winsock) 2026-03-04 15:30:32 +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 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 8334b97521 Backup before adding NAT IP:port tracking to ETCP handshake 2026-02-14 11:02:20 +03:00
Evgeny d694c92b1f Refactor etcp_api: per-instance bindings with struct ETCP_BINDINGS
Changed from global bindings to per-instance bindings:

1. Added struct ETCP_BINDINGS in etcp_api.h:
   - Contains array of callbacks[ETCP_MAX_BINDINGS]
   - NULL means not bound

2. Updated UTUN_INSTANCE (utun_instance.h):
   - Added field: struct ETCP_BINDINGS api_bindings
   - Initialized to NULL by calloc in utun_instance_create

3. Updated API functions (etcp_api.h/c):
   - etcp_bind(inst, id, callback) - per-instance binding
   - etcp_unbind(inst, id) - per-instance unbinding
   - Removed etcp_api_init/etcp_api_deinit (not needed)
   - etcp_int_recv now uses conn->instance->api_bindings.callbacks[id]

4. Updated test_etcp_api.c:
   - Separate callbacks for server and client
   - Register via etcp_bind(server_instance, ...) and etcp_bind(client_instance, ...)
   - Removed global etcp_api_init/etcp_api_deinit calls

Test passes: All 100 packets transmitted in each direction.
2026-02-14 01:39:55 +03:00
Evgeny 1a7356e923 Clean up test_etcp_api: set WARN level, remove obsolete comments 2026-02-14 01:07:44 +03:00
Evgeny 7a1f160094 Fix test_etcp_api: use single callback with connection check
etcp_bind uses global table - multiple binds with same ID overwrite.
Fixed by using single recv_callback that checks conn pointer:
- conn == server_conn: forward direction (client->server)
- conn == client_conn: backward direction (server->client)

Test now passes: All 100 packets transmitted in each direction.
2026-02-14 01:07:11 +03:00
Evgeny 6e93c087ca Add test_etcp_api.c - test for ETCP API (etcp_send, etcp_bind)
Based on test_pkt_normalizer_etcp.c but uses high-level API:
- etcp_send() for sending packets via ETCP normalizer
- etcp_bind() for registering receive callbacks
- etcp_api_init()/etcp_api_deinit() for API lifecycle

NOTE: Test has current limitation - pkt_normalizer packer aggregates
packets into ~1536 byte chunks, exceeding ETCP max payload of 1480 bytes.
This causes encrypt_send to fail. The test demonstrates correct API usage
pattern but requires packer fix for full functionality.
2026-02-13 23:37:13 +03:00