Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: Configure route in post up script #144

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tunnel:
mtu: ${MTU}
ipv4: '${IPV4}'
ipv6: '${IPV6}'
post-up-script: '/route.sh'
socks5:
port: ${SOCKS5_PORT}
address: '${SOCKS5_ADDR}'
Expand All @@ -34,25 +35,26 @@ EOF
}

config_route() {
ip route add default dev ${TUN} table ${TABLE}
echo "#!/bin/sh" > /route.sh
chmod +x /route.sh

echo "ip route add default dev ${TUN} table ${TABLE}" >> /route.sh

for addr in $(echo ${IPV4_INCLUDED_ROUTES} | tr ',' '\n'); do
ip rule add to ${addr} table ${TABLE}
echo "ip rule add to ${addr} table ${TABLE}" >> /route.sh
done

for addr in $(echo ${IPV4_EXCLUDED_ROUTES} | tr ',' '\n'); do
ip rule add to ${addr} table main
echo "ip rule add to ${addr} table main" >> /route.sh
done

ip rule add fwmark 0x${MARK} table main pref 1
echo "ip rule add fwmark 0x${MARK} table main pref 1" >> /route.sh
}

run() {
config_file
hev-socks5-tunnel /hs5t.yml &
PID=$!
config_route
wait ${PID}
hev-socks5-tunnel /hs5t.yml
}

run || exit 1
Loading