4 Commits

Author SHA1 Message Date
juewuy
b4a9702c82 Merge pull request #1248 from abcfy2/dev
添加 `.editorconfig` 配置,约束 `*.sh` 文件格式
2026-03-27 21:30:47 -07:00
juewuy
ee2fd53675 Merge pull request #1249 from abcfy2/fix/ipv6-dns
修复 ipv6 DNS 拦截错误的网段
2026-03-27 21:30:34 -07:00
Feng Yu
39084ffd1e 修复 ipv6 DNS 拦截错误的网段 2026-03-28 12:03:18 +08:00
Feng Yu
200d1729fb 添加 .editorconfig 配置,约束 *.sh 文件格式 2026-03-26 12:04:13 +08:00
3 changed files with 36 additions and 23 deletions

13
.editorconfig Normal file
View File

@@ -0,0 +1,13 @@
root = true
[*]
charset = utf-8
end_of_line = lf
[*.sh]
indent_style = space
indent_size = 4
shell_variant = posix
simplify = true
switch_case_indent = true

View File

@@ -1,9 +1,10 @@
getlanip() { #获取局域网host地址
i=1
while [ "$i" -le "20" ]; do
host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}') #ipv4局域网网段
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip -6 route show default | awk '{print $3}' | tr '\n' ' ' | sed 's/ $//') #ipv6公网地址段
#ipv4局域网网段
host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}')
#ipv6局域网网段
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip -6 route show | grep -Ev 'default|unreachable|fe80::/|wan|ppp|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}' | tr '\n' ' ' | sed 's/ $//')
[ -f "$TMPDIR"/ShellCrash.log ] && break
[ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break
[ -n "$host_ipv4" -a -n "$host_ipv6" ] && break
@@ -24,7 +25,7 @@ getlanip() { #获取局域网host地址
if [ "$replace_default_host_ipv4" == "ON" ]; then
host_ipv4="$cust_host_ipv4"
else
host_ipv4=$(echo "$host_ipv4 $cust_host_ipv4$ts_host_ipv4$wg_host_ipv4"| tr '\n' ' ' | sed 's/ $//')
host_ipv4=$(echo "$host_ipv4 $cust_host_ipv4$ts_host_ipv4$wg_host_ipv4" | tr '\n' ' ' | sed 's/ $//')
fi
#缺省配置
[ -z "$host_ipv4" ] && {

View File

@@ -14,9 +14,9 @@ while [ ! -f "$CRASHDIR/configs/ShellCrash.cfg" ]; do
done
. "$CRASHDIR"/configs/ShellCrash.cfg
autoSSH(){
autoSSH() {
#自动开启SSH
[ "`uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL`" != 'stable' ] && {
[ "$(uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL)" != 'stable' ] && {
uci -c /usr/share/xiaoqiang set xiaoqiang_version.version.CHANNEL='stable'
uci -c /usr/share/xiaoqiang commit xiaoqiang_version.version
}
@@ -28,13 +28,13 @@ autoSSH(){
#配置nvram
[ "$(nvram get ssh_en)" = 0 ] && nvram set ssh_en=1
[ "$(nvram get telnet_en)" = 0 ] && nvram set telnet_en=1
nvram commit &> /dev/null
nvram commit >/dev/null 2>&1
#备份还原SSH秘钥
[ -f "$CRASHDIR"/configs/dropbear_rsa_host_key ] && ln -sf "$CRASHDIR"/configs/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
[ -f "$CRASHDIR"/configs/authorized_keys ] && ln -sf "$CRASHDIR"/configs/authorized_keys /etc/dropbear/authorized_keys
}
tunfix(){
ko_dir=$(modinfo ip_tables | grep -Eo '/lib/modules.*/ip_tables.ko' | sed 's|/ip_tables.ko||' )
tunfix() {
ko_dir=$(modinfo ip_tables | grep -Eo '/lib/modules.*/ip_tables.ko' | sed 's|/ip_tables.ko||')
#在/tmp创建并挂载overlay
mkdir -p /tmp/overlay
mkdir -p /tmp/overlay/upper
@@ -43,12 +43,12 @@ tunfix(){
#将tun.ko链接到lib
ln -sf "$CRASHDIR"/tools/tun.ko "$ko_dir"/tun.ko
}
tproxyfix(){
tproxyfix() {
sed -i 's/sysctl -w net.bridge.bridge-nf-call-ip/#sysctl -w net.bridge.bridge-nf-call-ip/g' /etc/init.d/qca-nss-ecm
sysctl -w net.bridge.bridge-nf-call-iptables=0
sysctl -w net.bridge.bridge-nf-call-ip6tables=0
}
auto_clean(){
auto_clean() {
#自动清理升级备份文件夹
rm -rf /data/etc_bak
#自动清理被写入闪存的系统日志并禁止服务
@@ -59,7 +59,7 @@ auto_clean(){
rm -rf /data/usr/log /data/usr/sec_cfg
}
auto_start(){
auto_start() {
#设置init.d服务
[ ! -x /etc/init.d/shellcrash ] && {
cp -f "$CRASHDIR"/starts/shellcrash.procd /etc/init.d/shellcrash
@@ -83,12 +83,12 @@ auto_start(){
/etc/init.d/shellcrash start && /etc/init.d/shellcrash enable
fi
}
init(){
init() {
#等待启动完成
while ! ip a| grep -q lan; do
while ! ip a | grep -q lan; do
sleep 10
done
autoSSH #软固化功能
autoSSH #软固化功能
auto_clean #自动清理
auto_start
#启动自定义服务
@@ -103,9 +103,8 @@ case "$1" in
auto_clean) auto_clean ;;
init) init ;;
*)
if [ -z "$(pidof CrashCore)" ];then
if [ -z "$(pidof CrashCore)" ]; then
init &
fi
;;
;;
esac