mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-07-28 03:01:54 +08:00
💋 Sync 2026-04-09 03:05:33
This commit is contained in:
parent
9ee1d95299
commit
fa527e2e56
@ -566,7 +566,7 @@ o = s:taboption("DNS", DynamicList, "ad_url", translate("Anti-AD Rules Subscribe
|
||||
o:value("https://cdn.jsdelivr.net/gh/privacy-protection-tools/anti-AD/anti-ad-domains.txt", translate("anti-AD"))
|
||||
o:value("https://cdn.jsdelivr.net/gh/neodevpro/neodevhost/domain", translate("NEO DEV HOST"))
|
||||
o.default = "https://cdn.jsdelivr.net/gh/privacy-protection-tools/anti-AD/anti-ad-domains.txt"
|
||||
o.description = translate("Support Domain and Dnsmasq format list")
|
||||
o.description = translate("Support Domain / Dnsmasq / Hosts format list")
|
||||
o:depends("adblock",1)
|
||||
|
||||
s:tab("Proxy", translate("Mode"))
|
||||
|
||||
@ -31,8 +31,8 @@ msgstr "上一次规则更新时间"
|
||||
msgid "Subscribe Rules Data"
|
||||
msgstr "去广告规则"
|
||||
|
||||
msgid "Support Domain and Dnsmasq format list"
|
||||
msgstr "支持域名和Dnsmasq格式的过滤列表"
|
||||
msgid "Support Domain / Dnsmasq / Hosts format list"
|
||||
msgstr "支持 域名/Dnsmasq/Hosts 格式的过滤列表"
|
||||
|
||||
msgid "Anti-AD Rules Subscribe"
|
||||
msgstr "广告过滤列表URL"
|
||||
|
||||
@ -57,6 +57,8 @@ process_url() {
|
||||
sample_count++
|
||||
if (fmt == "" && $0 ~ /^address=\/[^\/]+\//) fmt = "dnsmasq"
|
||||
if (fmt == "" && $0 ~ /^DOMAIN-SUFFIX,/) fmt = "clash"
|
||||
if (fmt == "" && $0 ~ /^(0\.0\.0\.0|127\.0\.0\.1)[[:space:]]/)
|
||||
fmt = "hosts"
|
||||
if (fmt == "" && $0 ~ /^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)+$/)
|
||||
fmt = "plain"
|
||||
}
|
||||
@ -68,6 +70,16 @@ process_url() {
|
||||
if (n >= 3 && a[1] == "address=") print a[2]
|
||||
} else if (fmt == "clash") {
|
||||
if (sub(/^DOMAIN-SUFFIX,/, "")) print
|
||||
} else if (fmt == "hosts") {
|
||||
# 0.0.0.0 domain.com 或 127.0.0.1 domain.com
|
||||
if ($0 ~ /^(0\.0\.0\.0|127\.0\.0\.1)[[:space:]]/) {
|
||||
domain = $2
|
||||
# 去掉行尾可能的注释
|
||||
gsub(/#.*/, "", domain)
|
||||
gsub(/[[:space:]]/, "", domain)
|
||||
if (domain != "" && domain != "localhost")
|
||||
print domain
|
||||
}
|
||||
} else if (fmt == "plain") {
|
||||
if ($0 ~ /^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)+$/)
|
||||
print
|
||||
|
||||
@ -17,6 +17,8 @@ UTIL_TROJAN=$LUA_UTIL_PATH/util_trojan.lua
|
||||
UTIL_NAIVE=$LUA_UTIL_PATH/util_naiveproxy.lua
|
||||
UTIL_HYSTERIA2=$LUA_UTIL_PATH/util_hysteria2.lua
|
||||
UTIL_TUIC=$LUA_UTIL_PATH/util_tuic.lua
|
||||
SINGBOX_BIN=$(first_type $(config_t_get global_app sing_box_file) sing-box)
|
||||
XRAY_BIN=$(first_type $(config_t_get global_app xray_file) xray)
|
||||
|
||||
check_run_environment() {
|
||||
local prefer_nft=$(config_t_get global_forwarding prefer_nft 1)
|
||||
@ -102,11 +104,8 @@ run_singbox() {
|
||||
local loglevel log_file config_file server_host server_port no_run
|
||||
eval_set_val $@
|
||||
[ -z "$type" ] && {
|
||||
local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
if [ "$type" != "sing-box" ]; then
|
||||
bin=$(first_type $(config_t_get global_app sing_box_file) sing-box)
|
||||
[ -n "$bin" ] && type="sing-box"
|
||||
fi
|
||||
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
[ "$type" != "sing-box" ] && [ -n "$SINGBOX_BIN" ] && type="sing-box"
|
||||
}
|
||||
[ -z "$type" ] && return 1
|
||||
[ -n "$log_file" ] || local log_file="/dev/null"
|
||||
@ -187,7 +186,7 @@ run_singbox() {
|
||||
[ -n "$no_run" ] && json_add_string "no_run" "1"
|
||||
local _json_arg="$(json_dump)"
|
||||
lua $UTIL_SINGBOX gen_config "${_json_arg}" > $config_file
|
||||
[ -n "$no_run" ] || ln_run "$(first_type $(config_t_get global_app sing_box_file) sing-box)" "sing-box" $log_file run -c "$config_file"
|
||||
[ -n "$no_run" ] || ln_run "$SINGBOX_BIN" "sing-box" $log_file run -c "$config_file"
|
||||
}
|
||||
|
||||
run_xray() {
|
||||
@ -196,11 +195,8 @@ run_xray() {
|
||||
local loglevel log_file config_file server_host server_port no_run
|
||||
eval_set_val $@
|
||||
[ -z "$type" ] && {
|
||||
local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
if [ "$type" != "xray" ]; then
|
||||
bin=$(first_type $(config_t_get global_app xray_file) xray)
|
||||
[ -n "$bin" ] && type="xray"
|
||||
fi
|
||||
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
[ "$type" != "xray" ] && [ -n "$XRAY_BIN" ] && type="xray"
|
||||
}
|
||||
[ -z "$type" ] && return 1
|
||||
json_init
|
||||
@ -279,7 +275,7 @@ run_xray() {
|
||||
[ -n "$no_run" ] && json_add_string "no_run" "1"
|
||||
local _json_arg="$(json_dump)"
|
||||
lua $UTIL_XRAY gen_config "${_json_arg}" > $config_file
|
||||
[ -n "$no_run" ] || ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $log_file run -c "$config_file"
|
||||
[ -n "$no_run" ] || ln_run "$XRAY_BIN" "xray" $log_file run -c "$config_file"
|
||||
}
|
||||
|
||||
run_dns2socks() {
|
||||
@ -409,19 +405,20 @@ run_socks() {
|
||||
json_add_string "server_port" "${_socks_port}"
|
||||
json_add_string "server_username" "${_socks_username}"
|
||||
json_add_string "server_password" "${_socks_password}"
|
||||
local bin=$(first_type $(config_t_get global_app sing_box_file) sing-box)
|
||||
if [ -n "$bin" ]; then
|
||||
if [ -n "${SINGBOX_BIN}" ]; then
|
||||
type="sing-box"
|
||||
lua $UTIL_SINGBOX gen_proto_config "$(json_dump)" > $config_file
|
||||
ln_run "$bin" ${type} $log_file run -c "$config_file"
|
||||
else
|
||||
bin=$(first_type $(config_t_get global_app xray_file) xray)
|
||||
[ -n "$bin" ] && {
|
||||
type="xray"
|
||||
lua $UTIL_XRAY gen_proto_config "$(json_dump)" > $config_file
|
||||
ln_run "$bin" ${type} $log_file run -c "$config_file"
|
||||
}
|
||||
local bin="${SINGBOX_BIN}"
|
||||
local util="${UTIL_SINGBOX}"
|
||||
elif [ -n "${XRAY_BIN}" ]; then
|
||||
type="xray"
|
||||
local bin="${XRAY_BIN}"
|
||||
local util="${UTIL_XRAY}"
|
||||
fi
|
||||
[ -n "${bin}" ] && [ -n "${util}" ] && {
|
||||
lua ${util} gen_proto_config "$(json_dump)" > $config_file
|
||||
[ -n "$no_run" ] || ln_run "$bin" $type $log_file run -c "$config_file"
|
||||
}
|
||||
unset bin util
|
||||
;;
|
||||
sing-box)
|
||||
[ "$http_port" != "0" ] && {
|
||||
@ -514,10 +511,7 @@ run_socks() {
|
||||
|
||||
# http to socks
|
||||
[ -z "$http_flag" ] && [ "$http_port" != "0" ] && [ -n "$http_config_file" ] && [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && [ "$type" != "socks" ] && {
|
||||
local bin=$(first_type $(config_t_get global_app sing_box_file) sing-box)
|
||||
json_add_null "node"
|
||||
json_add_null "server_host"
|
||||
json_add_null "server_port"
|
||||
json_init
|
||||
json_add_string "local_http_address" "$bind"
|
||||
json_add_string "local_http_port" "$http_port"
|
||||
json_add_string "server_proto" "socks"
|
||||
@ -525,17 +519,20 @@ run_socks() {
|
||||
json_add_string "server_port" "$socks_port"
|
||||
json_add_string "server_username" "$_username"
|
||||
json_add_string "server_password" "$_password"
|
||||
if [ -n "$bin" ]; then
|
||||
if [ -n "${SINGBOX_BIN}" ]; then
|
||||
type="sing-box"
|
||||
lua $UTIL_SINGBOX gen_proto_config "$(json_dump)" > $http_config_file
|
||||
[ -n "$no_run" ] || ln_run "$bin" ${type} /dev/null run -c "$http_config_file"
|
||||
else
|
||||
bin=$(first_type $(config_t_get global_app xray_file) xray)
|
||||
[ -n "$bin" ] && type="xray"
|
||||
[ -z "$type" ] && return 1
|
||||
lua $UTIL_XRAY gen_proto_config "$(json_dump)" > $http_config_file
|
||||
[ -n "$no_run" ] || ln_run "$bin" ${type} /dev/null run -c "$http_config_file"
|
||||
local bin="${SINGBOX_BIN}"
|
||||
local util="${UTIL_SINGBOX}"
|
||||
elif [ -n "${XRAY_BIN}" ]; then
|
||||
type="xray"
|
||||
local bin="${XRAY_BIN}"
|
||||
local util="${UTIL_XRAY}"
|
||||
fi
|
||||
[ -n "${bin}" ] && [ -n "${util}" ] && {
|
||||
lua ${util} gen_proto_config "$(json_dump)" > $http_config_file
|
||||
[ -n "$no_run" ] || ln_run "$bin" $type /dev/null run -c "$http_config_file"
|
||||
}
|
||||
unset bin util
|
||||
}
|
||||
unset http_flag
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user