From ac60f39a883db45f06f18fcfff53a742a0391510 Mon Sep 17 00:00:00 2001 From: "B. Blechschmidt" Date: Tue, 21 Mar 2023 23:15:16 +0100 Subject: [PATCH 1/2] Add Dockerfile and test script for tests --- tests/Dockerfile | 9 +++++++++ tests/run-tests.sh | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/Dockerfile create mode 100755 tests/run-tests.sh diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000..6946914 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:edge +RUN apk add --no-cache cargo rust pkgconfig openssl-dev +RUN mkdir /tun2proxy +ADD src /tun2proxy/src +ADD Cargo.toml /tun2proxy/Cargo.toml +ADD tests /tun2proxy/tests +WORKDIR /tun2proxy +RUN cargo build --tests +ENTRYPOINT ["cargo", "test"] diff --git a/tests/run-tests.sh b/tests/run-tests.sh new file mode 100755 index 0000000..78d1454 --- /dev/null +++ b/tests/run-tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +# Run as follows: +# sudo SOCKS5_SERVER=: HTTP_SERVER=: ./run-tests.sh +# +# Alternatively, `cargo test` can be used instead of `./run-tests.sh`. +# Note that the tests require root privileges and will change +# the system's default routes. + +SCRIPT_DIR="$(dirname "$0")" +cd "$SCRIPT_DIR/.." +docker build -t tun2proxy-tests -f tests/Dockerfile . && docker run -e SOCKS5_SERVER -e HTTP_SERVER --rm -it tun2proxy-tests From 730d8c7045932492b42bd71524bbbdd876677462 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Wed, 22 Mar 2023 10:24:55 +0800 Subject: [PATCH 2/2] Remove the modification to the routing table --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 28818dc..04996af 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,15 @@ Note that if you paste these commands into a shell script, which you then run wi For DNS to work, you might need an additional tool like [dnsproxy](https://github.com/AdguardTeam/dnsproxy) that is configured to listen on a local UDP port and communicates with the upstream DNS server via TCP. +When you end the running of this program and want to eliminate the impact caused by the above several commands, +you can execute the following commands. +```shell +sudo ip route del 0.0.0.0/1 dev tun0 +sudo ip route del 128.0.0.0/1 dev tun0 +sudo ip link set tun0 down +sudo ip tuntap del tun0 mode tun +``` + ## CLI ``` Tunnel interface to proxy.