luci-app-passwall: sync with upstream source

This commit is contained in:
CN_SZTL 2019-12-28 20:45:37 +08:00
parent bfa791a4b5
commit 2f2419bdf5
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
12 changed files with 73874 additions and 160 deletions

View File

@ -1,13 +1,13 @@
# Copyright (C) 2018-2020 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.0
PKG_RELEASE:=135-20191220
PKG_RELEASE:=142-20191228
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PO2LMO:=./po2lmo
@ -57,17 +57,17 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_haproxy
bool "Include haproxy"
default n
config PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS
bool "Include ChinaDNS"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_pdnsd
bool "Include pdnsd"
config PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG
bool "Include ChinaDNS-NG"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_dns2socks
bool "Include dns2socks"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_pdnsd
bool "Include pdnsd"
default y
endmenu
endef
@ -89,7 +89,7 @@ define Package/$(PKG_NAME)
+PACKAGE_$(PKG_NAME)_INCLUDE_Brook:brook \
+PACKAGE_$(PKG_NAME)_INCLUDE_kcptun:kcptun-client \
+PACKAGE_$(PKG_NAME)_INCLUDE_haproxy:haproxy \
+PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS:openwrt_chinadns \
+PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG:chinadns-ng \
+PACKAGE_$(PKG_NAME)_INCLUDE_pdnsd:pdnsd-alt \
+PACKAGE_$(PKG_NAME)_INCLUDE_dns2socks:dns2socks
endef

View File

