Skip to content

Commit

Permalink
Fix Missing redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
twnesss committed Jun 24, 2024
1 parent 6725e28 commit cb26706
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions box/scripts/box.iptables
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ disable_ipv6() {
sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.wlan0.disable_ipv6=1

ip -6 rule add unreachable pref "${pref}"
# ip -6 rule add unreachable pref "${pref}"
} >> /dev/null 2>&1

ipv6_enable() {
Expand All @@ -130,7 +130,7 @@ ipv6_enable() {
sysctl -w net.ipv6.conf.default.disable_ipv6=0
sysctl -w net.ipv6.conf.wlan0.disable_ipv6=0

ip -6 rule del unreachable pref "${pref}"
# ip -6 rule del unreachable pref "${pref}"

$IP6V -A OUTPUT -p udp --destination-port 53 -j DROP
} >> /dev/null 2>&1
Expand Down Expand Up @@ -659,6 +659,34 @@ if [[ "${network_mode}" == @(redirect|mixed|tproxy|enhance) ]]; then
log Warning "Disabling IPv6."
fi
;;
redirect)
log Info "Using Redirect: tcp + udp (direct)."
log Info "Creating iptables transparent proxy rules."

iptables="$IPV"
if start_redirect; then
log Info "Creating iptables transparent proxy rules done."
else
log Error "Creating iptables transparent proxy rule failed."
stop_redirect >> /dev/null 2>&1
fi

if [ "${ipv6}" = "true" ]; then
log Debug "Using IPv6."
ipv6_enable
iptables="$IP6V"

if start_redirect; then
log Info "Creating ip6tables transparent proxy rules done."
else
log Error "Creating ip6tables transparent proxy rule failed."
stop_redirect >> /dev/null 2>&1
fi
else
disable_ipv6
log Warning "Disabling IPv6."
fi
;;
mixed)
log Info "Using Mixed: tcp(redirect) + udp(tun)."
log Info "Creating iptables transparent proxy rules."
Expand Down Expand Up @@ -792,4 +820,4 @@ else
echo "${yellow}Usage:${normal} ${green}$0${normal} {${yellow}enable|disable|renew${normal}}"
;;
esac
fi
fi

0 comments on commit cb26706

Please sign in to comment.