adjust scripts
This commit is contained in:
@@ -7,13 +7,14 @@ source /data/adb/box/settings.ini
|
||||
table="222"
|
||||
fwmark="223"
|
||||
pref="100"
|
||||
|
||||
# iptables_version=$(iptables -V | grep -o "v1\.[0-9]")
|
||||
# if [ "${iptables_version}" = "v1.4" ] ; then
|
||||
# iptables_x="iptables"
|
||||
# ip6tables_x="ip6tables"
|
||||
# ipts="iptables"
|
||||
# ip6ts="ip6tables"
|
||||
# else
|
||||
# iptables_x="iptables -w 100"
|
||||
# ip6tables_x="ip6tables -w 100"
|
||||
# ipts="iptables -w 100"
|
||||
# ip6ts="ip6tables -w 100"
|
||||
# fi
|
||||
|
||||
probe_user_group() {
|
||||
@@ -42,6 +43,7 @@ ipv6_enable() {
|
||||
echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6
|
||||
echo 0 > /proc/sys/net/ipv6/conf/wlan0/disable_ipv6
|
||||
}
|
||||
|
||||
intranet=(0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 169.254.0.0/16 192.0.0.0/24 192.0.2.0/24 192.88.99.0/24 192.168.0.0/16 198.51.100.0/24 203.0.113.0/24 224.0.0.0/4 240.0.0.0/4 255.255.255.255/32)
|
||||
intranet6=(::/128 ::1/128 ::ffff:0:0/96 100::/64 64:ff9b::/96 2001::/32 2001:10::/28 2001:20::/28 2001:db8::/32 2002::/16 fe80::/10 ff00::/8)
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ create_tun() {
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
[ ! -e "/dev/net/tun" ] && \
|
||||
mkdir -p /dev/net && ln -s /dev/tun /dev/net/tun
|
||||
# mkdir -p /dev/net
|
||||
# [ ! -L /dev/net/tun ] && ln -sf /dev/tun /dev/net/tun
|
||||
# mkdir -p /dev/net
|
||||
# [ ! -L /dev/net/tun ] && ln -sf /dev/tun /dev/net/tun
|
||||
}
|
||||
|
||||
run_box() {
|
||||
@@ -140,7 +140,8 @@ run_box() {
|
||||
ulimit -SHn 1000000
|
||||
case "${bin_name}" in
|
||||
sing-box)
|
||||
[ "${proxy_mode}" = "core" ] && log info "don't forget to set 'auto detect interface': true"
|
||||
[ "${proxy_mode}" = "core" ] && \
|
||||
log info "don't forget to set 'auto detect interface': true"
|
||||
# && (sed -i 's/"auto_detect_interface":.*/"auto_detect_interface": true/' ${data_dir}/sing-box/config.json) || (sed -i 's/"auto_detect_interface":.*/"auto_detect_interface": false/' ${data_dir}/sing-box/config.json)
|
||||
sed -i 's/network_mode=.*/network_mode="tproxy"/' ${settings}
|
||||
if (${bin_path} check -D ${data_dir}/${bin_name} > "${run_path}/${bin_name}-report.log" 2>&1) ; then
|
||||
@@ -250,23 +251,26 @@ crontab_alive() {
|
||||
crontab -c ${run_path} -r
|
||||
touch ${run_path}/root
|
||||
chmod 0600 ${run_path}/root
|
||||
[ "${static_dns1}" != "" ] && echo "*/1 * * * * ${scripts_dir}/box.tool keepdns" >> ${run_path}/root && log info "dns remains open."
|
||||
[ "${bin_name}" = "clash" ] && log info "configuration ${clash_config}."
|
||||
[ "${static_dns1}" != "" ] && \
|
||||
echo "*/1 * * * * ${scripts_dir}/box.tool keepdns" >> ${run_path}/root && log info "dns remains open."
|
||||
[ "${bin_name}" = "clash" ] && \
|
||||
log info "configuration ${clash_config}."
|
||||
crontab_geo
|
||||
}
|
||||
|
||||
network_port () {
|
||||
if [ "${network_mode}" = "mixed" ] || [ "${proxy_mode}" = "core" ] ; then
|
||||
$(/system/bin/ifconfig | grep -q ${tun_device}) || log error "tun_device: ${tun_device} not found"
|
||||
fi
|
||||
if [ "${clash_tun_status}" = "false" ] ; then
|
||||
$(/system/bin/netstat -tnulp | grep -q "${tproxy_port}") || log debug "tproxy_port out of sync with config"
|
||||
$(/system/bin/netstat -tnulp | grep -q "${tproxy_port}") || \
|
||||
log debug "tproxy_port out of sync with config"
|
||||
fi
|
||||
if [ "${network_mode}" = "mixed" ] || [ "${proxy_mode}" = "core" ] ; then
|
||||
$(/system/bin/ifconfig | grep -q ${tun_device}) || \
|
||||
log error "tun_device: ${tun_device} not found"
|
||||
fi
|
||||
}
|
||||
|
||||
start_box() {
|
||||
echo -n "" > ${logs_file}
|
||||
|
||||
[ -t 1 ] && echo "\033[1;31m$(date)\033[0m" || echo "$(date)" | tee -a ${logs_file} >> /dev/null 2>&1
|
||||
line="--------------------------------------------"
|
||||
[ -t 1 ] && echo "\033[1;32m$line\033[0m" || echo "$line" | tee -a ${logs_file} >> /dev/null 2>&1
|
||||
@@ -280,12 +284,12 @@ start_box() {
|
||||
check_in_bin || log error "kernel ${bin_name} corrupted."
|
||||
delete_logs
|
||||
create_tun
|
||||
run_box
|
||||
sleep 1
|
||||
[ "${crontab_sec}" != "false" ] && crontab_alive || log info "crontab: disable."
|
||||
run_box && sleep 1
|
||||
[ "${crontab_sec}" != "false" ] && \
|
||||
crontab_alive || log info "crontab: disable."
|
||||
cgroup_limit
|
||||
detected_port || sleep 1
|
||||
network_port
|
||||
# network_port
|
||||
still_alive
|
||||
display_bin_pid
|
||||
}
|
||||
@@ -325,8 +329,8 @@ case "$1" in
|
||||
clash)echo -e "$(${bin_path} -v)";;
|
||||
*)echo -e "$(${bin_path} version)";;
|
||||
esac
|
||||
[ $(pidof ${bin_name}) ] \
|
||||
&& bin_usage || log warn "${bin_name} service is stopped"
|
||||
[ $(pidof ${bin_name}) ] && \
|
||||
bin_usage || log warn "${bin_name} service is stopped"
|
||||
;;
|
||||
reload)
|
||||
if [ "${bin_name}" = "clash" ] ; then
|
||||
|
||||
Reference in New Issue
Block a user