Chore: optimize docker files

This commit is contained in:
xjasonlyu
2021-02-07 14:44:56 +08:00
parent 6fd3fd0f8c
commit 2fe6caab12
3 changed files with 14 additions and 9 deletions

View File

@@ -17,12 +17,13 @@ COPY --from=builder /tun2socks /usr/bin/tun2socks
RUN apk add --update --no-cache iptables iproute2 \
&& chmod +x /entrypoint.sh
ENV TUN tun0
ENV ETH eth0
ENV TUN=tun0
ENV ETH=eth0
ENV TUN_ADDR=198.18.0.1
ENV TUN_MASK=255.254.0.0
ENV LOGLEVEL=INFO
ENV PROXY=direct://
ENV MTU=9000
ENV STATS=
ENV TOKEN=
ENV EXTRA_COMMANDS=

View File

@@ -9,10 +9,15 @@ services:
- '/dev/net/tun:/dev/net/tun'
environment:
- GODEBUG=madvdontneed=1
- LOGLEVEL=WARN
- LOGLEVEL=
- TUN=
- ETH=
- TUN_ADDR=
- TUN_MASK=
- PROXY=
- STATS=
- TOKEN=
- MTU=
- EXTRA_COMMANDS=
- TUN_INCLUDED_ROUTES=
- TUN_EXCLUDED_ROUTES=

View File

@@ -43,11 +43,6 @@ config_route() {
ip rule add from "$eth" priority 9999 table main
ip rule add from all priority 10000 table "$TABLE"
# reserved IP addresses
ip rule add to 0.0.0.0/8 table main
ip rule add to 192.0.2.0/24 table main
ip rule add to 224.0.0.0/4 table main
# add tun included routes
for addr in $(echo "$TUN_INCLUDED_ROUTES" | tr ',' '\n'); do
ip rule add to "$addr" table "$TABLE"
@@ -68,8 +63,12 @@ main() {
sh -c "$EXTRA_COMMANDS"
fi
if [ -n "$MTU" ]; then
ARGS="--mtu $MTU"
fi
if [ -n "$STATS" ]; then
ARGS="--stats $STATS"
ARGS="$ARGS --stats $STATS"
fi
if [ -n "$TOKEN" ]; then