mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-ssr-plus: add dns2socks support for dns anti-pollution
This commit is contained in:
parent
b16d0661b0
commit
769676b11b
64
package/lean/dns2socks/Makefile
Executable file
64
package/lean/dns2socks/Makefile
Executable file
@ -0,0 +1,64 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dns2socks
|
||||
PKG_VERSION:=2.1
|
||||
PKG_RELEASE:=20200218
|
||||
|
||||
PKG_SOURCE:=SourceCode.zip
|
||||
PKG_SOURCE_SUBDIR:=DNS2SOCKS
|
||||
PKG_SOURCE_URL:=@SF/dns2socks
|
||||
PKG_MD5SUM:=ec82de936ad004cc940502cd2a1bff5b
|
||||
|
||||
PKG_MAINTAINER:=ghostmaker
|
||||
PKG_LICENSE:=BSD-3-Clause
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dns2socks/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=IP Addresses and Names
|
||||
TITLE:=The utility to resolve DNS requests via a SOCKS5 tunnel.
|
||||
URL:=http://dns2socks.sourceforge.net/
|
||||
MAINTAINER:=ghostmaker
|
||||
DEPENDS:=+libpthread
|
||||
endef
|
||||
|
||||
define Package/dns2socks
|
||||
$(call Package/dns2socks/Default)
|
||||
endef
|
||||
|
||||
define Package/dns2socks/description
|
||||
This is a utility to resolve DNS requests via a SOCKS5 tunnel and caches the answers.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
unzip $(DL_DIR)/$(PKG_SOURCE) -d $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) \
|
||||
$(TARGET_CFLAGS) \
|
||||
$(TARGET_CPPFLAGS) \
|
||||
$(FPIC) \
|
||||
-o $(PKG_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/$(PKG_NAME) \
|
||||
$(PKG_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/DNS2SOCKS.c \
|
||||
$(TARGET_LDFLAGS) -pthread
|
||||
endef
|
||||
|
||||
define Build/Install
|
||||
endef
|
||||
|
||||
define Package/dns2socks/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/$(PKG_NAME) $(1)/usr/bin/dns2socks
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dns2socks))
|
@ -1,8 +1,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-ssr-plus
|
||||
PKG_VERSION:=159
|
||||
PKG_RELEASE:=5
|
||||
PKG_VERSION:=160
|
||||
PKG_RELEASE:=6
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
@ -44,7 +44,7 @@ define Package/$(PKG_NAME)
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=SS/SSR/V2Ray/Trojan LuCI interface
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget +lua +ipt2socks +microsocks \
|
||||
DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget +lua +ipt2socks +microsocks +dns2socks \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Simple_obfs:simple-obfs \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_plugin:v2ray-plugin \
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
m = Map("shadowsocksr")
|
||||
-- [[ global ]]--
|
||||
s = m:section(TypedSection, "global", translate("Server failsafe auto swith settings"))
|
||||
s = m:section(TypedSection, "global", translate("Server failsafe auto swith and custom update settings"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "monitor_enable", translate("Enable Process Deamon"))
|
||||
@ -27,25 +27,20 @@ o.datatype = "uinteger"
|
||||
o:depends("enable_switch", "1")
|
||||
o.default = 3
|
||||
|
||||
-- [[ adblock ]]--
|
||||
s = m:section(TypedSection, "global", translate("adblock settings"))
|
||||
s.anonymous = true
|
||||
o = s:option(Flag, "chnroute", translate("Enable Custom Chnroute"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "chnroute_url", translate("Chnroute Update url"))
|
||||
o.default = "https://ispip.clang.cn/all_cn.txt"
|
||||
o:depends("chnroute", "1")
|
||||
|
||||
o = s:option(Flag, "adblock", translate("Enable adblock"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "adblock_url", translate("adblock_url"))
|
||||
o.default = "https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt"
|
||||
|
||||
-- [[ chnroute ]]
|
||||
s = m:section(TypedSection, "global", translate("Chnroute Setting"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "chnroute", translate("Enable custom chnroute"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "chnroute_url", translate("Update url"))
|
||||
o.default = "https://cdn.jsdelivr.net/gh/17mon/china_ip_list/china_ip_list.txt"
|
||||
o.default = "https://gitee.com/privacy-protection-tools/anti-ad/raw/master/anti-ad-for-dnsmasq.conf"
|
||||
o:depends("adblock", "1")
|
||||
o.description = translate("Support AdGuardHome and DNSMAQ format list")
|
||||
|
||||
-- [[ SOCKS Proxy ]]--
|
||||
if nixio.fs.access("/usr/bin/microsocks") then
|
||||
@ -58,19 +53,21 @@ o.rmempty = false
|
||||
o = s:option(Value, "local_port", translate("Local Port"))
|
||||
o.datatype = "port"
|
||||
o.default = 1080
|
||||
o.rmempty = false
|
||||
o.rmempty = true
|
||||
o:depends("socks", "1")
|
||||
|
||||
o = s:option(Flag, "auth_enable", translate("Enable Authentication"))
|
||||
o.rmempty = false
|
||||
o.default = "0"
|
||||
o:depends("socks", "1")
|
||||
|
||||
o = s:option(Value, "username", translate("Username"))
|
||||
o.rmempty = false
|
||||
o.rmempty = true
|
||||
o:depends("auth_enable", "1")
|
||||
|
||||
o = s:option(Value, "password", translate("Password"))
|
||||
o.password = true
|
||||
o.rmempty = false
|
||||
o.rmempty = true
|
||||
o:depends("auth_enable", "1")
|
||||
|
||||
end
|
||||
|
@ -70,6 +70,7 @@ o.default = 1
|
||||
|
||||
o = s:option(ListValue, "pdnsd_enable", translate("Resolve Dns Mode"))
|
||||
o:value("1", translate("Use Pdnsd tcp query and cache"))
|
||||
o:value("2", translate("Use DNS2SOCKS query and cache"))
|
||||
o:value("0", translate("Use Local DNS Service listen port 5335"))
|
||||
o.default = 1
|
||||
|
||||
@ -88,6 +89,7 @@ o:value("1.1.1.1:53", translate("Cloudflare DNS (1.1.1.1)"))
|
||||
o:value("114.114.114.114:53", translate("Oversea Mode DNS-1 (114.114.114.114)"))
|
||||
o:value("114.114.115.115:53", translate("Oversea Mode DNS-2 (114.114.115.115)"))
|
||||
o:depends("pdnsd_enable", "1")
|
||||
o:depends("pdnsd_enable", "2")
|
||||
o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)")
|
||||
|
||||
return m
|
||||
|
@ -98,11 +98,6 @@ function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or translate("None")
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "server", translate("Server Address"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "server_port", translate("Server Port"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
|
@ -65,7 +65,7 @@ if luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") ==
|
||||
redir_run=1
|
||||
end
|
||||
|
||||
if luci.sys.call("pidof microsocks >/dev/null") == 0 then
|
||||
if luci.sys.call("busybox ps -w | grep ssr-socks | grep -v grep >/dev/null") == 0 then
|
||||
sock5_run=1
|
||||
end
|
||||
|
||||
@ -81,7 +81,7 @@ if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") ==
|
||||
tunnel_run=1
|
||||
end
|
||||
|
||||
if luci.sys.call("pidof pdnsd >/dev/null") == 0 then
|
||||
if luci.sys.call("pidof pdnsd >/dev/null") == 0 or (luci.sys.call("busybox ps -w | grep ssr-dns |grep -v grep >/dev/null") == 0 and luci.sys.call("pidof dns2socks >/dev/null") == 0)then
|
||||
pdnsd_run=1
|
||||
end
|
||||
|
||||
@ -105,14 +105,17 @@ else
|
||||
s.value = translate("Not Running")
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"pdnsd_run",translate("PDNSD"))
|
||||
if ucic:get_first(shadowsocksr, 'global', 'pdnsd_enable', '0') ~= '0' then
|
||||
s=m:field(DummyValue,"pdnsd_run",translate("DNS Anti-pollution"))
|
||||
s.rawhtml = true
|
||||
if pdnsd_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
else
|
||||
s.value = translate("Not Running")
|
||||
end
|
||||
end
|
||||
|
||||
if ucic:get_first(shadowsocksr, 'socks5_proxy', 'socks', '0') == '1' then
|
||||
if nixio.fs.access("/usr/bin/microsocks") then
|
||||
s=m:field(DummyValue,"sock5_run",translate("SOCKS5 Proxy Server"))
|
||||
s.rawhtml = true
|
||||
@ -122,6 +125,7 @@ else
|
||||
s.value = translate("Not Running")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/usr/bin/ssr-server") then
|
||||
s=m:field(DummyValue,"server_run",translate("Global SSR Server"))
|
||||
|
@ -358,6 +358,9 @@ msgstr "使用SSR-DNS隧道"
|
||||
msgid "Use Pdnsd"
|
||||
msgstr "使用Pdnsd"
|
||||
|
||||
msgid "DNS Anti-pollution"
|
||||
msgstr "DNS 防污染服务"
|
||||
|
||||
msgid "Use Other DNS Tunnel(Need to install)"
|
||||
msgstr "使用其他DNS转发(需要自己安装)"
|
||||
|
||||
@ -412,6 +415,9 @@ msgstr "格式为 IP:PORT (默认: 8.8.4.4:53)"
|
||||
msgid "Use Pdnsd tcp query and cache"
|
||||
msgstr "使用PDNSD TCP查询并缓存"
|
||||
|
||||
msgid "Use DNS2SOCKS query and cache"
|
||||
msgstr "使用 DNS2SOCKS 查询并缓存"
|
||||
|
||||
msgid "DNS Server IP:Port"
|
||||
msgstr "DNS服务器 IP:Port"
|
||||
|
||||
@ -487,8 +493,17 @@ msgstr "游戏模式UDP中继"
|
||||
msgid "adblock settings"
|
||||
msgstr "广告屏蔽设置"
|
||||
|
||||
msgid "Server failsafe auto swith settings"
|
||||
msgstr "服务器节点故障自动切换设置"
|
||||
msgid "Server failsafe auto swith and custom update settings"
|
||||
msgstr "服务器节点故障自动切换/广告屏蔽/国内IP段数据库更新设置"
|
||||
|
||||
msgid "Support AdGuardHome and DNSMAQ format list"
|
||||
msgstr "同时支持 AdGuard Home 和 DNSMAQ 格式的过滤列表"
|
||||
|
||||
msgid "Enable Custom Chnroute"
|
||||
msgstr "自定义国内IP段数据库更新"
|
||||
|
||||
msgid "Chnroute Update url"
|
||||
msgstr "国内IP段数据库更新URL"
|
||||
|
||||
msgid "Delete all severs"
|
||||
msgstr "删除所有服务器节点"
|
||||
|
@ -251,7 +251,7 @@ start_pdnsd() {
|
||||
purge_cache=off;
|
||||
}
|
||||
EOF
|
||||
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf -d
|
||||
/usr/sbin/pdnsd -c /var/etc/pdnsd.conf -d &
|
||||
}
|
||||
|
||||
start_redir() {
|
||||
@ -356,10 +356,11 @@ start_redir() {
|
||||
fi
|
||||
fi
|
||||
#deal with dns
|
||||
if [ "$(uci_get_by_type global pdnsd_enable)" == "1" ]; then
|
||||
local dnsstr="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)"
|
||||
local dnsserver=$(echo "$dnsstr" | awk -F ':' '{print $1}')
|
||||
local dnsport=$(echo "$dnsstr" | awk -F ':' '{print $2}')
|
||||
local ssr_dns="$(uci_get_by_type global pdnsd_enable 0)"
|
||||
local dnsstr="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)"
|
||||
local dnsserver=$(echo "$dnsstr" | awk -F ':' '{print $1}')
|
||||
local dnsport=$(echo "$dnsstr" | awk -F ':' '{print $2}')
|
||||
if [ "$ssr_dns" == "1" ]; then
|
||||
if [ "$run_mode" == "gfw" ]; then
|
||||
ipset add gfwlist $dnsserver 2>/dev/null
|
||||
elif [ "$run_mode" == "oversea" ]; then
|
||||
@ -369,6 +370,9 @@ start_redir() {
|
||||
fi
|
||||
start_pdnsd $dnsserver $dnsport
|
||||
pdnsd_enable_flag=1
|
||||
elif [ "$ssr_dns" == "2" ]; then
|
||||
microsocks -i 127.0.0.1 -p 10802 ssr-dns >/dev/null 2>&1 &
|
||||
dns2socks 127.0.0.1:10802 $dnsserver:$dnsport 127.0.0.1:5335 -q >/dev/null 2>&1 &
|
||||
fi
|
||||
if [ "$(uci_get_by_type global enable_switch)" == "1" ]; then
|
||||
if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable 1)" == "1" ]; then
|
||||
@ -454,9 +458,9 @@ start_local() {
|
||||
[ "$local_server" == "0" ] && return 0
|
||||
local auth_enable=$(uci_get_by_type socks5_proxy auth_enable 0)
|
||||
if [ "$auth_enable" == "1" ]; then
|
||||
microsocks -i 0.0.0.0 -p $(uci_get_by_type socks5_proxy local_port 1080) -1 -u $(uci_get_by_type socks5_proxy username) -P $(uci_get_by_type socks5_proxy password) >/dev/null 2>&1 &
|
||||
microsocks -i 0.0.0.0 -p $(uci_get_by_type socks5_proxy local_port 1080) -1 -u $(uci_get_by_type socks5_proxy username) -P $(uci_get_by_type socks5_proxy password) ssr-socks >/dev/null 2>&1 &
|
||||
else
|
||||
microsocks -i 0.0.0.0 -p $(uci_get_by_type socks5_proxy local_port 1080) >/dev/null 2>&1 &
|
||||
microsocks -i 0.0.0.0 -p $(uci_get_by_type socks5_proxy local_port 1080) ssr-socks >/dev/null 2>&1 &
|
||||
fi
|
||||
local_enable=1
|
||||
}
|
||||
@ -539,7 +543,7 @@ stop() {
|
||||
killall -q -9 ipt2socks
|
||||
killall -q -9 ssr-server
|
||||
killall -q -9 kcptun-client
|
||||
killall -q -9 srelay
|
||||
killall -q -9 dns2socks
|
||||
killall -q -9 microsocks
|
||||
if [ -f /var/run/pdnsd.pid ]; then
|
||||
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
|
||||
|
Loading…
Reference in New Issue
Block a user