mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 08:30:53 +00:00
Merge branch 'master' into windows
This commit is contained in:
commit
ff6499f53b
3 changed files with 86 additions and 0 deletions
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
####################################################################################################
|
||||||
|
## Builder
|
||||||
|
####################################################################################################
|
||||||
|
FROM rust:latest AS builder
|
||||||
|
|
||||||
|
WORKDIR /worker
|
||||||
|
COPY ./ .
|
||||||
|
RUN cargo build --release --target x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
## Final image
|
||||||
|
####################################################################################################
|
||||||
|
FROM ubuntu:latest
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV TUN=tun0
|
||||||
|
ENV PROXY=
|
||||||
|
ENV DNS=virtual
|
||||||
|
ENV MODE=auto
|
||||||
|
ENV BYPASS_IP=
|
||||||
|
|
||||||
|
RUN apt update && apt install -y iproute2 curl && apt clean all
|
||||||
|
|
||||||
|
COPY --from=builder /worker/target/x86_64-unknown-linux-gnu/release/tun2proxy /usr/bin/tun2proxy
|
||||||
|
COPY --from=builder /worker/docker/entrypoint.sh /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
29
README.md
29
README.md
|
@ -108,6 +108,35 @@ Currently, tun2proxy supports HTTP, SOCKS4/SOCKS4a and SOCKS5. A proxy is suppli
|
||||||
URL format. For example, an HTTP proxy at `1.2.3.4:3128` with a username of `john.doe` and a password of `secret` is
|
URL format. For example, an HTTP proxy at `1.2.3.4:3128` with a username of `john.doe` and a password of `secret` is
|
||||||
supplied as `--proxy http://john.doe:secret@1.2.3.4:3128`. This works analogously to curl's `--proxy` argument.
|
supplied as `--proxy http://john.doe:secret@1.2.3.4:3128`. This works analogously to curl's `--proxy` argument.
|
||||||
|
|
||||||
|
## Docker Support
|
||||||
|
Tun2proxy can serve as a proxy for other Docker containers. To make use of that feature, first build the image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t tun2proxy .
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, start a container from the tun2proxy image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
|
-e PROXY=PROXY_TYPE://PROXY_IP:PROXY_PORT \
|
||||||
|
-v /dev/net/tun:/dev/net/tun \
|
||||||
|
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
|
||||||
|
--sysctl net.ipv6.conf.default.disable_ipv6=0 \
|
||||||
|
--cap-add NET_ADMIN \
|
||||||
|
--name tun2proxy \
|
||||||
|
tun2proxy
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then provide the running container's network to another worker container by sharing the network namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it \
|
||||||
|
-d \
|
||||||
|
--network "container:tun2proxy" \
|
||||||
|
ubuntu:latest
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration Tips
|
## Configuration Tips
|
||||||
### DNS
|
### DNS
|
||||||
When DNS resolution is performed by a service on your machine or through a server in your local network, DNS resolution
|
When DNS resolution is performed by a service on your machine or through a server in your local network, DNS resolution
|
||||||
|
|
29
docker/entrypoint.sh
Executable file
29
docker/entrypoint.sh
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
run() {
|
||||||
|
if [ -n "$BYPASS_IP" ]; then
|
||||||
|
BYPASS_IP="--bypass $BYPASS_IP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$DNS" ]; then
|
||||||
|
DNS="--dns $DNS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$MODE" ]; then
|
||||||
|
MODE="--setup $MODE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$PROXY" ]; then
|
||||||
|
PROXY="--proxy $PROXY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TUN" ]; then
|
||||||
|
TUN="--tun $TUN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec tun2proxy $TUN $PROXY $DNS $MODE $BYPASS_IP
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run || echo "Runing ERROR!!"
|
Loading…
Add table
Add a link
Reference in a new issue