diff --git a/headless/tests/lib.sh b/headless/tests/lib.sh index 8c69b50..a013b33 100644 --- a/headless/tests/lib.sh +++ b/headless/tests/lib.sh @@ -12,8 +12,8 @@ SINK_PID="" SINK_PORT="" SINK_FILE="" SINK_WRAP="${SINK_WRAP:-}" -SINK_BIND="${SINK_BIND:-127.0.0.1}" -SINK_TARGET="${SINK_TARGET:-127.0.0.1}" +SINK_BIND="${SINK_BIND:-}" +SINK_TARGET="${SINK_TARGET:-}" PROBE_HOST="${PROBE_HOST:-127.0.0.1}" PORT_CURSOR="${PORT_BASE:-21080}" @@ -55,7 +55,19 @@ alloc_port() { PORT_CURSOR=$((PORT_CURSOR + 1)) } +host_ip() { + if command -v ip >/dev/null 2>&1; then + ip -4 route get 1.1.1.1 2>/dev/null | sed -n 's/.* src \([0-9.]*\).*/\1/p' | head -1 + elif command -v ipconfig >/dev/null 2>&1; then + _iface=$(route -n get default 2>/dev/null | sed -n 's/.*interface: *//p' | head -1) + [ -n "$_iface" ] && ipconfig getifaddr "$_iface" 2>/dev/null + fi +} + start_sink() { + [ -n "$SINK_BIND" ] || SINK_BIND=$(host_ip) + [ -n "$SINK_BIND" ] || die "cannot detect a non-loopback address for the sink, set SINK_BIND and SINK_TARGET" + [ -n "$SINK_TARGET" ] || SINK_TARGET="$SINK_BIND" alloc_port SINK_PORT="$ALLOC_PORT" SINK_FILE=$(mktemp -t e2e-sink.XXXXXX) diff --git a/headless/tests/run.sh b/headless/tests/run.sh index 072bf58..2c1a6ae 100755 --- a/headless/tests/run.sh +++ b/headless/tests/run.sh @@ -82,7 +82,7 @@ require_cmd ncat trap cleanup EXIT INT TERM start_sink -log "sink on 127.0.0.1:$SINK_PORT" +log "sink on $SINK_BIND:$SINK_PORT" for _pf in $RUN_PLATFORMS; do run_platform "$_pf" diff --git a/headless/tests/stand/netns-run.sh b/headless/tests/stand/netns-run.sh index 15730bf..27732ba 100755 --- a/headless/tests/stand/netns-run.sh +++ b/headless/tests/stand/netns-run.sh @@ -46,8 +46,8 @@ JOINER_WRAP="ip netns exec joiner" JOINER_SOCKS_HOST="0.0.0.0" PROBE_HOST="10.201.2.2" SINK_WRAP="ip netns exec creator" -SINK_BIND="127.0.0.1" -SINK_TARGET="127.0.0.1" +SINK_BIND="10.201.1.2" +SINK_TARGET="10.201.1.2" cleanup_all() { cleanup diff --git a/headless/tests/stand/stand.sh b/headless/tests/stand/stand.sh index 27dbc9e..2ae1508 100755 --- a/headless/tests/stand/stand.sh +++ b/headless/tests/stand/stand.sh @@ -33,8 +33,8 @@ loopback - no external network, no rate limits. Platforms: telemost wbstream dion bitrix (VK has no headless SOCKS joiner) Scenarios: connect dc kcp dual kick -Cookies are taken from cookies-.json at the repo root at build time. -Rebuild after refreshing cookies. Examples: +Cookies are mounted from cookies-.json at the repo root on run. +Examples: stand.sh build stand.sh run stand.sh run bitrix dc kick @@ -43,7 +43,8 @@ EOF } build_context() { - arch=$(docker version --format '{{.Server.Arch}}' 2>/dev/null || echo arm64) + arch=$(docker version --format '{{.Server.Arch}}' 2>/dev/null | tr -d '[:space:]') + [ -n "$arch" ] || arch=arm64 rm -rf "$CTX" mkdir -p "$CTX/work/headless/tests/stand" for spec in $COMPONENTS; do