Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
test(linux): e2e_lifecycle reaches the library as an unprivileged user from a readable copy; e2e_exempt prints diagnostics on failure
anof-cyber74b3ab84f0b2
diff --git a/Linux/tests/e2e_exempt.sh b/Linux/tests/e2e_exempt.shindex ec0a66f..9ee1ae8 100755--- a/Linux/tests/e2e_exempt.sh+++ b/Linux/tests/e2e_exempt.sh@@ -11,6 +11,7 @@ HERE="${HERE:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"; PBL="$HERE/pbl";WORK="$(mktemp -d)"; PASS=0; FAIL=0; PB=""; FWD=""; WWW=""ok() { echo " PASS $1"; PASS=$((PASS+1)); }bad() { echo " FAIL $1"; FAIL=$((FAIL+1)); }+diag() { echo "---- diagnostics: ProxyBridge output"; tail -15 "$WORK/pb.out" 2>/dev/null; echo "---- proxy log"; tail -8 "$WORK/fwd.log" 2>/dev/null; echo "---- address and kernel"; echo "origin address: $MYIP"; uname -r; ip -4 addr show 2>/dev/null | grep -E 'inet |^[0-9]' | head -8; echo "----"; }cleanup() { kill $PB $FWD $WWW 2>/dev/null; wait 2>/dev/null; rm -rf "$WORK"; }trap cleanup EXITexport LD_LIBRARY_PATH="$PB_DIR"@@ -33,7 +34,7 @@ start_fwd 127.0.0.1 19090start_pb socks5://127.0.0.1:19090 || bad "start"out=$(fetch); [[ "$out" == *origin-ok* ]] && ok "request reaches the origin through the forwarding proxy" || bad "no answer (${out:0:100}): $(tail -3 "$WORK/fwd.log")"n=$(grep -c "FWD $MYIP:18399" "$WORK/fwd.log")-[ "$n" = 1 ] && ok "the proxy was asked exactly once: its own connection to the origin was not looped back" || bad "proxy saw $n requests"+[ "$n" = 1 ] && ok "the proxy was asked exactly once: its own connection to the origin was not looped back" || { bad "proxy saw $n requests"; diag; }grep -q "FAIL" "$WORK/fwd.log" && bad "forwarding failed: $(grep FAIL "$WORK/fwd.log")"stop_pb; stop_fwd@@ -57,7 +58,7 @@ good=nofor _ in $(seq 40); do out=$(fetch); if [[ "$out" == *origin-ok* ]]; then good=yes; break; fi; sleep 0.5; done[ $good = yes ] && ok "once the proxy is up it is exempted and the request works" || bad "never worked after the proxy started"n=$(grep -c "FWD $MYIP:18399" "$WORK/fwd.log")-[ "$n" -ge 1 ] && [ "$n" -le 2 ] && ok "no request storm from a loop ($n requests)" || bad "proxy saw $n requests"+[ "$n" -ge 1 ] && [ "$n" -le 2 ] && ok "no request storm from a loop ($n requests)" || { bad "proxy saw $n requests"; diag; }stop_pb; stop_fwdecho "== a proxy that is NOT local is not exempted"diff --git a/Linux/tests/e2e_lifecycle.sh b/Linux/tests/e2e_lifecycle.shindex dccefa6..9ad26f9 100755--- a/Linux/tests/e2e_lifecycle.sh+++ b/Linux/tests/e2e_lifecycle.sh@@ -118,7 +118,9 @@ if gcc -O1 -I"$ROOT/src" -o "$WORK/probe" "$WORK/probe.c" -L"$PB_DIR" -lproxybrichmod 755 "$WORK" "$WORK/probe"out=$("$WORK/probe" 2>&1)[[ "$out" == *"start=0"* && "$out" == *"no proxy is configured"* ]] && ok "a PROXY rule without any proxy refuses to start and says why" || bad "no proxy: $out"- out=$(setpriv --reuid=65534 --regid=65534 --clear-groups env LD_LIBRARY_PATH="$PB_DIR" "$WORK/probe" withproxy 2>&1)+ # the unprivileged user must be able to reach the library wherever the build lives (a CI runner's home folder is not world-readable)+ mkdir -p "$WORK/lib"; chmod 755 "$WORK/lib"; install -m 755 "$PB_DIR/libproxybridge.so" "$WORK/lib/libproxybridge.so"+ out=$(setpriv --reuid=65534 --regid=65534 --clear-groups env LD_LIBRARY_PATH="$WORK/lib" "$WORK/probe" withproxy 2>&1)[[ "$out" == *"start=0"* && "$out" == *"needs root"* ]] && ok "without root it fails cleanly and explains" || bad "not root: $out"[[ "$out" == *"stop=1"* ]] && ok "Stop after a failed Start is harmless" || bad "stop after failed start: $out"[ "$(progs)" = 0 ] && ok "a failed start attaches nothing" || bad "programs attached by a failed start"