fix: 🐛 自定义链未被主链调用

This commit is contained in:
jqtmviyu 2024-08-12 20:08:14 +08:00
parent 31c586b004
commit 5e7ef5c89a
2 changed files with 15 additions and 19 deletions

View File

@ -73,10 +73,10 @@ debug_echo_pass() {
# 打印自定义链规则 # 打印自定义链规则
print_chain_rules() { print_chain_rules() {
echo_info "当前IPv4自定义链规则:" echo_info "当前IPv4规则:"
iptables -nL $custom_chain_ipv4 iptables -L --line-numbers
echo_info "当前IPv6自定义链规则:" echo_info "当前IPv6规则:"
ip6tables -nL $custom_chain_ipv6 ip6tables -L --line-numbers
} }
print_log() { print_log() {
@ -171,13 +171,11 @@ create_chains_and_get_rules() {
# 确保自定义链在主链中被调用函数 # 确保自定义链在主链中被调用函数
ensure_chain_calls() { ensure_chain_calls() {
debug_echo_info "确保自定义链在主链中被调用..." debug_echo_info "确保自定义链在主链中被调用..."
iptables -C $chain -j $custom_chain_ipv4 & iptables -C $chain -j $custom_chain_ipv4 > /dev/null 2>&1 || (
>/dev/null || (
debug_echo_info "添加 $custom_chain_ipv4$chain" debug_echo_info "添加 $custom_chain_ipv4$chain"
iptables -A $chain -j $custom_chain_ipv4 iptables -A $chain -j $custom_chain_ipv4
) )
ip6tables -C $chain -j $custom_chain_ipv6 & ip6tables -C $chain -j $custom_chain_ipv6 > /dev/null 2>&1 || (
>/dev/null || (
debug_echo_info "添加 $custom_chain_ipv6$chain" debug_echo_info "添加 $custom_chain_ipv6$chain"
ip6tables -A $chain -j $custom_chain_ipv6 ip6tables -A $chain -j $custom_chain_ipv6
) )

View File

@ -49,10 +49,10 @@ BitComet 2.04"
# 打印自定义链规则 # 打印自定义链规则
print_chain_rules() { print_chain_rules() {
echo "当前IPv4自定义链规则:" echo_info "当前IPv4规则:"
iptables -nL $custom_chain_ipv4 iptables -L --line-numbers
echo "当前IPv6自定义链规则:" echo_info "当前IPv6规则:"
ip6tables -nL $custom_chain_ipv6 ip6tables -L --line-numbers
} }
print_log() { print_log() {
@ -151,15 +151,13 @@ create_chains_and_get_rules() {
# 确保自定义链在主链中被调用函数 # 确保自定义链在主链中被调用函数
ensure_chain_calls() { ensure_chain_calls() {
debug_echo "确保自定义链在主链中被调用..." debug_echo_info "确保自定义链在主链中被调用..."
iptables -C $chain -j $custom_chain_ipv4 & iptables -C $chain -j $custom_chain_ipv4 > /dev/null 2>&1 || (
>/dev/null || ( debug_echo_info "添加 $custom_chain_ipv4$chain"
debug_echo "添加 $custom_chain_ipv4$chain"
iptables -A $chain -j $custom_chain_ipv4 iptables -A $chain -j $custom_chain_ipv4
) )
ip6tables -C $chain -j $custom_chain_ipv6 & ip6tables -C $chain -j $custom_chain_ipv6 > /dev/null 2>&1 || (
>/dev/null || ( debug_echo_info "添加 $custom_chain_ipv6$chain"
debug_echo "添加 $custom_chain_ipv6$chain"
ip6tables -A $chain -j $custom_chain_ipv6 ip6tables -A $chain -j $custom_chain_ipv6
) )
} }