Skip to content

Commit

Permalink
luci: checking geo files when using shunt nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
lwb1978 committed Jan 27, 2025
1 parent 7c4b66e commit f26bb6f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion luci-app-passwall/root/usr/share/passwall/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ get_geoip() {
local geoip_type_flag=""
local geoip_path="$(config_t_get global_rules v2ray_location_asset)"
geoip_path="${geoip_path%*/}/geoip.dat"
[ -e "$geoip_path" ] || { echo ""; return; }
[ -s "$geoip_path" ] || { echo ""; return; }
case "$2" in
"ipv4") geoip_type_flag="-ipv6=false" ;;
"ipv6") geoip_type_flag="-ipv4=false" ;;
Expand Down Expand Up @@ -773,9 +773,26 @@ run_redir() {
run_ipt2socks flag=default proto=UDP local_port=${local_port} socks_address=${_socks_address} socks_port=${_socks_port} socks_username=${_socks_username} socks_password=${_socks_password} log_file=${log_file}
;;
sing-box)
local protocol=$(config_n_get $node protocol)
[ "$protocol" = "_shunt" ] && {
local geoip_path="$(config_t_get global_singbox geoip_path)"
local geosite_path="$(config_t_get global_singbox geosite_path)"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,UDP Sing-Box分流节点无法正常使用!"
fi
}
run_singbox flag=UDP node=$node udp_redir_port=$local_port config_file=$config_file log_file=$log_file
;;
xray)
local protocol=$(config_n_get $node protocol)
[ "$protocol" = "_shunt" ] && {
local geo_path="$(config_t_get global_rules v2ray_location_asset)"
local geoip_path="${geo_path%*/}/geoip.dat"
local geosite_path="${geo_path%*/}/geosite.dat"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,UDP Xray分流节点无法正常使用!"
fi
}
run_xray flag=UDP node=$node udp_redir_port=$local_port config_file=$config_file log_file=$log_file
;;
trojan*)
Expand Down Expand Up @@ -875,6 +892,14 @@ run_redir() {
echolog "* 当前TCP节点采用Sing-Box分流且默认节点为直连,远程DNS过滤模式将默认使用Sing-Box(TCP),防止环回!"
}

[ "$protocol" = "_shunt" ] && {
local geoip_path="$(config_t_get global_singbox geoip_path)"
local geosite_path="$(config_t_get global_singbox geosite_path)"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,TCP Sing-Box分流节点无法正常使用!"
fi
}

[ "${DNS_MODE}" = "sing-box" ] && {
NO_PLUGIN_DNS=1
config_file=$(echo $config_file | sed "s/.json/_DNS.json/g")
Expand Down Expand Up @@ -953,6 +978,15 @@ run_redir() {
echolog "* 当前TCP节点采用Xray分流且默认节点为直连,远程DNS过滤模式将默认使用Xray(TCP),防止环回!"
}

[ "$protocol" = "_shunt" ] && {
local geo_path="$(config_t_get global_rules v2ray_location_asset)"
local geoip_path="${geo_path%*/}/geoip.dat"
local geosite_path="${geo_path%*/}/geosite.dat"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,TCP Xray分流节点无法正常使用!"
fi
}

[ "${DNS_MODE}" = "xray" ] && {
NO_PLUGIN_DNS=1
config_file=$(echo $config_file | sed "s/.json/_DNS.json/g")
Expand Down

0 comments on commit f26bb6f

Please sign in to comment.