@ -19,8 +19,9 @@ function index()
end
entry({"admin", "vpn", "passwall", "settings"}, cbi("passwall/global"),
_("Basic Settings"), 1).dependent = true
entry({"admin", "vpn", "passwall", "node_list"}, cbi("passwall/node_list"),
_("Node List"), 2).dependent = true
entry({"admin", "vpn", "passwall", "node_list"},
cbi("passwall/node_list", {autoapply = true}), _("Node List"), 2).dependent =
true
-- entry({"admin", "vpn", "passwall", "auto_switch"},
-- cbi("passwall/auto_switch"), _("Auto Switch"), 3).leaf = true
entry({"admin", "vpn", "passwall", "other"}, cbi("passwall/other"),

View File

@ -40,7 +40,8 @@ else
end
-- [[ Global Settings ]]--
s = m:section(TypedSection, "global", translate("Global Settings"))
s = m:section(TypedSection, "global", translate("Global Settings"),
translate("If you can use it, very stable. If not, GG !!!"))
s.anonymous = true
s.addremove = false
@ -94,10 +95,8 @@ o = s:option(ListValue, "dns_mode", translate("DNS Forward Mode"), translate(
"if you use no patterns are used, DNS of wan will be used by default as upstream of dnsmasq"))
o.rmempty = false
o:reset_values()
if is_installed("openwrt_chinadns") or is_finded("chinadns") then
o:value("chinadns", "ChinaDNS")
end
if is_installed("dns2socks") or is_finded("dns2socks") then
if is_finded("chinadns-ng") then o:value("chinadns-ng", "ChinaDNS-NG") end
if is_finded("dns2socks") then
o:value("dns2socks", "dns2socks " .. translate("Need Socks5 server"))
end
if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then
@ -106,29 +105,40 @@ end
o:value("local_7913", translate("Use local port 7913 as DNS"))
o:value("nonuse", translate("No patterns are used"))
o = s:option(Value, "dns2socks_forward", translate("DNS Forward Address"))
---- DNS Forward
o = s:option(Value, "dns_forward", translate("DNS Forward Address"))
o.default = "8.8.4.4"
o:value("8.8.4.4", "8.8.4.4(Google DNS1)")
o:value("8.8.8.8", "8.8.8.8(Google DNS2)")
o:value("208.67.222.222", "208.67.222.222(OpenDNS DNS1)")
o:value("208.67.220.220", "208.67.220.220(OpenDNS DNS2)")
o:value("8.8.4.4", "8.8.4.4 (Google DNS)")
o:value("8.8.8.8", "8.8.8.8 (Google DNS)")
o:value("208.67.222.222", "208.67.222.222 (OpenDNS DNS)")
o:value("208.67.220.220", "208.67.220.220 (OpenDNS DNS)")
o:depends("dns_mode", "dns2socks")
o:depends("dns_mode", "pdnsd")
---- upstreamm DNS Server for ChinaDNS
o = s:option(ListValue, "up_chinadns_mode",
translate("upstreamm DNS Server for ChinaDNS"), translate(
"Domestic DNS server 1 in advanced Settings is used as domestic DNS by default"))
o.default = "OpenDNS_1"
o:depends("dns_mode", "chinadns")
o:value("OpenDNS_1", "OpenDNS_1")
o:value("OpenDNS_2", "OpenDNS_2")
---- Use TCP Node Resolve DNS
o = s:option(Flag, "use_tcp_node_resolve_dns",
translate("Use TCP Node Resolve DNS"),
translate("If checked, DNS is resolved using the TCP node."))
o.default = 1
o:depends("dns_mode", "pdnsd")
---- upstreamm DNS Server for ChinaDNS-NG
o = s:option(ListValue, "up_chinadns_ng_mode",
translate("upstreamm DNS Server for ChinaDNS-NG"), translate(
"Domestic DNS server in advanced Settings is used as domestic DNS by default"))
o.default = "208.67.222.222"
o:value("208.67.222.222", "208.67.222.222 (OpenDNS DNS)")
o:value("208.67.220.220", "208.67.220.220 (OpenDNS DNS)")
if is_finded("dns2socks") then
o:value("dns2socks", "dns2socks " .. translate("Need Socks5 server"))
end
o:value("custom", translate("custom"))
o:depends("dns_mode", "chinadns-ng")
---- upstreamm DNS Server
o = s:option(Value, "up_chinadns_custom", translate("DNS Server"), translate(
"example: 114.114.114.114,208.67.222.222:443,8.8.8.8<br>Need at least one,Other DNS services can be used as upstream, such as smartdns."))
o.default = "114.114.114.114,208.67.222.222:5353"
o:depends("up_chinadns_mode", "custom")
o = s:option(Value, "up_chinadns_ng_custom", translate("DNS Server"), translate(
"example: 127.0.0.1#5335<br>Need at least one,Other DNS services can be used as upstream, such as dns2socks."))
o.default = "208.67.222.222#443"
o:depends("up_chinadns_ng_mode", "custom")
---- Default Proxy Mode
o = s:option(ListValue, "proxy_mode",

View File

@ -139,6 +139,17 @@ tcp_fast_open:depends("type", "SS")
tcp_fast_open:depends("type", "SSR")
tcp_fast_open:depends("type", "Trojan")
ss_plugin = s:option(ListValue, "ss_plugin", translate("plugin"))
ss_plugin:value("none", translate("none"))
if is_finded("v2ray-plugin") then ss_plugin:value("v2ray-plugin") end
ss_plugin:depends("type", "SS")
ss_plugin_v2ray_opts = s:option(ListValue, "ss_plugin_v2ray_opts", translate("opts"))
ss_plugin_v2ray_opts:value("http", translate("HTTP"))
ss_plugin_v2ray_opts:value("https", translate("HTTPS"))
ss_plugin_v2ray_opts:value("quic", translate("QUIC"))
ss_plugin_v2ray_opts:depends("ss_plugin", "v2ray-plugin")
use_kcp = s:option(Flag, "use_kcp", translate("Use Kcptun"),
"<span style='color:red'>" .. translate(
"Please confirm whether the Kcptun is installed. If not, please go to Rule Update download installation.") ..

View File

@ -23,6 +23,14 @@ o.default = 1
---- Concise display nodes
o = s:option(Flag, "compact_display_nodes", translate("Concise display nodes"))
o.default = 0
---- Show Add Mode
o = s:option(Flag, "show_add_mode", translate("Show Add Mode"))
o.default = 1
---- Show group
o = s:option(Flag, "show_group", translate("Show Group"))
o.default = 1
-- [[ Add the node via the link ]]--
@ -46,15 +54,17 @@ function s.remove(t, a)
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "node_list"))
end
-- 简洁模式
if api.uci_get_type("global_other", "compact_display_nodes", "1") == "1" then
o = s:option(DummyValue, "group", translate("Group"))
o.width = "25%"
o.cfgvalue = function(t, n)
if api.uci_get_type("global_other", "show_group", "1") == "1" then
show_group = s:option(DummyValue, "group", translate("Group"))
show_group.cfgvalue = function(t, n)
local group = api.uci_get_type_id(n, "group") or ""
return group ~= "" and group or ""
end
end
-- 简洁模式
if api.uci_get_type("global_other", "compact_display_nodes", "0") == "1" then
if show_group then show_group.width = "25%" end
o = s:option(DummyValue, "remarks", translate("Remarks"))
o.cfgvalue = function(t, n)
local str = ""
@ -64,9 +74,7 @@ if api.uci_get_type("global_other", "compact_display_nodes", "1") == "1" then
local type = api.uci_get_type_id(n, "type") or ""
local address = api.uci_get_type_id(n, "address") or ""
local port = api.uci_get_type_id(n, "port") or ""
if is_sub == "" and group == "" then
str = str .. type .. ""
end
if is_sub == "" and group == "" then str = str .. type .. "" end
str = str .. remarks
if address ~= "" and port ~= "" then
local s = " " .. address .. ":" .. port .. ""
@ -80,15 +88,17 @@ else
o = s:option(DummyValue, "remarks", translate("Remarks"))
---- Add Mode
o = s:option(DummyValue, "add_mode", translate("Add Mode"))
o.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n)
if v and v ~= '' then
return v
else
return '手动'
if api.uci_get_type("global_other", "show_add_mode", "1") == "1" then
o = s:option(DummyValue, "add_mode", translate("Add Mode"))
o.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n)
if v and v ~= '' then
return v
else
return '手动'
end
return str
end
return str
end
---- Type
@ -132,8 +142,4 @@ o.template = "passwall/node_list/apply"
m:append(Template("passwall/node_list/node_list"))
if luci.http.formvalue("cbi.apply") then
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "node_list"))
end
return m

