From 00f10b81f9f06213418e259d3a542382abb45049 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 21 Apr 2024 14:04:59 +0800 Subject: [PATCH] =?UTF-8?q?~=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=90=91systemd=E8=BE=93=E5=87=BA=E5=A4=A7?= =?UTF-8?q?=E9=87=8F=E6=97=A0=E7=94=A8=E6=97=A5=E5=BF=97=E7=9A=84bug=20~?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1=E4=BD=BF=E7=94=A86-2?= =?UTF-8?q?=E6=97=B6=E5=80=92=E5=85=A5=E5=A4=B1=E8=B4=A5=E7=9A=84bug=20~?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=9B=A0ipv6=E5=AF=BC=E8=87=B4=E7=9A=84dns=E5=8A=AB?= =?UTF-8?q?=E6=8C=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/menu.sh | 2 +- scripts/shellcrash.service | 4 ++-- scripts/start.sh | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/menu.sh b/scripts/menu.sh index 71037d8..9c63b57 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -15,7 +15,7 @@ source ${CRASHDIR}/configs/command.env 2>/dev/null setconfig(){ #参数1代表变量名,参数2代表变量值,参数3即文件路径 [ -z "$3" ] && configpath=${CFG_PATH} || configpath="${3}" - [ -n "$(grep "${1}=" "$configpath")" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath + grep -q "${1}=" "$configpath" && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || sed -i "\$a\\${1}=${2}" $configpath } ckcmd(){ command -v sh >/dev/null 2>&1 && command -v $1 >/dev/null 2>&1 || type $1 >/dev/null 2>&1 diff --git a/scripts/shellcrash.service b/scripts/shellcrash.service index e2fadd6..27f9c00 100644 --- a/scripts/shellcrash.service +++ b/scripts/shellcrash.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=shellcrash ExecStartPre=/etc/ShellCrash/start.sh bfstart -ExecStart=/etc/ShellCrash/CrashCore run -D /etc/ShellCrash -C /tmp/ShellCrash/jsons -ExecStartPost=/etc/ShellCrash/start.sh afstart >/dev/null & +ExecStart=/etc/ShellCrash/CrashCore run -D /etc/ShellCrash -C /tmp/ShellCrash/jsons >/dev/null +ExecStartPost=/etc/ShellCrash/start.sh afstart ExecStopPost=/etc/ShellCrash/start.sh stop_firewall ; /etc/ShellCrash/start.sh unset_proxy Restart=on-abnormal RestartSec=10s diff --git a/scripts/start.sh b/scripts/start.sh index 9125569..70dfe55 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -46,7 +46,7 @@ getconfig() { #读取配置及全局变量 setconfig() { #脚本配置工具 #参数1代表变量名,参数2代表变量值,参数3即文件路径 [ -z "$3" ] && configpath="$CRASHDIR"/configs/ShellCrash.cfg || configpath="${3}" - grep -q "${1}=" "$configpath" && sed -i "s#${1}=.*#${1}=${2}#g" "$configpath" || echo "${1}=${2}" >> "$configpath" + grep -q "${1}=" "$configpath" && sed -i "s#${1}=.*#${1}=${2}#g" "$configpath" || sed -i "\$a\\${1}=${2}" $configpath } ckcmd() { #检查命令是否存在 command -v sh >/dev/null 2>&1 && command -v "$1" >/dev/null 2>&1 || type "$1" >/dev/null 2>&1 @@ -968,6 +968,10 @@ start_ipt_dns() { #iptables-dns通用工具 $1 -t nat -A $3 -p udp -s $ip -j REDIRECT --to-ports $dns_port done fi + [ "$1" = 'ip6tables' ] && { + $1 -t nat -A $3 -p tcp -m comment --comment "ShellCrash-IPV6_DNS-REJECT" -j REJECT + $1 -t nat -A $3 -p udp -m comment --comment "ShellCrash-IPV6_DNS-REJECT" -j REJECT + } $1 -t nat -I $2 -p tcp --dport 53 -j $3 $1 -t nat -I $2 -p udp --dport 53 -j $3 }