Files
proxychains-rs/.github/workflows/ci.yml
T

123 lines
4.8 KiB
YAML

name: CI
on:
push:
branches: [main, master]
tags:
- "v*"
pull_request:
workflow_dispatch:
jobs:
test-and-build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install rustfmt/clippy
run: rustup component add rustfmt clippy
- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
- name: Check formatting (advisory)
continue-on-error: true
run: cargo fmt --all -- --check
- name: Run clippy (advisory)
continue-on-error: true
run: cargo clippy --workspace --all-targets
- name: Run tests
run: cargo test --workspace --all-targets
- name: Build release binaries
run: cargo build --release --workspace
linux-e2e-distros:
name: linux-e2e (${{ matrix.distro }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- distro: ubuntu-24.04
family: deb
image: ubuntu:24.04
- distro: debian-12
family: deb
image: debian:12
- distro: fedora-41
family: rpm
image: fedora:41
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run e2e in distro container
shell: bash
env:
DISTRO_IMAGE: ${{ matrix.image }}
DISTRO_FAMILY: ${{ matrix.family }}
run: |
set -euo pipefail
docker run --rm -e DISTRO_FAMILY="${DISTRO_FAMILY}" -v "$PWD:/work" -w /work "${DISTRO_IMAGE}" /bin/bash -lc '
set -euo pipefail
if [ "${DISTRO_FAMILY}" = "deb" ]; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl ca-certificates git build-essential pkg-config python3 python3-pip python3-venv
else
dnf install -y \
curl ca-certificates git gcc gcc-c++ make pkgconf-pkg-config python3 python3-pip
fi
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable
export PATH="$HOME/.cargo/bin:$PATH"
rustup --version
cargo --version
python3 -m venv /tmp/pc-venv
. /tmp/pc-venv/bin/activate
pip install --no-input proxy.py pproxy
nohup python3 -m pproxy -l socks5://127.0.0.1:19080 >/tmp/pproxy-socks5.log 2>&1 &
nohup python3 -m proxy --hostname 127.0.0.1 --port 18080 >/tmp/proxy-http.log 2>&1 &
sleep 2
printf "%s\n" \
"dynamic_chain" \
"proxy_dns" \
"tcp_connect_time_out 3000" \
"tcp_read_time_out 8000" \
"[ProxyList]" \
"socks5 127.0.0.1 19080" \
"http 127.0.0.1 18080" > ci.e2e.conf
cargo run -p proxychains-bin -- -f ./ci.e2e.conf --probe
cargo run -p proxychains-bin -- -f ./ci.e2e.conf --probe --probe-json > probe-report.json
grep -q "\"summary\"" probe-report.json
DNS_V4="$(cargo run -q -p proxychains-bin -- -q -f ./ci.e2e.conf python3 -c "import socket;print(socket.getaddrinfo(\"dns-proxychains-e2e.invalid\",443,0,socket.SOCK_STREAM)[0][4][0])" | tr -d "\r\n")"
echo "dns v4 fake ip: ${DNS_V4}"
DNS_V4="${DNS_V4}" python3 -c "import ipaddress, os; n = ipaddress.ip_network(\"224.0.0.0/8\"); ip = ipaddress.ip_address(os.environ[\"DNS_V4\"]); mapped = getattr(ip, \"ipv4_mapped\", None); ok = (ip.version == 4 and ip in n) or (ip.version == 6 and mapped is not None and mapped in n); assert ok"
DNS_V6="$(cargo run -q -p proxychains-bin -- -q -f ./ci.e2e.conf python3 -c "import socket;print(socket.getaddrinfo(\"dns-proxychains-e2e.invalid\",443,socket.AF_INET6,socket.SOCK_STREAM)[0][4][0])" | tr -d "\r\n")"
echo "dns v6 fake ip: ${DNS_V6}"
DNS_V6="${DNS_V6}" python3 -c "import ipaddress, os; n = ipaddress.ip_network(\"224.0.0.0/8\"); lo_min = int(ipaddress.ip_address(\"224.0.0.0\")); lo_max = int(ipaddress.ip_address(\"239.255.255.255\")); ip = ipaddress.ip_address(os.environ[\"DNS_V6\"]); mapped = getattr(ip, \"ipv4_mapped\", None); v4compat = ip.version == 6 and (int(ip) >> 32) == 0 and lo_min <= (int(ip) & 0xffffffff) <= lo_max; v4mapped = ip.version == 6 and mapped is not None and mapped in n; assert v4compat or v4mapped"
PROXYCHAINS_TEST_SOCKS5_ADDR=127.0.0.1:19080 \
PROXYCHAINS_TEST_HTTP_ADDR=127.0.0.1:18080 \
cargo test -p proxychains --test real_backends -- --nocapture
'