Browse Source

Enable server-only operation and add server section to configs

- Fixed init_connections() to allow 0 connections for server-only mode
- All instances now require [server] section for bind socket
- Added test configs demonstrating server-only and client-with-server patterns
- Created run_two_instance_test.sh for manual handshake testing
v2_dev
Evgeny 2 months ago
parent
commit
11501faeb8
  1. 6
      src/etcp_connections.c
  2. 25
      tests/run_two_instance_test.sh
  3. 10
      tests/test_server_only.conf

6
src/etcp_connections.c

@ -562,8 +562,10 @@ int init_connections(struct UTUN_INSTANCE* instance) {
client = client->next;
}
if (instance->connections_count == 0) {
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "No connections initialized");
// If there are clients configured but no connections created, that's an error
// If there are no clients (server-only mode), 0 connections is OK (server will accept incoming)
if (instance->connections_count == 0 && config->clients != NULL) {
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Clients configured but no connections initialized");
return -1;
}

25
tests/run_two_instance_test.sh

@ -0,0 +1,25 @@
#!/bin/bash
# Test script for ETCP connection establishment with real instances
DIR=$(cd "$(dirname "$0")" && pwd)
echo "=== ETCP Two-Instance Test ==="
echo
# Start server instance in background
echo "Starting server instance..."
$DIR/test_server_only &
SERVER_PID=$!
sleep 1
# Start client instance
echo "Starting client instance..."
timeout 10 $DIR/test_server_only 2>&1
# Cleanup
kill $SERVER_PID 2>/dev/null
wait $SERVER_PID 2>/dev/null
echo
echo "=== Test completed ==="

10
tests/test_server_only.conf

@ -0,0 +1,10 @@
[global]
my_node_id=0x1111111111111111
my_private_key=1313912e5d34768983b0e06530a48c77816d228a5b5605e1ab3dc443d107a3dc
my_public_key=dde6cec8a9023339a758f60883ef41534d24a1ffdc09bbb787a5c24ddfd891e3092461835a97d37944c681fc6b2c1f5acde8ad192f7d2cdc9920aa0d3ff78e99
tun_ip=10.99.0.1/24
tun_ifname=tun99
[server: test]
addr=127.0.0.1:9001
type=public
Loading…
Cancel
Save