From 99247f7c8fc491506ad97ce6a00433de29185a95 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Sat, 25 Sep 2021 20:15:21 +0800 Subject: [PATCH] feat: bypass the private network automatically --- load.sh | 39 ++++++++++++++++++++------------------- tproxy.sh | 12 ++++++++++++ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/load.sh b/load.sh index aba3108..064e888 100755 --- a/load.sh +++ b/load.sh @@ -191,7 +191,7 @@ chmod +x $ASSET_DIR/update.sh } load_network_ipv4(){ -cat>"$NETWORK_DIR/ipv4"<"$NETWORK_DIR/interface/ipv4"<"$NETWORK_DIR/ipv6"<"$NETWORK_DIR/interface/ipv6"< /etc/resolv.conf - while read -r row - do - echo "nameserver $row" >> /etc/resolv.conf - done < $NETWORK_DIR/dns -fi +} + +init_dns(){ +cat /dev/null > /etc/resolv.conf +while read -r row +do + echo "nameserver $row" >> /etc/resolv.conf +done < $NETWORK_DIR/dns } load_ipv4(){ cat>$XRAY_DIR/expose/segment/ipv4<$XRAY_DIR/expose/segment/ipv6< /ipv4_range +while read -r segment +do + eval "iptables -t mangle -A XRAY -d $segment -j RETURN" +done < /ipv4_range +rm -f /ipv4_range while read -r segment do eval "iptables -t mangle -A XRAY -d $segment -j RETURN" @@ -15,6 +21,12 @@ iptables -t mangle -A PREROUTING -j XRAY ip -6 rule add fwmark 1 table 106 ip -6 route add local ::/0 dev lo table 106 ip6tables -t mangle -N XRAY6 +ip -6 addr | grep -w "inet6" | awk '{print $2}' > /ipv6_range +while read -r segment +do + eval "ip6tables -t mangle -A XRAY6 -d $segment -j RETURN" +done < /ipv6_range +rm -f /ipv6_range while read -r segment do eval "ip6tables -t mangle -A XRAY6 -d $segment -j RETURN"