View File

@ -4,9 +4,11 @@ local dsp = require "luci.dispatcher"
local gfwlist_version = api.uci_get_type("global_rules", "gfwlist_version")
local chnroute_version = api.uci_get_type("global_rules", "chnroute_version")
local chnlist_version = api.uci_get_type("global_rules", "chnlist_version")
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update", "1") == "1" and "checked='checked'" or ""
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update", "1") == "1" and "checked='checked'" or ""
local chnlist_update = api.uci_get_type("global_rules", "chnlist_update", "1") == "1" and "checked='checked'" or ""
-%>
<script type="text/javascript">
@ -66,6 +68,18 @@ local chnroute_update = api.uci_get_type("global_rules", "chnroute_update", "1")
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">chnlist
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=chnlist_version%> 】</span>
<input type="checkbox" name="chnlist_update" value="1" <%=chnroute_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">

View File

@ -118,8 +118,8 @@ msgstr "检测中..."
msgid "Clear"
msgstr "清除"
msgid "Global Setting"
msgstr "全局配置"
msgid "If you can use it, very stable. If not, GG !!!"
msgstr "如果你会用稳得一批。否则GG"
msgid "TCP Node"
msgstr "TCP节点"
@ -157,11 +157,20 @@ msgstr "不使用"
msgid "if you use no patterns are used, DNS of wan will be used by default as upstream of dnsmasq"
msgstr "如果您没有使用任何模式则会使用WAN的DNS"
msgid "upstreamm DNS Server for ChinaDNS"
msgstr "ChinaDNS的上游服务器"
msgid "Use TCP Node Resolve DNS"
msgstr "使用TCP节点解析DNS"
msgid "Domestic DNS server 1 in advanced Settings is used as domestic DNS by default"
msgstr "默认使用高级设置里的国内DNS服务器1作为国内DNS"
msgid "If checked, DNS is resolved using the TCP node."
msgstr "如果勾选则使用TCP节点解析DNS解决污染。"
msgid "upstreamm DNS Server for ChinaDNS-NG"
msgstr "ChinaDNS-NG的上游服务器"
msgid "Domestic DNS server in advanced Settings is used as domestic DNS by default"
msgstr "默认使用高级设置里的国内DNS服务器作为国内DNS"
msgid "example: 127.0.0.1#5335<br>Need at least one,Other DNS services can be used as upstream, such as dns2socks."
msgstr "例127.0.0.1#5335<br>需要至少一个服务器其他DNS服务可以作为上游使用比如dns2socks。"
msgid "custom"
msgstr "自定义"
@ -169,9 +178,6 @@ msgstr "自定义"
msgid "DNS Server"
msgstr "DNS服务器"
msgid "example: 114.114.114.114,208.67.222.222:443,8.8.8.8<br>Need at least one,Other DNS services can be used as upstream, such as smartdns."
msgstr "例114.114.114.114,208.67.222.222:443,8.8.8.8<br>需要至少一个服务器其他DNS服务可以作为上游使用比如smartdns。"
msgid "Need Socks5 server"
msgstr "需要Socks5"
@ -271,6 +277,12 @@ msgstr "Ping延迟"
msgid "Ping Value"
msgstr "Ping值"
msgid "Show Add Mode"
msgstr "显示添加方式"
msgid "Show Group"
msgstr "显示组"
msgid "Group"
msgstr "组"
@ -646,6 +658,12 @@ msgstr "TCP快速打开"
msgid "Need node support required"
msgstr "需要节点支持"
msgid "plugin"
msgstr "插件"
msgid "opts"
msgstr "插件选项"
msgid "Protocol"
msgstr "协议名称"

View File

@ -4,7 +4,8 @@ config global
option udp_node1 'nil'
option socks5_node1 'nil'
option dns_mode 'pdnsd'
option dns2socks_forward '8.8.4.4'
option dns_forward '8.8.4.4'
option use_tcp_node_resolve_dns '1'
option proxy_mode 'chnroute'
option localhost_proxy_mode 'gfwlist'
@ -42,14 +43,18 @@ config global_other
option udp_node_num '1'
option socks5_node_num '1'
option status_use_big_icon '1'
option compact_display_nodes '1'
option compact_display_nodes '0'
option show_group '0'
option show_add_mode '0'
config global_rules
option auto_update '0'
option gfwlist_update '1'
option chnroute_update '1'
option chnlist_update '1'
option gfwlist_version '2019-12-10'
option chnroute_version '2019-12-05'
option chnlist_version '2019-12-27'
config global_app
option v2ray_file '/usr/bin/v2ray/'

