Feature: support custom ICMP message handling #235
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| concurrency: | |
| group: test-${{ github.event_name }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| pull_request: | |
| jobs: | |
| unit: | |
| name: Unit Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| check-latest: true | |
| go-version-file: 'go.mod' | |
| - name: Run unit test | |
| run: | | |
| go test ./... | |
| build: | |
| name: Build Test | |
| needs: unit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| check-latest: true | |
| go-version-file: 'go.mod' | |
| - name: Run Go build | |
| run: make -j all | |
| - name: Run docker build | |
| run: docker build -t tun2socks:build . | |
| - name: Save image tarball | |
| run: docker save -o tun2socks-build.tar tun2socks:build | |
| - name: Upload image tarball | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: tun2socks-build-image | |
| path: tun2socks-build.tar | |
| retention-days: 1 | |
| e2e: | |
| name: E2E Test (${{ matrix.protocol }}) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - protocol: Direct | |
| proxy: direct:// | |
| udp: true | |
| - protocol: HTTP | |
| image: gogost/gost:latest | |
| args: -L "http://:8080" | |
| proxy: http://192.168.1.2:8080 | |
| udp: false | |
| - protocol: SOCKSv4 | |
| image: gogost/gost:latest | |
| args: -L "socks4://:1080" | |
| proxy: socks4://192.168.1.2:1080 | |
| udp: false | |
| - protocol: SOCKSv5 | |
| image: gogost/gost:latest | |
| args: -L "socks5://:1080?udp=true" | |
| proxy: socks5://192.168.1.2:1080 | |
| udp: true | |
| - protocol: Relay | |
| image: gogost/gost:latest | |
| args: -L "relay://:8420" | |
| proxy: relay://192.168.1.2:8420 | |
| udp: true | |
| - protocol: Shadowsocks | |
| image: ghcr.io/shadowsocks/ssserver-rust:latest | |
| args: ssserver -s 0.0.0.0:8388 -k pass -m aes-128-gcm -U -v | |
| proxy: ss://aes-128-gcm:[email protected]:8388 | |
| udp: true | |
| - protocol: SSH | |
| image: gogost/gost:3.0.0-nightly.20241002 | |
| args: -L "sshd://user:pass@:2222" | |
| proxy: ssh://user:[email protected]:2222 | |
| udp: false | |
| env: | |
| TUN_IF: tun0 | |
| RESTAPI_PORT: 8080 | |
| SUBNET_NAME: e2e-net | |
| SUBNET_PREFIX: 192.168.1 | |
| APP_IPERF: iperf | |
| APP_PROXY: proxy | |
| APP_TESTER: tester | |
| APP_TUN2SOCKS: tun2socks | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Download image tarball | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: tun2socks-build-image | |
| - name: Load image tarball | |
| run: docker load -i tun2socks-build.tar | |
| - name: Create E2E Dockerfile | |
| run: | | |
| cat > Dockerfile.e2e <<EOF | |
| FROM tun2socks:build | |
| RUN apk add --update --no-cache \ | |
| bind-tools curl iperf3 | |
| EOF | |
| - name: Build E2E image | |
| run: docker build -f Dockerfile.e2e -t tun2socks:e2e . | |
| - name: Create test network | |
| run: | | |
| docker network create \ | |
| --driver bridge \ | |
| --subnet "${SUBNET_PREFIX}.0/24" \ | |
| "${SUBNET_NAME}" | |
| - name: Start proxy | |
| if: ${{ matrix.image }} | |
| run: | | |
| docker run -d \ | |
| --name "${APP_PROXY}" \ | |
| --network "${SUBNET_NAME}" \ | |
| --ip "${SUBNET_PREFIX}.2" \ | |
| ${{ matrix.image }} ${{ matrix.args }} | |
| - name: Start iperf | |
| run: | | |
| docker run -d \ | |
| --name "${APP_IPERF}" \ | |
| --network "${SUBNET_NAME}" \ | |
| --ip "${SUBNET_PREFIX}.3" \ | |
| networkstatic/iperf3:latest \ | |
| -s --logfile /dev/null | |
| - name: Start tun2socks | |
| env: | |
| PROXY: ${{ matrix.proxy }} | |
| run: | | |
| docker run -d \ | |
| --name "${APP_TUN2SOCKS}" \ | |
| --cap-add=NET_ADMIN \ | |
| --device /dev/net/tun:/dev/net/tun \ | |
| --network "${SUBNET_NAME}" \ | |
| --ip "${SUBNET_PREFIX}.4" \ | |
| -e TUN="${TUN_IF}" \ | |
| -e PROXY="${PROXY}" \ | |
| -e LOGLEVEL=debug \ | |
| -e RESTAPI=":${RESTAPI_PORT}" \ | |
| -p "${RESTAPI_PORT}:${RESTAPI_PORT}" \ | |
| tun2socks:e2e | |
| - name: Start tester | |
| run: | | |
| docker run -d \ | |
| --name "${APP_TESTER}" \ | |
| --cap-add=NET_ADMIN \ | |
| --network "${SUBNET_NAME}" \ | |
| --entrypoint sh \ | |
| tun2socks:e2e \ | |
| -c "sleep infinite" | |
| - name: Set up tester | |
| run: docker exec "${APP_TESTER}" ip route add 1.1.1.1 via "${SUBNET_PREFIX}.4" | |
| - name: Check readiness | |
| run: | | |
| for i in $(seq 1 10); do | |
| if curl -fsS --max-time 2 -o /dev/null "http://localhost:${RESTAPI_PORT}"; then | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| exit 1 | |
| - name: Test ICMP via Ping | |
| run: docker exec "${APP_TUN2SOCKS}" ping -c 5 -W 5 12.34.56.78 | |
| - name: Test TCP via HTTP | |
| run: | | |
| docker exec "${APP_TUN2SOCKS}" curl -4 -fsS -v --max-time 10 -o /dev/null \ | |
| http://connectivitycheck.gstatic.com/generate_204 | |
| - name: Test UDP via DNS | |
| if: ${{ matrix.udp }} | |
| run: docker exec "${APP_TUN2SOCKS}" dig @8.8.8.8 www.google.com +tries=2 | |
| - name: Test UDP via QUIC | |
| if: ${{ matrix.udp }} | |
| run: | | |
| docker exec "${APP_TUN2SOCKS}" curl -4 -fsS -v --max-time 10 -o /dev/null \ | |
| --http3-only https://cloudflare-quic.com | |
| - name: Test upload speed via iPerf | |
| run: | | |
| docker exec "${APP_TUN2SOCKS}" iperf3 --bind-dev "${TUN_IF}" \ | |
| --connect-timeout 2000 -c "${SUBNET_PREFIX}.3" | |
| - name: Test download speed via iPerf | |
| run: | | |
| docker exec "${APP_TUN2SOCKS}" iperf3 --bind-dev "${TUN_IF}" \ | |
| --connect-timeout 2000 -c "${SUBNET_PREFIX}.3" -R | |
| - name: Test routing (ICMP) | |
| run: docker exec "${APP_TESTER}" ping -c 5 -W 5 1.1.1.1 | |
| - name: Test routing (TCP) | |
| run: docker exec "${APP_TESTER}" curl -4 -fsS -v --max-time 10 -o /dev/null 1.1.1.1 | |
| - name: Test routing (UDP) | |
| if: ${{ matrix.udp }} | |
| run: docker exec "${APP_TESTER}" dig @1.1.1.1 www.cloudflare.com +tries=2 | |
| - name: Dump proxy logs | |
| if: always() | |
| run: | | |
| docker logs "${APP_PROXY}" || true | |
| - name: Dump tun2socks logs | |
| if: always() | |
| run: | | |
| docker logs "${APP_TUN2SOCKS}" || true | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| docker rm -f "${APP_TUN2SOCKS}" || true | |
| docker rm -f "${APP_TESTER}" || true | |
| docker rm -f "${APP_IPERF}" || true | |
| docker rm -f "${APP_PROXY}" || true | |
| docker network rm "${SUBNET_NAME}" || true |