File diff suppressed because it is too large Load Diff

View File

@ -179,8 +179,9 @@ load_config() {
echolog "没有选择节点!"
return 1
}
DNS_MODE=$(config_t_get global dns_mode ChinaDNS)
UP_CHINADNS_MODE=$(config_t_get global up_chinadns_mode OpenDNS_1)
DNS_MODE=$(config_t_get global dns_mode pdnsd)
DNS_FORWARD=$(config_t_get global dns_forward 8.8.4.4)
use_tcp_node_resolve_dns=$(config_t_get global use_tcp_node_resolve_dns 0)
process=1
if [ "$(config_t_get global_forwarding process 0)" = "0" ]; then
process=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
@ -259,8 +260,7 @@ gen_config_file() {
server_ip=$(get_host_ip $network_type $server_host)
port=$(config_n_get $node port)
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
echolog "$redir_type节点$remarks"
echolog "$redir_type节点IP$server_ip"
echolog "$redir_type节点$remarks,节点地址端口:${server_ip}:${port}"
if [ "$redir_type" == "Socks5" ]; then
if [ "$network_type" == "ipv6" ]; then
@ -340,18 +340,22 @@ gen_config_file() {
fi
if [ "$kcptun_use" == "1" -a -n "$kcptun_port" -a -n "$kcptun_config" -a "$lbenabled" == "0" -a -n "$kcptun_path" ]; then
if [ -z "$kcptun_server_host" ]; then
start_kcptun "$kcptun_path" $server_ip $kcptun_port "$kcptun_config"
else
local run_kcptun_ip=$server_ip
if [ -n "$kcptun_server_host" ]; then
kcptun_use_ipv6=$(config_n_get $node kcp_use_ipv6)
network_type="ipv4"
[ "$kcptun_use_ipv6" == "1" ] && network_type="ipv6"
kcptun_server_ip=$(get_host_ip $network_type $kcptun_server_host)
echolog "KCP节点IP地址:$kcptun_server_ip"
TCP_NODE1_IP=$kcptun_server_ip
start_kcptun "$kcptun_path" $kcptun_server_ip $kcptun_port "$kcptun_config"
run_kcptun_ip=$kcptun_server_ip
echolog "KCP节点IP地址:$kcptun_server_ip"
fi
if [ -z "$kcptun_path" ]; then
echolog "找不到Kcptun客户端主程序无法启用"
else
$kcptun_bin --log $CONFIG_PATH/kcptun -l 0.0.0.0:$KCPTUN_REDIR_PORT -r $run_kcptun_ip:$kcptun_port "$kcptun_config" >/dev/null 2>&1 &
echolog "运行Kcptun..."
fi
echolog "运行Kcptun..."
if [ "$type" == "ss" -o "$type" == "ssr" ]; then
gen_ss_ssr_config_file $type $local_port 1 $node $config_file_path
fi
@ -370,15 +374,6 @@ gen_config_file() {
return 0
}
start_kcptun() {
kcptun_bin=$1
if [ -z "$kcptun_bin" ]; then
echolog "找不到Kcptun客户端主程序无法启用"
else
$kcptun_bin --log $CONFIG_PATH/kcptun -l 0.0.0.0:$KCPTUN_REDIR_PORT -r $2:$3 $4 >/dev/null 2>&1 &
fi
}
start_tcp_redir() {
for i in $(seq 1 $TCP_NODE_NUM); do
eval temp_server=\$TCP_NODE$i
@ -423,11 +418,33 @@ start_tcp_redir() {
# gen_redsocks_config $redsocks_config_file tcp $port $address $port $server_username $server_password
# $redsocks_bin -c $redsocks_config_file >/dev/null &
#}
elif [ "$TYPE" == "ss" -o "$TYPE" == "ssr" ]; then
ss_bin=$(find_bin "$TYPE"-redir)
[ -n "$ss_bin" ] && {
elif [ "$TYPE" == "ssr" ]; then
ssr_bin=$(find_bin ssr-redir)
[ -n "$ssr_bin" ] && {
for k in $(seq 1 $process); do
$ss_bin -c $config_file -f $RUN_PID_PATH/tcp_${TYPE}_$k_$i >/dev/null 2>&1 &
$ssr_bin -c $config_file -f $RUN_PID_PATH/tcp_${TYPE}_$k_$i >/dev/null 2>&1 &
done
}
elif [ "$TYPE" == "ss" ]; then
ss_bin=$(find_bin ss-redir)
[ -n "$ss_bin" ] && {
local plugin_params=""
local plugin=$(config_n_get $temp_server ss_plugin)
if [ "$plugin" != "none" ]; then
[ "$plugin" == "v2ray-plugin" ] && {
plugin_params="--plugin "
plugin_params="${plugin_params}v2ray-plugin"
local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts)
local address=$(config_n_get $temp_server address)
if [ "$opts" == "https" ]; then
plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\""
elif [ "$opts" == "quic" ]; then
plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\""
fi
}
fi
for k in $(seq 1 $process); do
$ss_bin -c $config_file -f $RUN_PID_PATH/tcp_${TYPE}_$k_$i $plugin_params >/dev/null 2>&1 &
done
}
fi
@ -496,10 +513,28 @@ start_udp_redir() {
# gen_redsocks_config $redsocks_config_file udp $port $address $port $server_username $server_password
# $redsocks_bin -c $redsocks_config_file >/dev/null &
#}
elif [ "$TYPE" == "ss" -o "$TYPE" == "ssr" ]; then
ss_bin=$(find_bin "$TYPE"-redir)
elif [ "$TYPE" == "ssr" ]; then
ssr_bin=$(find_bin ssr-redir)
[ -n "$ssr_bin" ] && $ssr_bin -c $config_file -f $RUN_PID_PATH/udp_${TYPE}_1_$i -U >/dev/null 2>&1 &
elif [ "$TYPE" == "ss" ]; then
ss_bin=$(find_bin ss-redir)
[ -n "$ss_bin" ] && {
$ss_bin -c $config_file -f $RUN_PID_PATH/udp_${TYPE}_1_$i -U >/dev/null 2>&1 &
local plugin_params=""
local plugin=$(config_n_get $temp_server ss_plugin)
if [ "$plugin" != "none" ]; then
[ "$plugin" == "v2ray-plugin" ] && {
plugin_params="--plugin "
plugin_params="${plugin_params}v2ray-plugin"
local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts)
local address=$(config_n_get $temp_server address)
if [ "$opts" == "https" ]; then
plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\""
elif [ "$opts" == "quic" ]; then
plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\""
fi
}
fi
$ss_bin -c $config_file -f $RUN_PID_PATH/udp_${TYPE}_1_$i -U $plugin_params >/dev/null 2>&1 &
}
fi
echo $port > $CONFIG_PATH/port/UDP_${i}
@ -538,9 +573,29 @@ start_socks5_proxy() {
[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null 2>&1 &
elif [ "$TYPE" == "socks5" ]; then
echolog "Socks5节点不能使用Socks5代理节点"
elif [ "$TYPE" == "ss" -o "$TYPE" == "ssr" ]; then
ss_bin=$(find_bin "$TYPE"-local)
[ -n "$ss_bin" ] && $ss_bin -c $config_file -b 0.0.0.0 >/dev/null 2>&1 &
elif [ "$TYPE" == "ssr" ]; then
ssr_bin=$(find_bin ssr-local)
[ -n "$ssr_bin" ] && $ssr_bin -c $config_file -b 0.0.0.0 >/dev/null 2>&1 &
elif [ "$TYPE" == "ss" ]; then
ss_bin=$(find_bin ss-local)
[ -n "$ss_bin" ] && {
local plugin_params=""
local plugin=$(config_n_get $temp_server ss_plugin)
if [ "$plugin" != "none" ]; then
[ "$plugin" == "v2ray-plugin" ] && {
plugin_params="--plugin "
plugin_params="${plugin_params}v2ray-plugin"
local opts=$(config_n_get $temp_server ss_plugin_v2ray_opts)
local address=$(config_n_get $temp_server address)
if [ "$opts" == "https" ]; then
plugin_params="${plugin_params} --plugin-opts \"tls;host=${address}\""
elif [ "$opts" == "quic" ]; then
plugin_params="${plugin_params} --plugin-opts \"mode=quic;host=${address}\""
fi
}
fi
$ss_bin -c $config_file -b 0.0.0.0 $plugin_params >/dev/null 2>&1 &
}
fi
echo $port > $CONFIG_PATH/port/Socks5_${i}
fi
@ -644,8 +699,7 @@ start_dns() {
if [ -n "$SOCKS5_NODE1" -a "$SOCKS5_NODE1" != "nil" ]; then
dns2socks_bin=$(find_bin dns2socks)
[ -n "$dns2socks_bin" ] && {
local dns=$(config_t_get global dns2socks_forward 8.8.4.4)
nohup $dns2socks_bin 127.0.0.1:$SOCKS5_PROXY_PORT1 ${dns}:53 127.0.0.1:$DNS_PORT >/dev/null 2>&1 &
nohup $dns2socks_bin 127.0.0.1:$SOCKS5_PROXY_PORT1 ${DNS_FORWARD}:53 127.0.0.1:$DNS_PORT >/dev/null 2>&1 &
echolog "运行DNS转发模式dns2socks..."
}
else
@ -656,39 +710,51 @@ start_dns() {
pdnsd_bin=$(find_bin pdnsd)
[ -n "$pdnsd_bin" ] && {
gen_pdnsd_config
nohup $pdnsd_bin --daemon -c $CACHEDIR/pdnsd.conf -p $RUN_PID_PATH/pdnsd.pid -d >/dev/null 2>&1 &
nohup $pdnsd_bin --daemon -c $pdnsd_dir/pdnsd.conf -d >/dev/null 2>&1 &
echolog "运行DNS转发模式Pdnsd..."
}
;;
chinadns)
chinadns_bin=$(find_bin ChinaDNS)
[ -n "$chinadns_bin" ] && {
other=1
other_port=$(expr $DNS_PORT + 1)
echolog "运行DNS转发模式ChinaDNS..."
chinadns-ng)
chinadns_ng_bin=$(find_bin chinadns-ng)
[ -n "$chinadns_ng_bin" ] && {
local dns1=$DNS1
[ "$DNS1" = "dnsbyisp" ] && dns1=$(cat /tmp/resolv.conf.auto 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep -v 0.0.0.0 | grep -v 127.0.0.1 | sed -n '1P')
case "$UP_CHINADNS_MODE" in
OpenDNS_1)
other=0
nohup $chinadns_bin -p $DNS_PORT -c $RULE_PATH/chnroute -m -d -s $dns1,208.67.222.222:443,208.67.222.222:5353 >/dev/null 2>&1 &
echolog "运行ChinaDNS上游转发模式$dns1,208.67.222.222..."
local dns2=$DNS2
[ "$DNS2" = "dnsbyisp" ] && dns2=$(cat /tmp/resolv.conf.auto 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep -v 0.0.0.0 | grep -v 127.0.0.1 | sed -n '2P')
other_port=$(expr $DNS_PORT + 1)
cat $RULE_PATH/gfwlist.conf | sort | uniq | sed -e '/127.0.0.1/d' | sed 's/ipset=\/.//g' | sed 's/\/gfwlist//g' > $CONFIG_PATH/gfwlist_chinadns_ng.txt
[ -f "$CONFIG_PATH/gfwlist_chinadns_ng.txt" ] && local gfwlist_param="-g $CONFIG_PATH/gfwlist_chinadns_ng.txt"
[ -f "$RULE_PATH/chnlist" ] && local chnlist_param="-m $RULE_PATH/chnlist -M"
up_chinadns_ng_mode=$(config_t_get global up_chinadns_ng_mode "208.67.222.222")
case "$up_chinadns_ng_mode" in
208.67.222.222)
DNS_FORWARD=$up_chinadns_ng_mode
nohup $chinadns_ng_bin -l $DNS_PORT -c $dns1,$dns2 -t 208.67.222.222#443,208.67.222.222#5353 $gfwlist_param $chnlist_param >/dev/null 2>&1 &
echolog "运行DNS转发模式ChinaDNS-NG国内DNS$dns1, $dns2可信DNS208.67.222.222"
;;
OpenDNS_2)
other=0
nohup $chinadns_bin -p $DNS_PORT -c $RULE_PATH/chnroute -m -d -s $dns1,208.67.220.220:443,208.67.220.220:5353 >/dev/null 2>&1 &
echolog "运行ChinaDNS上游转发模式$dns1,208.67.220.220..."
208.67.220.220)
DNS_FORWARD=$up_chinadns_ng_mode
nohup $chinadns_ng_bin -l $DNS_PORT -c $dns1,$dns2 -t 208.67.220.220#443,208.67.220.220#5353 $gfwlist_param $chnlist_param >/dev/null 2>&1 &
echolog "运行DNS转发模式ChinaDNS-NG国内DNS$dns1, $dns2可信DNS208.67.220.220"
;;
dns2socks)
if [ -n "$SOCKS5_NODE1" -a "$SOCKS5_NODE1" != "nil" ]; then
dns2socks_bin=$(find_bin dns2socks)
[ -n "$dns2socks_bin" ] && {
nohup $dns2socks_bin 127.0.0.1:$SOCKS5_PROXY_PORT1 ${DNS_FORWARD}:53 127.0.0.1:$other_port >/dev/null 2>&1 &
nohup $chinadns_ng_bin -l $DNS_PORT -c $dns1,$dns2 -t 127.0.0.1#$other_port $gfwlist_param $chnlist_param >/dev/null 2>&1 &
echolog "运行DNS转发模式ChinaDNS-NG + dns2socks国内DNS$dns1, $dns2"
}
else
echolog "dns2socks模式需要使用Socks5代理节点请开启"
fi
;;
custom)
other=0
UP_CHINADNS_CUSTOM=$(config_t_get global up_chinadns_custom '114.114.114.114,208.67.222.222:5353')
nohup $chinadns_bin -p $DNS_PORT -c $RULE_PATH/chnroute -m -d -s $UP_CHINADNS_CUSTOM >/dev/null 2>&1 &
echolog "运行ChinaDNS上游转发模式$UP_CHINADNS_CUSTOM..."
up_chinadns_ng_custom=$(config_t_get global up_chinadns_ng_custom '208.67.222.222#443,208.67.222.222#5353')
nohup $chinadns_ng_bin -l $DNS_PORT -c $dns1,$dns2 -t $up_chinadns_ng_custom $gfwlist_param $chnlist_param >/dev/null 2>&1 &
echolog "运行DNS转发模式ChinaDNS-NG国内DNS$dns1, $dns2可信DNS$up_chinadns_ng_custom"
;;
esac
if [ "$other" = "1" ]; then
nohup $chinadns_bin -p $DNS_PORT -c $RULE_PATH/chnroute -m -d -s $dns1,127.0.0.1:$other_port >/dev/null 2>&1 &
fi
}
;;
esac
@ -908,47 +974,77 @@ gen_redsocks_config() {
}
gen_pdnsd_config() {
CACHEDIR=/var/pdnsd
CACHE=$CACHEDIR/pdnsd.cache
if ! test -f "$CACHE"; then
mkdir -p $(dirname $CACHE)
touch $CACHE
chown -R root.nogroup $CACHEDIR
fi
cat >$CACHEDIR/pdnsd.conf <<-EOF
pdnsd_dir=$CONFIG_PATH/pdnsd
mkdir -p $pdnsd_dir
touch $pdnsd_dir/pdnsd.cache
chown -R root.nogroup $pdnsd_dir
cat > $pdnsd_dir/pdnsd.conf <<-EOF
global {
perm_cache=1024;
cache_dir="/var/pdnsd";
run_as="root";
server_ip = 127.0.0.1;
server_port=$DNS_PORT;
status_ctl = on;
query_method=tcp_only;
min_ttl=1d;
max_ttl=1w;
timeout=10;
tcp_qtimeout=1;
par_queries=2;
neg_domain_pol=on;
udpbufsize=1024;
}
perm_cache = 1024;
cache_dir = "$pdnsd_dir";
pid_file = "$RUN_PID_PATH/pdnsd.pid";
run_as = "root";
server_ip = 127.0.0.1;
server_port = $DNS_PORT;
status_ctl = on;
query_method = tcp_only;
min_ttl = 1d;
max_ttl = 1w;
timeout = 10;
tcp_qtimeout = 1;
par_queries = 2;
neg_domain_pol = on;
udpbufsize = 1024;
}
EOF
[ "$use_tcp_node_resolve_dns" == 1 ] && {
cat >> $pdnsd_dir/pdnsd.conf <<-EOF
server {
label = "opendns";
ip = 208.67.222.222, 208.67.220.220;
edns_query=on;
port = 5353;
timeout = 4;
interval=60;
uptest = none;
purge_cache=off;
caching=on;
}
label = "node";
ip = $DNS_FORWARD;
edns_query = on;
port = 53;
timeout = 4;
interval = 60;
uptest = none;
purge_cache = off;
caching = on;
}
EOF
}
cat >> $pdnsd_dir/pdnsd.conf <<-EOF
server {
label = "opendns";
ip = 208.67.222.222, 208.67.220.220;
edns_query = on;
port = 443;
timeout = 4;
interval = 60;
uptest = none;
purge_cache = off;
caching = on;
}
server {
label = "opendns";
ip = 208.67.222.222, 208.67.220.220;
edns_query = on;
port = 5353;
timeout = 4;
interval = 60;
uptest = none;
purge_cache = off;
caching = on;
}
source {
ttl=86400;
owner="localhost.";
serve_aliases=on;
file="/etc/hosts";
}
ttl = 86400;
owner = "localhost.";
serve_aliases = on;
file = "/etc/hosts";
}
EOF
}
@ -1135,7 +1231,7 @@ stop() {
clean_log
source $APP_PATH/iptables.sh stop
del_vps_port
kill_all pdnsd brook dns2socks haproxy chinadns ipt2socks
kill_all brook dns2socks haproxy chinadns-ng ipt2socks v2ray-plugin
ps -w | grep -E "$CONFIG_TCP_FILE|$CONFIG_UDP_FILE|$CONFIG_SOCKS5_FILE" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
ps -w | grep -E "$CONFIG_PATH" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
ps -w | grep "kcptun_client" | grep "$KCPTUN_REDIR_PORT" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &

View File

@ -351,6 +351,7 @@ add_firewall_rule() {
# 用于本机流量转发默认只走router
#$iptables_nat -I OUTPUT -j SS
$iptables_nat -A OUTPUT -m set --match-set $IPSET_LANIPLIST dst -m comment --comment "PassWall" -j RETURN
[ "$use_tcp_node_resolve_dns" == 1 -a -n "$DNS_FORWARD" ] && $iptables_nat -A OUTPUT -p tcp -d $DNS_FORWARD -m multiport --dport 1:65535 -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT1
$iptables_nat -A OUTPUT -m set --match-set $IPSET_VPSIPLIST dst -m comment --comment "PassWall" -j RETURN
$iptables_nat -A OUTPUT -m set --match-set $IPSET_WHITELIST dst -m comment --comment "PassWall" -j RETURN
$iptables_nat -A OUTPUT -p tcp -m multiport --dport $TCP_REDIR_PORTS -m set --match-set $IPSET_ROUTER dst -m comment --comment "PassWall" -j REDIRECT --to-ports $TCP_REDIR_PORT1

View File

@ -13,12 +13,14 @@ chnroute_update=0
if [ -n "$update" ]; then
[ -n "$(echo $update | grep "gfwlist_update")" ] && gfwlist_update=1
[ -n "$(echo $update | grep "chnroute_update")" ] && chnroute_update=1
[ -n "$(echo $update | grep "chnlist_update")" ] && chnlist_update=1
else
gfwlist_update=$(uci get $CONFIG.@global_rules[0].gfwlist_update)
chnroute_update=$(uci get $CONFIG.@global_rules[0].chnroute_update)
chnlist_update=$(uci get $CONFIG.@global_rules[0].chnlist_update)
fi
if [ "$gfwlist_update" == 0 -a "$chnroute_update" == 0 ]; then
if [ "$gfwlist_update" == 0 -a "$chnroute_update" == 0 -a "$chnlist_update" == 0 ]; then
exit
fi
@ -127,13 +129,52 @@ if [ "$chnroute_update" == 1 ]; then
rm -rf /tmp/chnroute
fi
# update chnlist
if [ "$chnlist_update" == 1 ]; then
chnlist=$(cat /tmp/version1 | sed -n 4p)
version_chnlist2=$(echo $chnlist | sed 's/ /\n/g' | sed -n 1p)
md5sum_chnlist2=$(echo $chnlist | sed 's/ /\n/g' | tail -n 2 | head -n 1)
local_md5sum_chnlist=$(md5sum $RULE_PATH/chnlist | awk '{print $1}')
if [ ! -z "$version_chnlist2" ]; then
version_chnlist1=$(uci_get_by_type global_rules chnlist_version)
if [ "$version_chnlist1" != "$version_chnlist2" -o "$md5sum_chnlist2" != "$local_md5sum_chnlist" ]; then
echo $Date: 检测到新版本chnlist开始更新... >>$LOG_FILE
echo $Date: 下载chnlist到临时文件... >>$LOG_FILE
status=$(/usr/bin/curl -w %{http_code} --connect-timeout 10 $url_main/cdn.txt --silent -o /tmp/chnlist)
[ "$?" != 0 ] || [ -z "$status" ] || [ "$status" != "200" ] && {
status=$(/usr/bin/wget --no-check-certificate --timeout=15 -q $url_main/cdn.txt -O /tmp/chnlist)
[ "$?" != 0 ] || [ -z "$status" ] && {
echo $Date: 无法访问更新接口,请更新接口! >>$LOG_FILE
exit
}
}
md5sum_chnlist1=$(md5sum /tmp/chnlist | sed 's/ /\n/g' | sed -n 1p)
if [ "$md5sum_chnlist1"x = "$md5sum_chnlist2"x ]; then
echo $Date: 下载完成校验通过将临时文件覆盖到原始chnlist文件 >>$LOG_FILE
mv /tmp/chnlist $RULE_PATH/chnlist
uci set $CONFIG.@global_rules[0].chnlist_version=$version_chnlist2
reboot="1"
echo $Date: 你的chnlist已经更新到最新了哦~ >>$LOG_FILE
else
echo $Date: 下载完成,但是校验没有通过! >>$LOG_FILE
fi
else
echo $Date: 检测到chnlist本地版本号和在线版本号相同不用更新! >>$LOG_FILE
fi
else
echo $Date: chnlist文件下载失败 >>$LOG_FILE
fi
rm -rf /tmp/chnlist
fi
echo $Date: 更新进程运行完毕! >>$LOG_FILE
rm -rf /tmp/version1
# write number
uci set $CONFIG.@global_rules[0].gfwlist_update=$gfwlist_update
uci set $CONFIG.@global_rules[0].chnroute_update=$chnroute_update
uci set $CONFIG.@global_rules[0].chnlist_update=$chnlist_update
uci commit
# reboot ss
# reboot
if [ "$reboot" == "1" ]; then
echo $Date: 重启软件,以应用新的规则文件!请稍后! >>$LOG_FILE
/etc/init.d/$CONFIG restart