mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-17 21:03:30 +00:00
luci-app-ssr-plus (#2815)
* v2ray-core:Add v2ray-core self compilation Network ---> Project V ---> <*> v2ray-core You can custom the features in "V2Ray Configuration" option. * luci-app-ssr-plus 0.Add v2ray-core 1.Makefile Standard install 2.Fix vmess v2ray 3.Optimize update scripts 4.Add ad filter (not enabled) 5.Code formatting 6.Clear basic data * luci-app-ssr-plus:Add ad filter settings UI * luci-app-ssr-plus:Fix Filter invalid nodes * luci-app-ssr-plus:update china_ssr.txt * luci-app-ssr-plus:Fix
This commit is contained in:
parent
ea8ecf8bd5
commit
aabeddc2b0
@ -1,58 +1,56 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-ssr-plus
|
||||
PKG_RELEASE:=133
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=132
|
||||
|
||||
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks \
|
||||
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \
|
||||
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan \
|
||||
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun \
|
||||
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server \
|
||||
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks
|
||||
bool "Include Shadowsocks New Version"
|
||||
default y if x86_64
|
||||
|
||||
default y
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_v2ray-core
|
||||
bool "Include v2ray-core"
|
||||
default y
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray
|
||||
bool "Include V2ray"
|
||||
default y if x86_64
|
||||
|
||||
default n
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan
|
||||
bool "Include Trojan"
|
||||
default y if x86_64
|
||||
|
||||
default n
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun
|
||||
bool "Include Kcptun"
|
||||
default n
|
||||
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server
|
||||
bool "Include ShadowsocksR Server"
|
||||
default y if x86_64
|
||||
|
||||
default n
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks
|
||||
bool "Include ShadowsocksR Socks and Tunnel"
|
||||
default y if x86_64
|
||||
default y
|
||||
endef
|
||||
|
||||
define Package/luci-app-ssr-plus
|
||||
SECTION:=luci
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=SS/SSR/V2Ray LuCI interface
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +pdnsd-alt +wget \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_v2ray-core:v2ray-core \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
@ -67,11 +65,37 @@ define Package/luci-app-ssr-plus/conffiles
|
||||
endef
|
||||
|
||||
define Package/luci-app-ssr-plus/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
|
||||
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
|
||||
$(INSTALL_DIR) $(1)/
|
||||
cp -pR ./root/* $(1)/
|
||||
#lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/shadowsocksr
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||
#etc
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/dnsmasq.oversea
|
||||
$(INSTALL_DIR) $(1)/etc/dnsmasq.ssr
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
#usr
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/share/shadowsocksr
|
||||
#root/etc
|
||||
$(INSTALL_DATA) ./root/etc/china_ssr.txt $(1)/etc/china_ssr.txt
|
||||
$(INSTALL_CONF) ./root/etc/config/shadowsocksr $(1)/etc/config/shadowsocksr
|
||||
$(INSTALL_DATA) ./root/etc/config/*.list $(1)/etc/config/
|
||||
$(INSTALL_DATA) ./root/etc/dnsmasq.oversea/* $(1)/etc/dnsmasq.oversea/
|
||||
$(INSTALL_DATA) ./root/etc/dnsmasq.ssr/* $(1)/etc/dnsmasq.ssr/
|
||||
$(INSTALL_BIN) ./root/etc/init.d/* $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) ./root/etc/uci-defaults/* $(1)/etc/uci-defaults/
|
||||
#root/usr
|
||||
$(INSTALL_BIN) ./root/usr/bin/* $(1)/usr/bin/
|
||||
$(INSTALL_BIN) ./root/usr/share/shadowsocksr/*.sh $(1)/usr/share/shadowsocksr/
|
||||
$(INSTALL_DATA) ./root/usr/share/shadowsocksr/*.lua $(1)/usr/share/shadowsocksr/
|
||||
#luasrc
|
||||
$(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/
|
||||
$(INSTALL_DATA) ./luasrc/model/cbi/shadowsocksr/*.lua $(1)/usr/lib/lua/luci/model/cbi/shadowsocksr/
|
||||
$(INSTALL_DATA) ./luasrc/view/shadowsocksr/* $(1)/usr/lib/lua/luci/view/shadowsocksr/
|
||||
po2lmo ./po/zh-cn/ssr-plus.po $(1)/usr/lib/lua/luci/i18n/ssr-plus.zh-cn.lmo
|
||||
endef
|
||||
|
||||
@ -80,7 +104,6 @@ define Package/luci-app-ssr-plus/postinst
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
( . /etc/uci-defaults/luci-ssr-plus ) && rm -f /etc/uci-defaults/luci-ssr-plus
|
||||
rm -f /tmp/luci-indexcache
|
||||
chmod 755 /etc/init.d/shadowsocksr >/dev/null 2>&1
|
||||
/etc/init.d/shadowsocksr enable >/dev/null 2>&1
|
||||
fi
|
||||
exit 0
|
||||
@ -89,8 +112,8 @@ endef
|
||||
define Package/luci-app-ssr-plus/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
/etc/init.d/shadowsocksr disable
|
||||
/etc/init.d/shadowsocksr stop
|
||||
/etc/init.d/shadowsocksr disable
|
||||
/etc/init.d/shadowsocksr stop
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
@ -7,38 +7,23 @@ function index()
|
||||
if not nixio.fs.access("/etc/config/shadowsocksr") then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
entry({"admin", "services", "shadowsocksr"}, alias("admin", "services", "shadowsocksr", "client"),_("ShadowSocksR Plus+"), 10).dependent = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"),_("SSR Client"), 10).leaf = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "servers"}, arcombine(cbi("shadowsocksr/servers", {autoapply=true}), cbi("shadowsocksr/client-config")),_("Severs Nodes"), 20).leaf = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "control"},cbi("shadowsocksr/control"), _("Access Control"), 30).leaf = true
|
||||
|
||||
-- entry({"admin", "services", "shadowsocksr", "list"},form("shadowsocksr/list"),_("GFW List"), 40).leaf = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "advanced"},cbi("shadowsocksr/advanced"),_("Advanced Settings"), 50).leaf = true
|
||||
|
||||
if nixio.fs.access("/usr/bin/ssr-server") then
|
||||
entry({"admin", "services", "shadowsocksr", "server"},arcombine(cbi("shadowsocksr/server"), cbi("shadowsocksr/server-config")),_("SSR Server"), 60).leaf = true
|
||||
end
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "status"},form("shadowsocksr/status"),_("Status"), 70).leaf = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "check"}, call("check_status"))
|
||||
entry({"admin", "services", "shadowsocksr", "refresh"}, call("refresh_data"))
|
||||
entry({"admin", "services", "shadowsocksr", "subscribe"}, call("subscribe"))
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "checkport"}, call("check_port"))
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "log"},form("shadowsocksr/log"),_("Log"), 80).leaf = true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr","run"},call("act_status")).leaf=true
|
||||
|
||||
entry({"admin", "services", "shadowsocksr", "ping"}, call("act_ping")).leaf=true
|
||||
|
||||
end
|
||||
|
||||
function subscribe()
|
||||
@ -60,7 +45,6 @@ function act_ping()
|
||||
local port = luci.http.formvalue("port")
|
||||
e.index = luci.http.formvalue("index")
|
||||
e.ping = luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'" % domain)
|
||||
|
||||
local iret = luci.sys.call(" ipset add ss_spec_wan_ac " .. domain .. " 2>/dev/null")
|
||||
local socket = nixio.socket("inet", "stream")
|
||||
socket:setopt("socket", "rcvtimeo", 3)
|
||||
@ -91,84 +75,82 @@ local set =luci.http.formvalue("set")
|
||||
local icount =0
|
||||
|
||||
if set == "gfw_data" then
|
||||
if nixio.fs.access("/usr/bin/wget-ssl") then
|
||||
if nixio.fs.access("/usr/bin/wget-ssl") then
|
||||
refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64"
|
||||
else
|
||||
refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64"
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
else
|
||||
refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64"
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
luci.sys.call("/usr/bin/ssr-gfw")
|
||||
icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l")
|
||||
if tonumber(icount)>1000 then
|
||||
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf")
|
||||
retstring=tostring(math.ceil(tonumber(icount)/2))
|
||||
else
|
||||
retstring ="0"
|
||||
end
|
||||
else
|
||||
retstring ="-1"
|
||||
retstring ="0"
|
||||
end
|
||||
else
|
||||
retstring ="-1"
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/gfwnew.txt ")
|
||||
else
|
||||
else
|
||||
retstring ="-1"
|
||||
end
|
||||
end
|
||||
elseif set == "ip_data" then
|
||||
refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt"
|
||||
sret=luci.sys.call(refresh_cmd)
|
||||
icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
|
||||
if sret== 0 and tonumber(icount)>1000 then
|
||||
refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt"
|
||||
sret=luci.sys.call(refresh_cmd)
|
||||
icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
|
||||
if sret== 0 and tonumber(icount)>1000 then
|
||||
oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l")
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
|
||||
retstring=tostring(tonumber(icount))
|
||||
luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
|
||||
retstring=tostring(tonumber(icount))
|
||||
else
|
||||
retstring ="0"
|
||||
retstring ="0"
|
||||
end
|
||||
|
||||
else
|
||||
else
|
||||
retstring ="-1"
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/china_ssr.txt ")
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/china_ssr.txt ")
|
||||
else
|
||||
local need_process = 0
|
||||
if nixio.fs.access("/usr/bin/wget-ssl") then
|
||||
refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf"
|
||||
need_process = 1
|
||||
else
|
||||
else
|
||||
refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf"
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
if need_process == 1 then
|
||||
luci.sys.call("/usr/bin/ssr-ad")
|
||||
end
|
||||
icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
|
||||
if tonumber(icount)>1000 then
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
|
||||
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")
|
||||
else
|
||||
else
|
||||
oldcount=0
|
||||
end
|
||||
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
end
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf")
|
||||
retstring=tostring(math.ceil(tonumber(icount)))
|
||||
if oldcount==0 then
|
||||
luci.sys.call("/etc/init.d/dnsmasq restart")
|
||||
end
|
||||
else
|
||||
retstring ="0"
|
||||
end
|
||||
else
|
||||
retstring ="-1"
|
||||
retstring ="0"
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/ad.conf ")
|
||||
else
|
||||
else
|
||||
retstring ="-1"
|
||||
end
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/ad.conf")
|
||||
else
|
||||
retstring ="-1"
|
||||
end
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ ret=retstring ,retcount=icount})
|
||||
@ -183,9 +165,7 @@ local server_name = ""
|
||||
local shadowsocksr = "shadowsocksr"
|
||||
local uci = luci.model.uci.cursor()
|
||||
local iret=1
|
||||
|
||||
uci:foreach(shadowsocksr, "servers", function(s)
|
||||
|
||||
if s.alias then
|
||||
server_name=s.alias
|
||||
elseif s.server and s.server_port then
|
||||
@ -206,7 +186,6 @@ uci:foreach(shadowsocksr, "servers", function(s)
|
||||
luci.sys.call(" ipset del ss_spec_wan_ac " .. s.server)
|
||||
end
|
||||
end)
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ ret=retstring })
|
||||
end
|
||||
|
@ -12,13 +12,12 @@ end)
|
||||
|
||||
local key_table = {}
|
||||
for key,_ in pairs(server_table) do
|
||||
table.insert(key_table,key)
|
||||
table.insert(key_table,key)
|
||||
end
|
||||
|
||||
table.sort(key_table)
|
||||
|
||||
m = Map(shadowsocksr)
|
||||
|
||||
-- [[ global ]]--
|
||||
s = m:section(TypedSection, "global", translate("Server failsafe auto swith settings"))
|
||||
s.anonymous = true
|
||||
|
||||
@ -43,6 +42,13 @@ 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, "adblock", translate("Enable adblock"))
|
||||
o.rmempty = false
|
||||
|
||||
-- [[ SOCKS5 Proxy ]]--
|
||||
if nixio.fs.access("/usr/bin/ssr-local") then
|
||||
s = m:section(TypedSection, "socks5_proxy", translate("SOCKS5 Proxy"))
|
||||
@ -60,5 +66,4 @@ o.default = 1080
|
||||
o.rmempty = false
|
||||
|
||||
end
|
||||
|
||||
return m
|
||||
|
@ -10,12 +10,12 @@ local sid = arg[1]
|
||||
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
|
||||
|
||||
local function isKcptun(file)
|
||||
if not fs.access(file, "rwx", "rx", "rx") then
|
||||
fs.chmod(file, 755)
|
||||
end
|
||||
if not fs.access(file, "rwx", "rx", "rx") then
|
||||
fs.chmod(file, 755)
|
||||
end
|
||||
|
||||
local str = sys.exec(file .. " -v | awk '{printf $1}'")
|
||||
return (str:lower() == "kcptun")
|
||||
local str = sys.exec(file .. " -v | awk '{printf $1}'")
|
||||
return (str:lower() == "kcptun")
|
||||
end
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ local encrypt_methods = {
|
||||
"aes-256-cfb",
|
||||
"aes-128-ctr",
|
||||
"aes-192-ctr",
|
||||
"aes-256-ctr",
|
||||
"aes-256-ctr",
|
||||
"bf-cfb",
|
||||
"camellia-128-cfb",
|
||||
"camellia-192-cfb",
|
||||
@ -95,17 +95,17 @@ obfs = {
|
||||
}
|
||||
|
||||
local securitys = {
|
||||
"auto",
|
||||
"none",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305"
|
||||
"auto",
|
||||
"none",
|
||||
"aes-128-gcm",
|
||||
"chacha20-poly1305"
|
||||
}
|
||||
|
||||
|
||||
m = Map(shadowsocksr, translate("Edit ShadowSocksR Server"))
|
||||
m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers")
|
||||
if m.uci:get(shadowsocksr, sid) ~= "servers" then
|
||||
luci.http.redirect(m.redirect)
|
||||
luci.http.redirect(m.redirect)
|
||||
return
|
||||
end
|
||||
|
||||
@ -114,7 +114,7 @@ s = m:section(NamedSection, sid, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(DummyValue,"ssr_url","SS/SSR/V2RAY/TROJAN URL")
|
||||
o = s:option(DummyValue,"ssr_url","SS/SSR/V2RAY/TROJAN URL")
|
||||
o.rawhtml = true
|
||||
o.template = "shadowsocksr/ssrurl"
|
||||
o.value =sid
|
||||
@ -124,7 +124,7 @@ o:value("ssr", translate("ShadowsocksR"))
|
||||
if nixio.fs.access("/usr/bin/ss-redir") then
|
||||
o:value("ss", translate("Shadowsocks New Version"))
|
||||
end
|
||||
if nixio.fs.access("/usr/bin/v2ray/v2ray") then
|
||||
if nixio.fs.access("/usr/bin/v2ray/v2ray") or nixio.fs.access("/usr/bin/v2ray") then
|
||||
o:value("v2ray", translate("V2Ray"))
|
||||
end
|
||||
if nixio.fs.access("/usr/sbin/trojan") then
|
||||
@ -341,9 +341,9 @@ o:depends("type", "v2ray")
|
||||
o:depends("type", "trojan")
|
||||
|
||||
o = s:option(Value, "tls_host", translate("TLS Host"))
|
||||
--o:depends("type", "trojan")
|
||||
o:depends("tls", "1")
|
||||
o.rmempty = true
|
||||
o:depends("type", "trojan")
|
||||
|
||||
-- [[ Mux ]]--
|
||||
o = s:option(Flag, "mux", translate("Mux"))
|
||||
@ -388,14 +388,14 @@ function o.validate(self, value, section)
|
||||
local kcp_file="/usr/bin/kcptun-client"
|
||||
local enable = kcp_enable:formvalue(section) or kcp_enable.disabled
|
||||
if enable == kcp_enable.enabled then
|
||||
if not fs.access(kcp_file) then
|
||||
return nil, translate("Haven't a Kcptun executable file")
|
||||
elseif not isKcptun(kcp_file) then
|
||||
return nil, translate("Not a Kcptun executable file")
|
||||
end
|
||||
end
|
||||
if not fs.access(kcp_file) then
|
||||
return nil, translate("Haven't a Kcptun executable file")
|
||||
elseif not isKcptun(kcp_file) then
|
||||
return nil, translate("Not a Kcptun executable file")
|
||||
end
|
||||
end
|
||||
|
||||
return value
|
||||
return value
|
||||
end
|
||||
o:depends("type", "ssr")
|
||||
o:depends("type", "ss")
|
||||
|
@ -21,12 +21,12 @@ uci:foreach(shadowsocksr, "servers", function(s)
|
||||
end
|
||||
end)
|
||||
|
||||
local key_table = {}
|
||||
for key,_ in pairs(server_table) do
|
||||
table.insert(key_table,key)
|
||||
end
|
||||
local key_table = {}
|
||||
for key,_ in pairs(server_table) do
|
||||
table.insert(key_table,key)
|
||||
end
|
||||
|
||||
table.sort(key_table)
|
||||
table.sort(key_table)
|
||||
|
||||
-- [[ Global Setting ]]--
|
||||
s = m:section(TypedSection, "global")
|
||||
|
@ -21,25 +21,25 @@ s:tab("lan_ac", translate("LAN IP AC"))
|
||||
o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Bypassed Host List"))
|
||||
o.datatype = "ipaddr"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List"))
|
||||
o.datatype = "ipaddr"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List"))
|
||||
o.datatype = "ipaddr"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
if entry.reachable then
|
||||
o:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
-- Part of Self
|
||||
@ -85,4 +85,4 @@ o.remove = function(self, section, value)
|
||||
NXFS.writefile(blockconf, "")
|
||||
end
|
||||
|
||||
return m
|
||||
return m
|
||||
|
@ -20,4 +20,4 @@ function f.handle(self, state, data)
|
||||
return true
|
||||
end
|
||||
|
||||
return f
|
||||
return f
|
||||
|
@ -5,12 +5,12 @@ t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 20
|
||||
function t.cfgvalue()
|
||||
local logs = luci.util.execi("cat /tmp/ssrplus.log")
|
||||
local s = ""
|
||||
for line in logs do
|
||||
s = line .. "\n" .. s
|
||||
end
|
||||
return s
|
||||
local logs = luci.util.execi("cat /tmp/ssrplus.log")
|
||||
local s = ""
|
||||
for line in logs do
|
||||
s = line .. "\n" .. s
|
||||
end
|
||||
return s
|
||||
end
|
||||
t.readonly="readonly"
|
||||
|
||||
|
@ -15,7 +15,7 @@ local encrypt_methods = {
|
||||
"aes-256-cfb",
|
||||
"aes-128-ctr",
|
||||
"aes-192-ctr",
|
||||
"aes-256-ctr",
|
||||
"aes-256-ctr",
|
||||
"bf-cfb",
|
||||
"camellia-128-cfb",
|
||||
"camellia-192-cfb",
|
||||
@ -44,7 +44,7 @@ m = Map(shadowsocksr, translate("Edit ShadowSocksR Server"))
|
||||
|
||||
m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/server")
|
||||
if m.uci:get(shadowsocksr, sid) ~= "server_config" then
|
||||
luci.http.redirect(m.redirect)
|
||||
luci.http.redirect(m.redirect)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,6 @@ local shadowsocksr = "shadowsocksr"
|
||||
local uci = luci.model.uci.cursor()
|
||||
local ipkg = require("luci.model.ipkg")
|
||||
|
||||
|
||||
m = Map(shadowsocksr, translate("ShadowSocksR Server"))
|
||||
|
||||
local encrypt_methods = {
|
||||
@ -19,7 +18,7 @@ local encrypt_methods = {
|
||||
"aes-256-cfb",
|
||||
"aes-128-ctr",
|
||||
"aes-192-ctr",
|
||||
"aes-256-ctr",
|
||||
"aes-256-ctr",
|
||||
"bf-cfb",
|
||||
"camellia-128-cfb",
|
||||
"camellia-192-cfb",
|
||||
@ -52,16 +51,10 @@ obfs = {
|
||||
"tls1.2_ticket_fastauth",
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- [[ Global Setting ]]--
|
||||
sec = m:section(TypedSection, "server_global", translate("Global Setting"))
|
||||
sec.anonymous = true
|
||||
|
||||
|
||||
|
||||
o = sec:option(Flag, "enable_server", translate("Enable Server"))
|
||||
o.rmempty = false
|
||||
|
||||
@ -90,7 +83,6 @@ function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
end
|
||||
|
||||
|
||||
o = sec:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
@ -102,13 +94,9 @@ function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
end
|
||||
|
||||
|
||||
|
||||
o = sec:option(DummyValue, "obfs", translate("Obfs"))
|
||||
function o.cfgvalue(...)
|
||||
return Value.cfgvalue(...) or "?"
|
||||
end
|
||||
|
||||
|
||||
|
||||
return m
|
||||
|
@ -52,10 +52,10 @@ o.template = "shadowsocksr/subscribe"
|
||||
|
||||
-- o.inputstyle = "apply"
|
||||
-- o.write = function()
|
||||
-- luci.sys.call("lua /root/subscribe.lua >>/tmp/ssrplus.log 2>&1")
|
||||
-- -- luci.sys.call("echo 123 >>/tmp/ssrplus.log 2>&1")
|
||||
-- --luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1")
|
||||
-- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
|
||||
-- luci.sys.call("lua /root/subscribe.lua >>/tmp/ssrplus.log 2>&1")
|
||||
-- -- luci.sys.call("echo 123 >>/tmp/ssrplus.log 2>&1")
|
||||
-- -- luci.sys.exec("bash /usr/share/shadowsocksr/subscribe.sh >>/tmp/ssrplus.log 2>&1")
|
||||
-- luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
|
||||
-- end
|
||||
|
||||
|
||||
@ -63,11 +63,11 @@ o = s:option(Button,"delete",translate("Delete all severs"))
|
||||
o.inputstyle = "reset"
|
||||
o.description = string.format(translate("Server Count") .. ": %d", server_count)
|
||||
o.write = function()
|
||||
uci:delete_all("shadowsocksr", "servers", function(s) return true end)
|
||||
uci:save("shadowsocksr")
|
||||
luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
|
||||
return
|
||||
uci:delete_all("shadowsocksr", "servers", function(s) return true end)
|
||||
uci:save("shadowsocksr")
|
||||
luci.sys.call("uci commit shadowsocksr && /etc/init.d/shadowsocksr stop")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
|
||||
return
|
||||
end
|
||||
|
||||
-- [[ Servers Manage ]]--
|
||||
@ -81,7 +81,7 @@ function s.create(...)
|
||||
local sid = TypedSection.create(...)
|
||||
if sid then
|
||||
luci.http.redirect(s.extedit % sid)
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -15,9 +15,10 @@ local gfw_count=0
|
||||
local ad_count=0
|
||||
local ip_count=0
|
||||
local gfwmode=0
|
||||
local ucic = luci.model.uci.cursor()
|
||||
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
|
||||
gfwmode=1
|
||||
gfwmode=1
|
||||
end
|
||||
|
||||
local shadowsocksr = "shadowsocksr"
|
||||
@ -32,27 +33,27 @@ local sys = require "luci.sys"
|
||||
local kcptun_version=translate("Unknown")
|
||||
local kcp_file="/usr/bin/kcptun-client"
|
||||
if not fs.access(kcp_file) then
|
||||
kcptun_version=translate("Not exist")
|
||||
kcptun_version=translate("Not exist")
|
||||
else
|
||||
if not fs.access(kcp_file, "rwx", "rx", "rx") then
|
||||
fs.chmod(kcp_file, 755)
|
||||
end
|
||||
kcptun_version=sys.exec(kcp_file .. " -v | awk '{printf $3}'")
|
||||
if not kcptun_version or kcptun_version == "" then
|
||||
kcptun_version = translate("Unknown")
|
||||
end
|
||||
|
||||
if not fs.access(kcp_file, "rwx", "rx", "rx") then
|
||||
fs.chmod(kcp_file, 755)
|
||||
end
|
||||
kcptun_version=sys.exec(kcp_file .. " -v | awk '{printf $3}'")
|
||||
if not kcptun_version or kcptun_version == "" then
|
||||
kcptun_version = translate("Unknown")
|
||||
end
|
||||
|
||||
if gfwmode==1 then
|
||||
gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
|
||||
ad_count=tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l"))
|
||||
end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/etc/china_ssr.txt") then
|
||||
ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l")
|
||||
|
||||
if gfwmode == 1 then
|
||||
gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
|
||||
ad_count=tonumber(sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l"))
|
||||
end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/etc/china_ssr.txt") then
|
||||
ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l")
|
||||
end
|
||||
|
||||
local icount=sys.exec("busybox ps -w | grep ssr-reudp |grep -v grep| wc -l")
|
||||
@ -65,10 +66,9 @@ reudp_run=1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if luci.sys.call("busybox ps -w | grep ssr-retcp | grep -v grep >/dev/null") == 0 then
|
||||
redir_run=1
|
||||
end
|
||||
end
|
||||
|
||||
if luci.sys.call("pidof ssr-local >/dev/null") == 0 then
|
||||
sock5_run=1
|
||||
@ -76,25 +76,25 @@ end
|
||||
|
||||
if luci.sys.call("pidof kcptun-client >/dev/null") == 0 then
|
||||
kcptun_run=1
|
||||
end
|
||||
end
|
||||
|
||||
if luci.sys.call("pidof ssr-server >/dev/null") == 0 then
|
||||
server_run=1
|
||||
end
|
||||
end
|
||||
|
||||
if luci.sys.call("busybox ps -w | grep ssr-tunnel |grep -v grep >/dev/null") == 0 then
|
||||
tunnel_run=1
|
||||
end
|
||||
end
|
||||
|
||||
if luci.sys.call("pidof pdnsd >/dev/null") == 0 then
|
||||
pdnsd_run=1
|
||||
end
|
||||
if luci.sys.call("pidof pdnsd >/dev/null") == 0 then
|
||||
pdnsd_run=1
|
||||
end
|
||||
|
||||
m = SimpleForm("Version")
|
||||
m.reset = false
|
||||
m.submit = false
|
||||
|
||||
s=m:field(DummyValue,"redir_run",translate("Global Client"))
|
||||
s=m:field(DummyValue,"redir_run",translate("Global Client"))
|
||||
s.rawhtml = true
|
||||
if redir_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
@ -102,7 +102,7 @@ else
|
||||
s.value = translate("Not Running")
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay"))
|
||||
s=m:field(DummyValue,"reudp_run",translate("Game Mode UDP Relay"))
|
||||
s.rawhtml = true
|
||||
if reudp_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
@ -111,15 +111,15 @@ s.value = translate("Not Running")
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"pdnsd_run",translate("PDNSD"))
|
||||
s.rawhtml = true
|
||||
if pdnsd_run == 1 then
|
||||
s.rawhtml = true
|
||||
if pdnsd_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
else
|
||||
else
|
||||
s.value = translate("Not Running")
|
||||
end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/usr/bin/ssr-local") then
|
||||
s=m:field(DummyValue,"sock5_run",translate("SOCKS5 Proxy"))
|
||||
s=m:field(DummyValue,"sock5_run",translate("SOCKS5 Proxy"))
|
||||
s.rawhtml = true
|
||||
if sock5_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
@ -129,7 +129,7 @@ end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/usr/bin/ssr-server") then
|
||||
s=m:field(DummyValue,"server_run",translate("Global SSR Server"))
|
||||
s=m:field(DummyValue,"server_run",translate("Global SSR Server"))
|
||||
s.rawhtml = true
|
||||
if server_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
@ -139,11 +139,11 @@ end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/usr/bin/kcptun-client") then
|
||||
s=m:field(DummyValue,"kcp_version",translate("KcpTun Version"))
|
||||
s=m:field(DummyValue,"kcp_version",translate("KcpTun Version"))
|
||||
s.rawhtml = true
|
||||
s.value =kcptun_version
|
||||
|
||||
s=m:field(DummyValue,"kcptun_run",translate("KcpTun"))
|
||||
s=m:field(DummyValue,"kcptun_run",translate("KcpTun"))
|
||||
s.rawhtml = true
|
||||
if kcptun_run == 1 then
|
||||
s.value =font_blue .. bold_on .. translate("Running") .. bold_off .. font_off
|
||||
@ -153,22 +153,28 @@ end
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"google",translate("Google Connectivity"))
|
||||
s.value = translate("No Check")
|
||||
s.value = translate("No Check")
|
||||
s.template = "shadowsocksr/check"
|
||||
|
||||
s=m:field(DummyValue,"baidu",translate("Baidu Connectivity"))
|
||||
s.value = translate("No Check")
|
||||
s=m:field(DummyValue,"baidu",translate("Baidu Connectivity"))
|
||||
s.value = translate("No Check")
|
||||
s.template = "shadowsocksr/check"
|
||||
|
||||
if gfwmode==1 then
|
||||
s=m:field(DummyValue,"gfw_data",translate("GFW List Data"))
|
||||
if gfwmode == 1 then
|
||||
s=m:field(DummyValue,"gfw_data",translate("GFW List Data"))
|
||||
s.rawhtml = true
|
||||
s.template = "shadowsocksr/refresh"
|
||||
s.value =tostring(math.ceil(gfw_count)) .. " " .. translate("Records")
|
||||
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"ip_data",translate("China IP Data"))
|
||||
if ucic:get_first(shadowsocksr, 'global', 'adblock', '') == '1' then
|
||||
s=m:field(DummyValue,"ad_data",translate("Advertising Data"))
|
||||
s.rawhtml = true
|
||||
s.template = "shadowsocksr/refresh"
|
||||
s.value =ad_count .. " " .. translate("Records")
|
||||
end
|
||||
|
||||
s=m:field(DummyValue,"ip_data",translate("China IP Data"))
|
||||
s.rawhtml = true
|
||||
s.template = "shadowsocksr/refresh"
|
||||
s.value =ip_count .. " " .. translate("Records")
|
||||
|
@ -1,7 +1,5 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function check_connect(btn,urlname)
|
||||
{
|
||||
btn.disabled = true;
|
||||
@ -18,20 +16,14 @@
|
||||
s.innerHTML ="<font color='green'>"+"<%:Connect OK%>"+"</font>";
|
||||
else
|
||||
s.innerHTML ="<font color='red'>"+"<%:Connect Error%>"+"</font>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Check Connect%>';
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Connect%>" onclick="return check_connect(this,'<%=self.option%>')" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function check_port(btn)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Check...%>';
|
||||
btn.value = '<%:Check...%>';
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocksr","checkport")%>',
|
||||
null,
|
||||
function(x,rv)
|
||||
@ -13,24 +12,15 @@
|
||||
var s = document.getElementById('<%=self.option%>-status');
|
||||
if (s)
|
||||
{
|
||||
|
||||
s.innerHTML =rv.ret;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Check Server%>';
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:Check Server%>" onclick="return check_port(this)" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
|
||||
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -1,11 +1,9 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function refresh_data(btn,dataname)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Refresh...%> ';
|
||||
btn.value = '<%:Refresh...%> ';
|
||||
murl=dataname;
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "shadowsocksr","refresh")%>',
|
||||
{ set:murl },
|
||||
@ -24,21 +22,14 @@
|
||||
{
|
||||
s.innerHTML ="<font color='green'>"+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+"</font>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Refresh Data %>';
|
||||
}
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:Refresh Data%> " onclick="return refresh_data(this,'<%=self.option%>')" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -2,11 +2,9 @@
|
||||
Copyright 2018-2019 Lienol <lawlienol@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
const doms = document.getElementsByClassName('pingtime');
|
||||
|
@ -1,227 +1,237 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function padright(str, cnt, pad) {
|
||||
return str + Array(cnt + 1).join(pad);
|
||||
}
|
||||
function b64EncodeUnicode(str) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
||||
return String.fromCharCode('0x' + p1);
|
||||
}));
|
||||
}
|
||||
function b64encutf8safe(str) {
|
||||
return b64EncodeUnicode(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '');
|
||||
}
|
||||
function b64DecodeUnicode(str) {
|
||||
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
}).join(''));
|
||||
}
|
||||
function b64decutf8safe(str) {
|
||||
var l;
|
||||
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
||||
l = str.length;
|
||||
l = (4 - l % 4) % 4;
|
||||
if (l)
|
||||
str = padright(str, l, "=");
|
||||
return b64DecodeUnicode(str);
|
||||
}
|
||||
function b64encsafe(str) {
|
||||
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '')
|
||||
}
|
||||
function b64decsafe(str) {
|
||||
var l;
|
||||
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
||||
l = str.length;
|
||||
l = (4 - l % 4) % 4;
|
||||
if (l)
|
||||
str = padright(str, l, "=");
|
||||
return atob(str);
|
||||
}
|
||||
function dictvalue(d, key) {
|
||||
var v = d[key];
|
||||
if (typeof (v) == 'undefined' || v == '')
|
||||
return '';
|
||||
return b64decsafe(v);
|
||||
}
|
||||
function export_ssr_url(btn, urlname, sid) {
|
||||
var s = document.getElementById(urlname + '-status');
|
||||
if (!s)
|
||||
return false;
|
||||
var v_server = document.getElementById('cbid.shadowsocksr.' + sid + '.server');
|
||||
var v_port = document.getElementById('cbid.shadowsocksr.' + sid + '.server_port');
|
||||
var v_protocol = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol');
|
||||
var v_method = document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method');
|
||||
var v_obfs = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs');
|
||||
var v_password = document.getElementById('cbid.shadowsocksr.' + sid + '.password');
|
||||
var v_obfs_param = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param');
|
||||
var v_protocol_param = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param');
|
||||
var v_alias = document.getElementById('cbid.shadowsocksr.' + sid + '.alias');
|
||||
function padright(str, cnt, pad) {
|
||||
return str + Array(cnt + 1).join(pad);
|
||||
}
|
||||
function b64EncodeUnicode(str) {
|
||||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
||||
return String.fromCharCode('0x' + p1);
|
||||
}));
|
||||
}
|
||||
function b64encutf8safe(str) {
|
||||
return b64EncodeUnicode(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '');
|
||||
}
|
||||
function b64DecodeUnicode(str) {
|
||||
return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
}).join(''));
|
||||
}
|
||||
function b64decutf8safe(str) {
|
||||
var l;
|
||||
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
||||
l = str.length;
|
||||
l = (4 - l % 4) % 4;
|
||||
if (l)
|
||||
str = padright(str, l, "=");
|
||||
return b64DecodeUnicode(str);
|
||||
}
|
||||
function b64encsafe(str) {
|
||||
return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, '')
|
||||
}
|
||||
function b64decsafe(str) {
|
||||
var l;
|
||||
str = str.replace(/-/g, "+").replace(/_/g, "/");
|
||||
l = str.length;
|
||||
l = (4 - l % 4) % 4;
|
||||
if (l)
|
||||
str = padright(str, l, "=");
|
||||
return atob(str);
|
||||
}
|
||||
function dictvalue(d, key) {
|
||||
var v = d[key];
|
||||
if (typeof (v) == 'undefined' || v == '')
|
||||
return '';
|
||||
return b64decsafe(v);
|
||||
}
|
||||
function export_ssr_url(btn, urlname, sid) {
|
||||
var s = document.getElementById(urlname + '-status');
|
||||
if (!s)
|
||||
return false;
|
||||
var v_server = document.getElementById('cbid.shadowsocksr.' + sid + '.server');
|
||||
var v_port = document.getElementById('cbid.shadowsocksr.' + sid + '.server_port');
|
||||
var v_protocol = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol');
|
||||
var v_method = document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method');
|
||||
var v_obfs = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs');
|
||||
var v_password = document.getElementById('cbid.shadowsocksr.' + sid + '.password');
|
||||
var v_obfs_param = document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param');
|
||||
var v_protocol_param = document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param');
|
||||
var v_alias = document.getElementById('cbid.shadowsocksr.' + sid + '.alias');
|
||||
var ssr_str = v_server.value + ":" +
|
||||
v_port.value + ":" +
|
||||
v_protocol.value + ":" +
|
||||
v_method.value + ":" +
|
||||
v_obfs.value + ":" +
|
||||
b64encsafe(v_password.value) +
|
||||
"/?obfsparam=" + b64encsafe(v_obfs_param.value) +
|
||||
"&protoparam=" + b64encsafe(v_protocol_param.value) +
|
||||
"&remarks=" + b64encutf8safe(v_alias.value);
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = "ssr://" + b64encsafe(ssr_str);
|
||||
textarea.style.position = "fixed";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
||||
s.innerHTML = "<font color='green'><%:Copy SSR to clipboard successfully.%></font>";
|
||||
} catch (ex) {
|
||||
s.innerHTML = "<font color='red'><%:Unable to copy SSR to clipboard.%></font>";
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var ssr_str = v_server.value + ":" +
|
||||
v_port.value + ":" +
|
||||
v_protocol.value + ":" +
|
||||
v_method.value + ":" +
|
||||
v_obfs.value + ":" +
|
||||
b64encsafe(v_password.value) +
|
||||
"/?obfsparam=" + b64encsafe(v_obfs_param.value) +
|
||||
"&protoparam=" + b64encsafe(v_protocol_param.value) +
|
||||
"&remarks=" + b64encutf8safe(v_alias.value);
|
||||
var textarea = document.createElement("textarea");
|
||||
textarea.textContent = "ssr://" + b64encsafe(ssr_str);
|
||||
textarea.style.position = "fixed";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
document.execCommand("copy"); // Security exception may be thrown by some browsers.
|
||||
s.innerHTML = "<font color='green'><%:Copy SSR to clipboard successfully.%></font>";
|
||||
} catch (ex) {
|
||||
s.innerHTML = "<font color='red'><%:Unable to copy SSR to clipboard.%></font>";
|
||||
} finally {
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function import_ssr_url(btn, urlname, sid) {
|
||||
var s = document.getElementById(urlname + '-status');
|
||||
if (!s)
|
||||
return false;
|
||||
var ssrurl = prompt("在这里黏贴配置链接 ssr:// | ss:// | vmess:// | trojan://", "");
|
||||
if (ssrurl == null || ssrurl == "") {
|
||||
s.innerHTML = "<font color='red'>用户取消</font>";
|
||||
return false;
|
||||
}
|
||||
s.innerHTML = "";
|
||||
//var ssu = ssrurl.match(/ssr:\/\/([A-Za-z0-9_-]+)/i);
|
||||
var ssu = ssrurl.split('://');
|
||||
console.log(ssu.length);
|
||||
if ((ssu[0] != "ssr" && ssu[0] != "ss" && ssu[0] != "vmess" && ssu[0] != "trojan") || ssu[1] == "") {
|
||||
s.innerHTML = "<font color='red'>无效格式</font>";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function import_ssr_url(btn, urlname, sid) {
|
||||
var s = document.getElementById(urlname + '-status');
|
||||
if (!s)
|
||||
return false;
|
||||
var ssrurl = prompt("在这里黏贴配置链接 ssr:// | ss:// | vmess:// | trojan://", "");
|
||||
if (ssrurl == null || ssrurl == "") {
|
||||
s.innerHTML = "<font color='red'>用户取消</font>";
|
||||
return false;
|
||||
}
|
||||
s.innerHTML = "";
|
||||
//var ssu = ssrurl.match(/ssr:\/\/([A-Za-z0-9_-]+)/i);
|
||||
var ssu = ssrurl.split('://');
|
||||
console.log(ssu.length);
|
||||
if ((ssu[0] != "ssr" && ssu[0] != "ss" && ssu[0] != "vmess" && ssu[0] != "trojan") || ssu[1] == "") {
|
||||
s.innerHTML = "<font color='red'>无效格式</font>";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("change", true, true);
|
||||
if (ssu[0] == "ssr") {
|
||||
var sstr = b64decsafe(ssu[1]);
|
||||
var ploc = sstr.indexOf("/?");
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ssr";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var url0, param = "";
|
||||
if (ploc > 0) {
|
||||
url0 = sstr.substr(0, ploc);
|
||||
param = sstr.substr(ploc + 2);
|
||||
}
|
||||
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
|
||||
if (!ssm || ssm.length < 7)
|
||||
return false;
|
||||
var pdict = {};
|
||||
if (param.length > 2)
|
||||
{
|
||||
var a = param.split('&');
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var b = a[i].split('=');
|
||||
pdict[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
|
||||
}
|
||||
}
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm[2];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol').value = ssm[3];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method').value = ssm[4];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs').value = ssm[5];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = b64decsafe(ssm[6]);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param').value = dictvalue(pdict, 'obfsparam');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param').value = dictvalue(pdict, 'protoparam');
|
||||
|
||||
var rem = pdict['remarks'];
|
||||
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0)
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = b64decutf8safe(rem);
|
||||
|
||||
s.innerHTML = "<font color='green'>导入ShadowsocksR配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "ss") {
|
||||
var ploc = ssu[1].indexOf("#");
|
||||
if (ploc > 0) {
|
||||
url0 = ssu[1].substr(0, ploc);
|
||||
param = ssu[1].substr(ploc + 1);
|
||||
} else {
|
||||
url0 = ssu[1]
|
||||
}
|
||||
var sstr = b64decsafe(url0);
|
||||
|
||||
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ss";
|
||||
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var team = sstr.split('@');
|
||||
console.log(param);
|
||||
var part1 = team[0].split(':');
|
||||
var part2 = team[1].split(':');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method_ss').value = part1[0];
|
||||
if (param != undefined) {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
|
||||
}
|
||||
|
||||
s.innerHTML = "<font color='green'>导入Shadowsocks配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "trojan") {
|
||||
var ploc = ssu[1].indexOf("#");
|
||||
if (ploc > 0) {
|
||||
url0 = ssu[1].substr(0, ploc);
|
||||
param = ssu[1].substr(ploc + 1);
|
||||
} else {
|
||||
url0 = ssu[1]
|
||||
}
|
||||
var sstr = b64decsafe(url0);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "trojan";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var team = sstr.split('@');
|
||||
console.log(param);
|
||||
var part1 = team[0].split(':');
|
||||
var part2 = team[1].split(':');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
|
||||
if (param != undefined) {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
|
||||
}
|
||||
s.innerHTML = "<font color='green'>导入Trojan配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "vmess") {
|
||||
var sstr = b64DecodeUnicode(ssu[1]);
|
||||
var ploc = sstr.indexOf("/?");
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "v2ray";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var url0, param = "";
|
||||
if (ploc > 0) {
|
||||
url0 = sstr.substr(0, ploc);
|
||||
param = sstr.substr(ploc + 2);
|
||||
}
|
||||
var ssm = JSON.parse(sstr);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = ssm.ps;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm.add;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm.port;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alter_id').value = ssm.aid;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.vmess_id').value = ssm.id;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.security').value = ssm.type;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').value = ssm.net;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.http_host').value = ssm.host;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.http_path').value = ssm.path;
|
||||
|
||||
s.innerHTML = "<font color='green'>导入V2ray配置信息成功</font>";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
var event = document.createEvent("HTMLEvents");
|
||||
event.initEvent("change", true, true);
|
||||
if (ssu[0] == "ssr") {
|
||||
var sstr = b64decsafe(ssu[1]);
|
||||
var ploc = sstr.indexOf("/?");
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ssr";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var url0, param = "";
|
||||
if (ploc > 0) {
|
||||
url0 = sstr.substr(0, ploc);
|
||||
param = sstr.substr(ploc + 2);
|
||||
}
|
||||
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
|
||||
if (!ssm || ssm.length < 7)
|
||||
return false;
|
||||
var pdict = {};
|
||||
if (param.length > 2)
|
||||
{
|
||||
var a = param.split('&');
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var b = a[i].split('=');
|
||||
pdict[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
|
||||
}
|
||||
}
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm[2];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol').value = ssm[3];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method').value = ssm[4];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs').value = ssm[5];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = b64decsafe(ssm[6]);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.obfs_param').value = dictvalue(pdict, 'obfsparam');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.protocol_param').value = dictvalue(pdict, 'protoparam');
|
||||
var rem = pdict['remarks'];
|
||||
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0)
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = b64decutf8safe(rem);
|
||||
s.innerHTML = "<font color='green'>导入ShadowsocksR配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "ss") {
|
||||
var ploc = ssu[1].indexOf("#");
|
||||
if (ploc > 0) {
|
||||
url0 = ssu[1].substr(0, ploc);
|
||||
param = ssu[1].substr(ploc + 1);
|
||||
} else {
|
||||
url0 = ssu[1]
|
||||
}
|
||||
var sstr = b64decsafe(url0);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "ss";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var team = sstr.split('@');
|
||||
console.log(param);
|
||||
var part1 = team[0].split(':');
|
||||
var part2 = team[1].split(':');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.encrypt_method_ss').value = part1[0];
|
||||
if (param != undefined) {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
|
||||
}
|
||||
s.innerHTML = "<font color='green'>导入Shadowsocks配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "trojan") {
|
||||
var ploc = ssu[1].indexOf("#");
|
||||
if (ploc > 0) {
|
||||
url0 = ssu[1].substr(0, ploc);
|
||||
param = ssu[1].substr(ploc + 1);
|
||||
} else {
|
||||
url0 = ssu[1]
|
||||
}
|
||||
var sstr = b64decsafe(url0);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "trojan";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var team = sstr.split('@');
|
||||
console.log(param);
|
||||
var part1 = team[0].split(':');
|
||||
var part2 = team[1].split(':');
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = part2[0];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = part2[1];
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.password').value = part1[1];
|
||||
if (param != undefined) {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = decodeURI(param);
|
||||
}
|
||||
s.innerHTML = "<font color='green'>导入Trojan配置信息成功</font>";
|
||||
return false;
|
||||
} else if (ssu[0] == "vmess") {
|
||||
var sstr = b64DecodeUnicode(ssu[1]);
|
||||
var ploc = sstr.indexOf("/?");
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').value = "v2ray";
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.type').dispatchEvent(event);
|
||||
var url0, param = "";
|
||||
if (ploc > 0) {
|
||||
url0 = sstr.substr(0, ploc);
|
||||
param = sstr.substr(ploc + 2);
|
||||
}
|
||||
var ssm = JSON.parse(sstr);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alias').value = ssm.ps;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server').value = ssm.add;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.server_port').value = ssm.port;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.alter_id').value = ssm.aid;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.vmess_id').value = ssm.id;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').value = ssm.net;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.transport').dispatchEvent(event);
|
||||
if (ssm.net == "tcp") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.http_host').value = ssm.host;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.http_path').value = ssm.path;
|
||||
}
|
||||
if (ssm.net == "ws") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.ws_host').value = ssm.host;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.ws_path').value = ssm.path;
|
||||
}
|
||||
if (ssm.net == "h2") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.h2_host').value = ssm.host;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.h2_path').value = ssm.path;
|
||||
}
|
||||
if (ssm.net == "quic") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.quic_security').value = ssm.securty;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.quic_key').value = ssm.key;
|
||||
}
|
||||
if (ssm.net == "kcp") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.kcp_guise').value = ssm.type;
|
||||
}
|
||||
if (ssm.tls == "tls") {
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.tls').checked = true;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.tls').dispatchEvent(event);
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.tls_host').value = ssm.host;
|
||||
}
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.mux').checked = true;
|
||||
document.getElementById('cbid.shadowsocksr.' + sid + '.mux').dispatchEvent(event);
|
||||
s.innerHTML = "<font color='green'>导入V2ray配置信息成功</font>";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="导入配置信息" onclick="return import_ssr_url(this, '<%=self.option%>', '<%=self.value%>')" />
|
||||
<span id="<%=self.option%>-status"></span>
|
||||
|
||||
<%+cbi/valuefooter%>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function subscribe(btn,dataname) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Refresh...%> ';
|
||||
@ -15,9 +13,6 @@
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
|
||||
<input type="button" class="cbi-button cbi-input-apply" value="<%:Update All Subscribe Severs%> " onclick="return subscribe(this,'<%=self.option%>')" />
|
||||
<!-- <span id="<%=self.option%>-status"><em><%=self.value%></em></span> -->
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -271,7 +271,6 @@ msgstr "正在检查.."
|
||||
msgid "Proxy Check"
|
||||
msgstr "代理检查"
|
||||
|
||||
|
||||
msgid "GFW List Data"
|
||||
msgstr "【GFW列表】数据库"
|
||||
|
||||
@ -323,6 +322,9 @@ msgstr "切换检查超时时间(秒)"
|
||||
msgid "Check Try Count"
|
||||
msgstr "切换检查重试次数"
|
||||
|
||||
msgid "Enable adblock"
|
||||
msgstr "启用广告屏蔽"
|
||||
|
||||
msgid "Enable Process Deamon"
|
||||
msgstr "启用进程自动守护"
|
||||
|
||||
@ -464,6 +466,9 @@ msgstr "游戏模式UDP中继服务器"
|
||||
msgid "Game Mode UDP Relay"
|
||||
msgstr "游戏模式UDP中继"
|
||||
|
||||
msgid "adblock settings"
|
||||
msgstr "广告屏蔽设置"
|
||||
|
||||
msgid "Server failsafe auto swith settings"
|
||||
msgstr "服务器节点故障自动切换设置"
|
||||
|
||||
|
@ -948,7 +948,6 @@
|
||||
43.250.244.0/22
|
||||
43.251.4.0/22
|
||||
43.251.8.0/22
|
||||
43.251.12.0/22
|
||||
43.251.36.0/22
|
||||
43.251.100.0/22
|
||||
43.251.116.0/22
|
||||
@ -3990,6 +3989,10 @@
|
||||
103.146.236.0/23
|
||||
103.146.252.0/23
|
||||
103.147.12.0/23
|
||||
103.147.124.0/23
|
||||
103.147.198.0/23
|
||||
103.147.206.0/23
|
||||
103.147.211.0/24
|
||||
103.192.0.0/22
|
||||
103.192.4.0/22
|
||||
103.192.8.0/22
|
||||
@ -4708,7 +4711,6 @@
|
||||
103.227.228.0/22
|
||||
103.228.12.0/22
|
||||
103.228.28.0/22
|
||||
103.228.68.0/22
|
||||
103.228.88.0/22
|
||||
103.228.128.0/22
|
||||
103.228.136.0/22
|
||||
@ -5821,7 +5823,8 @@
|
||||
124.64.0.0/15
|
||||
124.66.0.0/17
|
||||
124.67.0.0/16
|
||||
124.68.0.0/14
|
||||
124.68.0.0/15
|
||||
124.70.0.0/15
|
||||
124.72.0.0/16
|
||||
124.73.0.0/16
|
||||
124.74.0.0/15
|
||||
@ -6233,7 +6236,6 @@
|
||||
180.233.144.0/22
|
||||
180.235.64.0/19
|
||||
180.235.112.0/22
|
||||
180.235.136.0/22
|
||||
182.16.144.0/22
|
||||
182.16.148.0/22
|
||||
182.16.192.0/19
|
||||
|
@ -10,6 +10,7 @@ config global
|
||||
option switch_timeout '5'
|
||||
option switch_time '667'
|
||||
option switch_try_count '3'
|
||||
option adblock '0'
|
||||
|
||||
config socks5_proxy
|
||||
option server 'nil'
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ add_cron()
|
||||
sed -i '/shadowsocksr/d' $CRON_FILE
|
||||
sed -i '/ssrplus.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/ssrplus.log' >> $CRON_FILE
|
||||
[ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/bin/lua /usr/share/shadowsocksr/subscribe.lua" >> $CRON_FILE
|
||||
[ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/share/shadowsocksr/update.sh" >> $CRON_FILE
|
||||
[ $(uci_get_by_type server_subscribe auto_update 0) -eq 1 ] && echo "0 $(uci_get_by_type server_subscribe auto_update_time) * * * /usr/bin/lua /usr/share/shadowsocksr/update.lua" >> $CRON_FILE
|
||||
crontab $CRON_FILE
|
||||
}
|
||||
|
||||
@ -60,73 +60,72 @@ del_cron()
|
||||
run_mode=$(uci_get_by_type global run_mode)
|
||||
|
||||
gen_config_file() {
|
||||
local host=$(uci_get_by_name $1 server)
|
||||
if echo $host|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
hostip=${host}
|
||||
elif [ "$host" != "${host#*:[0-9a-fA-F]}" ] ;then
|
||||
hostip=${host}
|
||||
else
|
||||
hostip=`ping ${host} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1`
|
||||
if echo $hostip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
hostip=${hostip}
|
||||
else
|
||||
hostip=`cat /etc/ssr_ip`
|
||||
fi
|
||||
fi
|
||||
[ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1"
|
||||
local host=$(uci_get_by_name $1 server)
|
||||
if echo $host|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
hostip=${host}
|
||||
elif [ "$host" != "${host#*:[0-9a-fA-F]}" ] ;then
|
||||
hostip=${host}
|
||||
else
|
||||
hostip=`ping ${host} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1`
|
||||
if echo $hostip|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
hostip=${hostip}
|
||||
else
|
||||
hostip=`cat /etc/ssr_ip`
|
||||
fi
|
||||
fi
|
||||
[ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1"
|
||||
|
||||
if [ $2 = "0" ] ;then
|
||||
config_file=$CONFIG_FILE
|
||||
elif [ $2 = "1" ]; then
|
||||
config_file=$CONFIG_UDP_FILE
|
||||
else
|
||||
config_file=$CONFIG_SOCK5_FILE
|
||||
fi
|
||||
if [ $(uci_get_by_name $1 fast_open 0) = "1" ] ;then
|
||||
fastopen="true";
|
||||
else
|
||||
fastopen="false";
|
||||
fi
|
||||
if [ $2 = "0" ] ;then
|
||||
config_file=$CONFIG_FILE
|
||||
elif [ $2 = "1" ]; then
|
||||
config_file=$CONFIG_UDP_FILE
|
||||
else
|
||||
config_file=$CONFIG_SOCK5_FILE
|
||||
fi
|
||||
if [ $(uci_get_by_name $1 fast_open 0) = "1" ] ;then
|
||||
fastopen="true";
|
||||
else
|
||||
fastopen="false";
|
||||
fi
|
||||
local stype=$(uci_get_by_name $1 type)
|
||||
if [ "$stype" == "ss" ] ;then
|
||||
cat <<-EOF >$config_file
|
||||
{
|
||||
"server": "$hostip",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": $(uci_get_by_name $1 local_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method_ss)",
|
||||
"reuse_port": true,
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
{
|
||||
"server": "$hostip",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": $(uci_get_by_name $1 local_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method_ss)",
|
||||
"reuse_port": true,
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
EOF
|
||||
elif [ "$stype" == "ssr" ] ;then
|
||||
cat <<-EOF >$config_file
|
||||
{
|
||||
|
||||
"server": "$hostip",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": $(uci_get_by_name $1 local_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method)",
|
||||
"protocol": "$(uci_get_by_name $1 protocol)",
|
||||
"protocol_param": "$(uci_get_by_name $1 protocol_param)",
|
||||
"obfs": "$(uci_get_by_name $1 obfs)",
|
||||
"obfs_param": "$(uci_get_by_name $1 obfs_param)",
|
||||
"reuse_port": true,
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
elif [ "$stype" == "ssr" ] ;then
|
||||
cat <<-EOF >$config_file
|
||||
{
|
||||
"server": "$hostip",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": $(uci_get_by_name $1 local_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method)",
|
||||
"protocol": "$(uci_get_by_name $1 protocol)",
|
||||
"protocol_param": "$(uci_get_by_name $1 protocol_param)",
|
||||
"obfs": "$(uci_get_by_name $1 obfs)",
|
||||
"obfs_param": "$(uci_get_by_name $1 obfs_param)",
|
||||
"reuse_port": true,
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
EOF
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp $(uci_get_by_name $1 local_port) > /var/etc/v2-ssr-retcp.json
|
||||
sed -i 's/\\//g' /var/etc/v2-ssr-retcp.json
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER nat $(uci_get_by_name $1 local_port) > /var/etc/trojan-ssr-retcp.json
|
||||
sed -i 's/\\//g' /var/etc/trojan-ssr-retcp.json
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $GLOBAL_SERVER tcp $(uci_get_by_name $1 local_port) > /var/etc/v2-ssr-retcp.json
|
||||
sed -i 's/\\//g' /var/etc/v2-ssr-retcp.json
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER nat $(uci_get_by_name $1 local_port) > /var/etc/trojan-ssr-retcp.json
|
||||
sed -i 's/\\//g' /var/etc/trojan-ssr-retcp.json
|
||||
fi
|
||||
}
|
||||
|
||||
@ -141,23 +140,23 @@ start_rules() {
|
||||
local server=$(uci_get_by_name $GLOBAL_SERVER server)
|
||||
#resolve name
|
||||
if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
server=${server}
|
||||
server=${server}
|
||||
elif [ "$server" != "${server#*:[0-9a-fA-F]}" ] ;then
|
||||
server=${server}
|
||||
server=${server}
|
||||
else
|
||||
server=`ping ${server} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1`
|
||||
if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
echo $server >/etc/ssr_ip
|
||||
else
|
||||
server=`cat /etc/ssr_ip`
|
||||
fi
|
||||
server=`ping ${server} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1`
|
||||
if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
echo $server >/etc/ssr_ip
|
||||
else
|
||||
server=`cat /etc/ssr_ip`
|
||||
fi
|
||||
fi
|
||||
|
||||
kcp_server=$server
|
||||
|
||||
local kcp_enable=$(uci_get_by_name $GLOBAL_SERVER kcp_enable 0)
|
||||
if [ $kcp_enable = "1" ] ;then
|
||||
kcp_flag=1
|
||||
kcp_flag=1
|
||||
fi
|
||||
|
||||
local local_port=$(uci_get_by_name $GLOBAL_SERVER local_port)
|
||||
@ -181,21 +180,21 @@ start_rules() {
|
||||
#deal gfw firewall rule
|
||||
local gfwmode=""
|
||||
if [ "$run_mode" = "gfw" ]; then
|
||||
gfwmode="-g"
|
||||
gfwmode="-g"
|
||||
elif [ "$run_mode" = "router" ]; then
|
||||
gfwmode="-r"
|
||||
gfwmode="-r"
|
||||
elif [ "$run_mode" = "oversea" ]; then
|
||||
gfwmode="-c"
|
||||
gfwmode="-c"
|
||||
elif [ "$run_mode" = "all" ]; then
|
||||
gfwmode="-z"
|
||||
gfwmode="-z"
|
||||
fi
|
||||
|
||||
local dports=$(uci_get_by_type global dports 1)
|
||||
if [ $dports = "1" ] ;then
|
||||
proxyport=" "
|
||||
if [ $dports = "1" ] ;then
|
||||
proxyport=" "
|
||||
else
|
||||
proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443 "
|
||||
fi
|
||||
proxyport="-m multiport --dports 22,53,587,465,995,993,143,80,443 "
|
||||
fi
|
||||
|
||||
/usr/bin/ssr-rules \
|
||||
-s "$server" \
|
||||
@ -222,49 +221,49 @@ start_pdnsd() {
|
||||
[ -z "$usr_dns" ] && usr_dns="8.8.8.8"
|
||||
[ -z "$usr_port" ] && usr_port="53"
|
||||
|
||||
[ -d /var/etc ] || mkdir -p /var/etc
|
||||
[ -d /var/etc ] || mkdir -p /var/etc
|
||||
|
||||
if [ ! -d /var/pdnsd ];then
|
||||
mkdir -p /var/pdnsd
|
||||
echo -ne "pd13\000\000\000\000" >/var/pdnsd/pdnsd.cache
|
||||
chown -R nobody:nogroup /var/pdnsd
|
||||
fi
|
||||
if [ ! -d /var/pdnsd ];then
|
||||
mkdir -p /var/pdnsd
|
||||
echo -ne "pd13\000\000\000\000" >/var/pdnsd/pdnsd.cache
|
||||
chown -R nobody:nogroup /var/pdnsd
|
||||
fi
|
||||
|
||||
cat > /var/etc/pdnsd.conf <<EOF
|
||||
global {
|
||||
perm_cache=1024;
|
||||
cache_dir="/var/pdnsd";
|
||||
pid_file = /var/run/pdnsd.pid;
|
||||
run_as="nobody";
|
||||
server_ip = 127.0.0.1;
|
||||
server_port = 5335;
|
||||
status_ctl = on;
|
||||
query_method = tcp_only;
|
||||
min_ttl=1h;
|
||||
max_ttl=1w;
|
||||
timeout=10;
|
||||
neg_domain_pol=on;
|
||||
proc_limit=2;
|
||||
procq_limit=8;
|
||||
par_queries=1;
|
||||
perm_cache=1024;
|
||||
cache_dir="/var/pdnsd";
|
||||
pid_file = /var/run/pdnsd.pid;
|
||||
run_as="nobody";
|
||||
server_ip = 127.0.0.1;
|
||||
server_port = 5335;
|
||||
status_ctl = on;
|
||||
query_method = tcp_only;
|
||||
min_ttl=1h;
|
||||
max_ttl=1w;
|
||||
timeout=10;
|
||||
neg_domain_pol=on;
|
||||
proc_limit=2;
|
||||
procq_limit=8;
|
||||
par_queries=1;
|
||||
}
|
||||
server {
|
||||
label= "ssr-usrdns";
|
||||
ip = $usr_dns;
|
||||
port = $usr_port;
|
||||
timeout=6;
|
||||
uptest=none;
|
||||
interval=10m;
|
||||
purge_cache=off;
|
||||
label= "ssr-usrdns";
|
||||
ip = $usr_dns;
|
||||
port = $usr_port;
|
||||
timeout=6;
|
||||
uptest=none;
|
||||
interval=10m;
|
||||
purge_cache=off;
|
||||
}
|
||||
server {
|
||||
label= "ssr-pdnsd";
|
||||
ip = $tcp_dns_list;
|
||||
port = 5353;
|
||||
timeout=6;
|
||||
uptest=none;
|
||||
interval=10m;
|
||||
purge_cache=off;
|
||||
label= "ssr-pdnsd";
|
||||
ip = $tcp_dns_list;
|
||||
port = 5353;
|
||||
timeout=6;
|
||||
uptest=none;
|
||||
interval=10m;
|
||||
purge_cache=off;
|
||||
}
|
||||
EOF
|
||||
|
||||
@ -296,93 +295,95 @@ start_redir() {
|
||||
kcp_enable_flag=1
|
||||
fi
|
||||
|
||||
gen_config_file $GLOBAL_SERVER 0
|
||||
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
|
||||
if [ "$stype" == "ss" ] ;then
|
||||
sscmd="/usr/bin/ss-redir"
|
||||
elif [ "$stype" == "ssr" ] ;then
|
||||
sscmd="/usr/bin/ssr-redir"
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
sscmd="/usr/bin/v2ray/v2ray"
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
sscmd="/usr/sbin/trojan"
|
||||
fi
|
||||
gen_config_file $GLOBAL_SERVER 0
|
||||
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
|
||||
if [ "$stype" == "ss" ] ;then
|
||||
sscmd="/usr/bin/ss-redir"
|
||||
elif [ "$stype" == "ssr" ] ;then
|
||||
sscmd="/usr/bin/ssr-redir"
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
sscmd="/usr/bin/v2ray/v2ray"
|
||||
[ ! -f "$sscmd" ] && sscmd="/usr/bin/v2ray"
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
sscmd="/usr/sbin/trojan"
|
||||
fi
|
||||
|
||||
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
|
||||
if [ "$utype" == "ss" ] ;then
|
||||
ucmd="/usr/bin/ss-redir"
|
||||
elif [ "$utype" == "ssr" ] ;then
|
||||
ucmd="/usr/bin/ssr-redir"
|
||||
elif [ "$utype" == "v2ray" ] ;then
|
||||
ucmd="/usr/bin/v2ray/v2ray"
|
||||
elif [ "$utype" == "trojan" ] ;then
|
||||
ucmd="/usr/sbin/trojan"
|
||||
fi
|
||||
if [ "$utype" == "ss" ] ;then
|
||||
ucmd="/usr/bin/ss-redir"
|
||||
elif [ "$utype" == "ssr" ] ;then
|
||||
ucmd="/usr/bin/ssr-redir"
|
||||
elif [ "$utype" == "v2ray" ] ;then
|
||||
ucmd="/usr/bin/v2ray/v2ray"
|
||||
[ ! -f "$ucmd" ] && ucmd="/usr/bin/v2ray"
|
||||
elif [ "$utype" == "trojan" ] ;then
|
||||
ucmd="/usr/sbin/trojan"
|
||||
fi
|
||||
|
||||
if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then
|
||||
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
|
||||
else
|
||||
threads=$(uci_get_by_type global threads)
|
||||
fi
|
||||
if [ "$(uci_get_by_type global threads 0)" = "0" ] ;then
|
||||
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
|
||||
else
|
||||
threads=$(uci_get_by_type global threads)
|
||||
fi
|
||||
|
||||
redir_tcp=1
|
||||
if [ "$stype" == "ss" -o "$stype" == "ssr" ] ;then
|
||||
local last_config_file=$CONFIG_FILE
|
||||
local pid_file="/var/run/ssr-retcp.pid"
|
||||
for i in $(seq 1 $threads)
|
||||
do
|
||||
$sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1
|
||||
done
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >> /tmp/ssrplus.log
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >> /tmp/ssrplus.log
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
$sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 &
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) Started!" >> /tmp/ssrplus.log
|
||||
local last_config_file=$CONFIG_FILE
|
||||
local pid_file="/var/run/ssr-retcp.pid"
|
||||
for i in $(seq 1 $threads)
|
||||
do
|
||||
$sscmd -c $CONFIG_FILE $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1
|
||||
done
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Shadowsocks/ShadowsocksR $threads Threads Started!" >> /tmp/ssrplus.log
|
||||
elif [ "$stype" == "v2ray" ] ;then
|
||||
$sscmd -config /var/etc/v2-ssr-retcp.json >/dev/null 2>&1 &
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) Started!" >> /tmp/ssrplus.log
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
$sscmd --config /var/etc/trojan-ssr-retcp.json >/dev/null 2>&1 &
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd --version 2>&1 | head -1) Started!" >> /tmp/ssrplus.log
|
||||
fi
|
||||
|
||||
if [ -n "$UDP_RELAY_SERVER" ] ;then
|
||||
redir_udp=1
|
||||
if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then
|
||||
case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in
|
||||
1|on|true|yes|enabled) ARG_OTA="-A";;
|
||||
*) ARG_OTA="";;
|
||||
esac
|
||||
gen_config_file $UDP_RELAY_SERVER 1
|
||||
last_config_file=$CONFIG_UDP_FILE
|
||||
pid_file="/var/run/ssr-reudp.pid"
|
||||
$ucmd -c $last_config_file $ARG_OTA -U -f /var/run/ssr-reudp.pid >/dev/null 2>&1
|
||||
elif [ "$utype" == "v2ray" ] ; then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json
|
||||
sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json
|
||||
$ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 &
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER client 10801 > /var/etc/trojan-ssr-reudp.json
|
||||
sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json
|
||||
$ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 &
|
||||
ipt2socks -U -4 -b 0.0.0.0 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
redir_udp=1
|
||||
if [ "$utype" == "ss" -o "$utype" == "ssr" ] ;then
|
||||
case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in
|
||||
1|on|true|yes|enabled) ARG_OTA="-A";;
|
||||
*) ARG_OTA="";;
|
||||
esac
|
||||
gen_config_file $UDP_RELAY_SERVER 1
|
||||
last_config_file=$CONFIG_UDP_FILE
|
||||
pid_file="/var/run/ssr-reudp.pid"
|
||||
$ucmd -c $last_config_file $ARG_OTA -U -f /var/run/ssr-reudp.pid >/dev/null 2>&1
|
||||
elif [ "$utype" == "v2ray" ] ; then
|
||||
lua /usr/share/shadowsocksr/genv2config.lua $UDP_RELAY_SERVER udp $(uci_get_by_name $UDP_RELAY_SERVER local_port) > /var/etc/v2-ssr-reudp.json
|
||||
sed -i 's/\\//g' /var/etc/v2-ssr-reudp.json
|
||||
$ucmd -config /var/etc/v2-ssr-reudp.json >/dev/null 2>&1 &
|
||||
elif [ "$stype" == "trojan" ] ;then
|
||||
lua /usr/share/shadowsocksr/gentrojanconfig.lua $GLOBAL_SERVER client 10801 > /var/etc/trojan-ssr-reudp.json
|
||||
sed -i 's/\\//g' /var/etc/trojan-ssr-reudp.json
|
||||
$ucmd --config /var/etc/trojan-ssr-reudp.json >/dev/null 2>&1 &
|
||||
ipt2socks -U -4 -b 0.0.0.0 -s 127.0.0.1 -p 10801 -l $(uci_get_by_name $UDP_RELAY_SERVER local_port) >/dev/null 2>&1 &
|
||||
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}'`
|
||||
if [ "$run_mode" = "gfw" ]; then
|
||||
ipset add gfwlist $dnsserver 2>/dev/null
|
||||
elif [ "$run_mode" = "oversea" ]; then
|
||||
ipset add oversea $dnsserver 2>/dev/null
|
||||
else
|
||||
ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null
|
||||
fi
|
||||
start_pdnsd $dnsserver $dnsport
|
||||
pdnsd_enable_flag=1
|
||||
fi
|
||||
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}'`
|
||||
if [ "$run_mode" = "gfw" ]; then
|
||||
ipset add gfwlist $dnsserver 2>/dev/null
|
||||
elif [ "$run_mode" = "oversea" ]; then
|
||||
ipset add oversea $dnsserver 2>/dev/null
|
||||
else
|
||||
ipset add ss_spec_wan_ac $dnsserver nomatch 2>/dev/null
|
||||
fi
|
||||
start_pdnsd $dnsserver $dnsport
|
||||
pdnsd_enable_flag=1
|
||||
fi
|
||||
|
||||
if [ "$(uci_get_by_type global enable_switch)" = "1" ] ;then
|
||||
if [ "$(uci_get_by_name $GLOBAL_SERVER switch_enable)" = "1" ] ;then
|
||||
@ -401,23 +402,23 @@ start_redir() {
|
||||
|
||||
gen_service_file() {
|
||||
if [ $(uci_get_by_name $1 fast_open) = "1" ] ;then
|
||||
fastopen="true";
|
||||
fastopen="true";
|
||||
else
|
||||
fastopen="false";
|
||||
fastopen="false";
|
||||
fi
|
||||
cat <<-EOF >$2
|
||||
{
|
||||
"server": "0.0.0.0",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method)",
|
||||
"protocol": "$(uci_get_by_name $1 protocol)",
|
||||
"protocol_param": "$(uci_get_by_name $1 protocol_param)",
|
||||
"obfs": "$(uci_get_by_name $1 obfs)",
|
||||
"obfs_param": "$(uci_get_by_name $1 obfs_param)",
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
{
|
||||
"server": "0.0.0.0",
|
||||
"server_port": $(uci_get_by_name $1 server_port),
|
||||
"password": "$(uci_get_by_name $1 password)",
|
||||
"timeout": $(uci_get_by_name $1 timeout 60),
|
||||
"method": "$(uci_get_by_name $1 encrypt_method)",
|
||||
"protocol": "$(uci_get_by_name $1 protocol)",
|
||||
"protocol_param": "$(uci_get_by_name $1 protocol_param)",
|
||||
"obfs": "$(uci_get_by_name $1 obfs)",
|
||||
"obfs_param": "$(uci_get_by_name $1 obfs_param)",
|
||||
"fast_open": $fastopen
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -425,8 +426,8 @@ start_service() {
|
||||
[ $(uci_get_by_name $1 enable) = "0" ] && return 1
|
||||
let server_count=server_count+1
|
||||
if [ $server_count = 1 ] ;then
|
||||
iptables -N SSR-SERVER-RULE && \
|
||||
iptables -t filter -I INPUT -j SSR-SERVER-RULE
|
||||
iptables -N SSR-SERVER-RULE && \
|
||||
iptables -t filter -I INPUT -j SSR-SERVER-RULE
|
||||
fi
|
||||
|
||||
gen_service_file $1 /var/etc/${NAME}_${server_count}.json
|
||||
@ -439,24 +440,24 @@ gen_serv_include() {
|
||||
FWI=$(uci get firewall.shadowsocksr.path 2>/dev/null)
|
||||
[ -n "$FWI" ] || return 0
|
||||
if [ ! -f $FWI ] ;then
|
||||
echo '#!/bin/sh' >$FWI
|
||||
echo '#!/bin/sh' >$FWI
|
||||
fi
|
||||
extract_rules() {
|
||||
echo "*filter"
|
||||
iptables-save -t filter | grep SSR-SERVER-RULE|sed -e "s/^-A INPUT/-I INPUT/"
|
||||
echo 'COMMIT'
|
||||
}
|
||||
cat <<-EOF >>$FWI
|
||||
iptables-save -c | grep -v "SSR-SERVER" | iptables-restore -c
|
||||
iptables-restore -n <<-EOT
|
||||
$(extract_rules)
|
||||
EOT
|
||||
cat <<-EOF >>$FWI
|
||||
iptables-save -c | grep -v "SSR-SERVER" | iptables-restore -c
|
||||
iptables-restore -n <<-EOT
|
||||
$(extract_rules)
|
||||
EOT
|
||||
EOF
|
||||
|
||||
}
|
||||
start_server() {
|
||||
SERVER_ENABLE=$(uci_get_by_type server_global enable_server)
|
||||
[ "$SERVER_ENABLE" = 0 ] && return 0
|
||||
SERVER_ENABLE=$(uci_get_by_type server_global enable_server)
|
||||
[ "$SERVER_ENABLE" = 0 ] && return 0
|
||||
mkdir -p /var/run /var/etc
|
||||
|
||||
config_load $NAME
|
||||
@ -483,33 +484,36 @@ rules() {
|
||||
UDP_RELAY_SERVER=$(uci_get_by_type global udp_relay_server)
|
||||
[ "$UDP_RELAY_SERVER" = "same" ] && UDP_RELAY_SERVER=$GLOBAL_SERVER
|
||||
if start_rules ;then
|
||||
return 0
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
if [ -z "$switch_server" ] ;then
|
||||
GLOBAL_SERVER=$(uci_get_by_type global global_server)
|
||||
GLOBAL_SERVER=$(uci_get_by_type global global_server)
|
||||
else
|
||||
GLOBAL_SERVER=$switch_server
|
||||
switch_enable=1
|
||||
GLOBAL_SERVER=$switch_server
|
||||
switch_enable=1
|
||||
fi
|
||||
|
||||
if rules ;then
|
||||
start_redir
|
||||
|
||||
mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/
|
||||
mkdir -p /tmp/dnsmasq.d && cp -a /etc/dnsmasq.ssr /tmp/ && cp -a /etc/dnsmasq.oversea /tmp/
|
||||
if ! [ "$run_mode" = "oversea" ] ;then
|
||||
cat > /tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF
|
||||
conf-dir=/tmp/dnsmasq.ssr
|
||||
EOF
|
||||
else
|
||||
else
|
||||
cat > /tmp/dnsmasq.d/dnsmasq-ssr.conf <<EOF
|
||||
conf-dir=/tmp/dnsmasq.oversea
|
||||
EOF
|
||||
fi
|
||||
if [ $(uci_get_by_type global adblock) = 0 ] ;then
|
||||
rm -f /tmp/dnsmasq.ssr/ad.conf
|
||||
fi
|
||||
|
||||
/usr/share/shadowsocksr/gfw2ipset.sh
|
||||
|
||||
@ -520,12 +524,11 @@ EOF
|
||||
start_local
|
||||
|
||||
if [ $(uci_get_by_type global monitor_enable) = 1 ] ;then
|
||||
let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable
|
||||
if [ $total_count -gt 0 ]
|
||||
then
|
||||
#param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw
|
||||
service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable
|
||||
fi
|
||||
let total_count=server_count+redir_tcp+redir_udp+tunnel_enable+kcp_enable_flag+local_enable+pdnsd_enable_flag+switch_enable
|
||||
if [ $total_count -gt 0 ] ;then
|
||||
#param:server(count) redir_tcp(0:no,1:yes) redir_udp tunnel kcp local gfw
|
||||
service_start /usr/bin/ssr-monitor $server_count $redir_tcp $redir_udp $tunnel_enable $kcp_enable_flag $local_enable $pdnsd_enable_flag $switch_enable
|
||||
fi
|
||||
fi
|
||||
|
||||
ENABLE_SERVER=$(uci_get_by_type global global_server)
|
||||
@ -540,15 +543,15 @@ stop() {
|
||||
/usr/bin/ssr-rules -f
|
||||
srulecount=`iptables -L|grep SSR-SERVER-RULE|wc -l`
|
||||
if [ $srulecount -gt 0 ] ;then
|
||||
iptables -F SSR-SERVER-RULE
|
||||
iptables -t filter -D INPUT -j SSR-SERVER-RULE
|
||||
iptables -X SSR-SERVER-RULE 2>/dev/null
|
||||
iptables -F SSR-SERVER-RULE
|
||||
iptables -t filter -D INPUT -j SSR-SERVER-RULE
|
||||
iptables -X SSR-SERVER-RULE 2>/dev/null
|
||||
fi
|
||||
if [ -z "$switch_server" ] ;then
|
||||
kill -9 $(busybox ps -w | grep ssr-switch | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
kill -9 $(busybox ps -w | grep ssr-switch | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
if [ $(uci_get_by_type global monitor_enable) = 1 ] ;then
|
||||
kill -9 $(busybox ps -w | grep ssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
kill -9 $(busybox ps -w | grep ssr-monitor | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
killall -q -9 ssr-monitor
|
||||
killall -q -9 ss-redir
|
||||
@ -560,14 +563,14 @@ stop() {
|
||||
killall -q -9 kcptun-client
|
||||
killall -q -9 ssr-local
|
||||
if [ -f /var/run/pdnsd.pid ] ;then
|
||||
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
|
||||
else
|
||||
kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
|
||||
else
|
||||
kill -9 $(busybox ps -w | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
|
||||
rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
fi
|
||||
del_cron
|
||||
fi
|
||||
del_cron
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ generate_china_banned()
|
||||
|
||||
cat $1 | base64 -d > /tmp/gfwlist.txt
|
||||
rm -f $1
|
||||
sed -i '/^@@|/d' /tmp/gfwlist.txt
|
||||
sed -i '/^@@|/d' /tmp/gfwlist.txt
|
||||
|
||||
cat /tmp/gfwlist.txt | sort -u |
|
||||
sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' |
|
||||
|
@ -46,10 +46,10 @@ sock5_port=$(uci_get_by_type socks5_proxy local_port 1080)
|
||||
if echo $server|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$">/dev/null; then
|
||||
server=${server}
|
||||
else
|
||||
server=`cat /etc/ssr_ip`
|
||||
server=`cat /etc/ssr_ip`
|
||||
fi
|
||||
|
||||
while [ "1" = "1" ] #死循环
|
||||
while [ "1" = "1" ] #死循环
|
||||
do
|
||||
sleep 30
|
||||
#redir tcp
|
||||
@ -57,7 +57,7 @@ do
|
||||
icount=`busybox ps -w | grep ssr-retcp |grep -v grep| wc -l`
|
||||
if [ $icount = 0 ] ;then
|
||||
logger -t "$NAME" "ssr redir tcp error.restart!"
|
||||
/etc/init.d/shadowsocksr restart
|
||||
/etc/init.d/shadowsocksr restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
@ -80,53 +80,53 @@ do
|
||||
fi
|
||||
fi
|
||||
#server
|
||||
if [ $server_process_count -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep ssr-server |grep -v grep| wc -l`
|
||||
if [ $icount -lt $server_process_count ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr server error.restart!"
|
||||
killall -q -9 ssr-server
|
||||
for i in `seq $server_process_count`
|
||||
do
|
||||
/usr/bin/ssr-server -c /var/etc/shadowsocksr_$i.json -u -f /var/run/ssr-server$i.pid
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ $server_process_count -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep ssr-server |grep -v grep| wc -l`
|
||||
if [ $icount -lt $server_process_count ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr server error.restart!"
|
||||
killall -q -9 ssr-server
|
||||
for i in `seq $server_process_count`
|
||||
do
|
||||
/usr/bin/ssr-server -c /var/etc/shadowsocksr_$i.json -u -f /var/run/ssr-server$i.pid
|
||||
done
|
||||
fi
|
||||
fi
|
||||
#kcptun
|
||||
if [ $kcp_process -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep kcptun-client |grep -v grep| wc -l`
|
||||
if [ $icount -lt $kcp_process ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr kcptun error.restart!"
|
||||
killall -q -9 kcptun-client
|
||||
if [ $kcp_process -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep kcptun-client |grep -v grep| wc -l`
|
||||
if [ $icount -lt $kcp_process ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr kcptun error.restart!"
|
||||
killall -q -9 kcptun-client
|
||||
|
||||
( /usr/bin/kcptun-client -r $server:$kcp_port -l :$server_port $password $kcp_param &)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#local
|
||||
if [ $local_process -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep ssr-local |grep -v grep| wc -l`
|
||||
if [ $icount -lt $local_process ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr local error.restart!"
|
||||
killall -q -9 ssr-local
|
||||
if [ $local_process -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep ssr-local |grep -v grep| wc -l`
|
||||
if [ $icount -lt $local_process ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "ssr local error.restart!"
|
||||
killall -q -9 ssr-local
|
||||
|
||||
( /usr/bin/ssr-local -c /var/etc/shadowsocksr_s.json -u -l $sock5_port -f /var/run/ssr-local.pid &)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#pdnsd
|
||||
if [ $pdnsd_process -gt 0 ] ;then
|
||||
icount=`busybox ps -w | grep pdnsd |grep -v grep| wc -l`
|
||||
if [ $icount -lt $pdnsd_process ] #如果进程挂掉就重启它
|
||||
if [ $icount -lt $pdnsd_process ] #如果进程挂掉就重启它
|
||||
then
|
||||
logger -t "$NAME" "pdnsd tunnel error.restart!"
|
||||
if [ -f /var/run/pdnsd.pid ] ;then
|
||||
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
|
||||
else
|
||||
kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
if [ -f /var/run/pdnsd.pid ] ;then
|
||||
kill $(cat /var/run/pdnsd.pid) >/dev/null 2>&1
|
||||
else
|
||||
kill -9 $(ps | grep pdnsd | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
( /usr/sbin/pdnsd -c /var/etc/pdnsd.conf -d &)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@ -13,32 +13,32 @@ FWI=$(uci get firewall.shadowsocksr.path 2>/dev/null) # firewall include file
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
Usage: ssr-rules [options]
|
||||
Usage: ssr-rules [options]
|
||||
|
||||
Valid options are:
|
||||
Valid options are:
|
||||
|
||||
-s <server_ip> ip address of shadowsocksr remote server
|
||||
-l <local_port> port number of shadowsocksr local server
|
||||
-S <server_ip> ip address of shadowsocksr remote UDP server
|
||||
-L <local_port> port number of shadowsocksr local UDP server
|
||||
-i <ip_list_file> a file content is bypassed ip list
|
||||
-a <lan_ips> lan ip of access control, need a prefix to
|
||||
define access control mode
|
||||
-b <wan_ips> wan ip of will be bypassed
|
||||
-w <wan_ips> wan ip of will be forwarded
|
||||
-p <fp_lan_ips> lan ip of will be global proxy
|
||||
-G <gm_lan_ips> lan ip of will be game mode proxy
|
||||
-D <proxy_ports> proxy ports
|
||||
-e <extra_options> extra options for iptables
|
||||
-o apply the rules to the OUTPUT chain
|
||||
-O apply the global rules to the OUTPUT chain
|
||||
-u enable udprelay mode, TPROXY is required
|
||||
-U enable udprelay mode, using different IP
|
||||
and ports for TCP and UDP
|
||||
-f flush the rules
|
||||
-g gfw list mode
|
||||
-r return china mode
|
||||
-h show this help message and exit
|
||||
-s <server_ip> ip address of shadowsocksr remote server
|
||||
-l <local_port> port number of shadowsocksr local server
|
||||
-S <server_ip> ip address of shadowsocksr remote UDP server
|
||||
-L <local_port> port number of shadowsocksr local UDP server
|
||||
-i <ip_list_file> a file content is bypassed ip list
|
||||
-a <lan_ips> lan ip of access control, need a prefix to
|
||||
define access control mode
|
||||
-b <wan_ips> wan ip of will be bypassed
|
||||
-w <wan_ips> wan ip of will be forwarded
|
||||
-p <fp_lan_ips> lan ip of will be global proxy
|
||||
-G <gm_lan_ips> lan ip of will be game mode proxy
|
||||
-D <proxy_ports> proxy ports
|
||||
-e <extra_options> extra options for iptables
|
||||
-o apply the rules to the OUTPUT chain
|
||||
-O apply the global rules to the OUTPUT chain
|
||||
-u enable udprelay mode, TPROXY is required
|
||||
-U enable udprelay mode, using different IP
|
||||
and ports for TCP and UDP
|
||||
-f flush the rules
|
||||
-g gfw list mode
|
||||
-r return china mode
|
||||
-h show this help message and exit
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
@ -76,7 +76,7 @@ flush_r() {
|
||||
ipset_r() {
|
||||
ipset -N gmlan hash:net 2>/dev/null
|
||||
for ip in $LAN_GM_IP; do ipset -! add gmlan $ip ; done
|
||||
|
||||
|
||||
if [ "$RUNMODE" = "router" ] ;then
|
||||
ipset -! -R <<-EOF || return 1
|
||||
create ss_spec_wan_ac hash:net
|
||||
@ -87,15 +87,15 @@ EOF
|
||||
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set ss_spec_wan_ac dst -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "gfw" ] ;then
|
||||
ipset -N gfwlist hash:net 2>/dev/null
|
||||
$IPT -N SS_SPEC_WAN_AC
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set gfwlist dst -j SS_SPEC_WAN_FW
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set gmlan src -m set ! --match-set china dst -j SS_SPEC_WAN_FW
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j RETURN
|
||||
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "oversea" ] ;then
|
||||
ipset -N oversea hash:net 2>/dev/null
|
||||
$IPT -N SS_SPEC_WAN_AC
|
||||
@ -103,18 +103,18 @@ EOF
|
||||
for ip in $LAN_GM_IP; do ipset -! add gmlan $ip ; done
|
||||
$IPT -A SS_SPEC_WAN_AC -m set --match-set china dst -j SS_SPEC_WAN_FW
|
||||
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "all" ] ;then
|
||||
$IPT -N SS_SPEC_WAN_AC
|
||||
$IPT -A SS_SPEC_WAN_AC -j SS_SPEC_WAN_FW
|
||||
$IPT -I SS_SPEC_WAN_AC -d $server -j RETURN
|
||||
|
||||
|
||||
fi
|
||||
|
||||
|
||||
ipset -N fplan hash:net 2>/dev/null
|
||||
for ip in $LAN_FP_IP; do ipset -! add fplan $ip ; done
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set fplan src -j SS_SPEC_WAN_FW
|
||||
|
||||
|
||||
ipset -N whitelist hash:net 2>/dev/null
|
||||
ipset -N blacklist hash:net 2>/dev/null
|
||||
$IPT -I SS_SPEC_WAN_AC -m set --match-set blacklist dst -j SS_SPEC_WAN_FW
|
||||
@ -128,14 +128,14 @@ EOF
|
||||
|
||||
fw_rule() {
|
||||
$IPT -N SS_SPEC_WAN_FW
|
||||
$IPT -A SS_SPEC_WAN_FW -d 0.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 10.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 127.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 169.254.0.0/16 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 172.16.0.0/12 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 192.168.0.0/16 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 224.0.0.0/4 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 240.0.0.0/4 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 0.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 10.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 127.0.0.0/8 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 169.254.0.0/16 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 172.16.0.0/12 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 192.168.0.0/16 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 224.0.0.0/4 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -d 240.0.0.0/4 -j RETURN
|
||||
$IPT -A SS_SPEC_WAN_FW -p tcp $PROXY_PORTS \
|
||||
-j REDIRECT --to-ports $local_port 2>/dev/null || {
|
||||
loger 3 "Can't redirect, please check the iptables."
|
||||
@ -189,43 +189,42 @@ tp_rule() {
|
||||
local ipt="iptables -t mangle"
|
||||
$ipt -N SS_SPEC_TPROXY
|
||||
$ipt -A SS_SPEC_TPROXY -p udp --dport 53 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 0.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 10.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 127.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 169.254.0.0/16 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 172.16.0.0/12 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 192.168.0.0/16 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 224.0.0.0/4 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 240.0.0.0/4 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d $SERVER -j RETURN
|
||||
|
||||
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set fplan src \
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 0.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 10.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 127.0.0.0/8 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 169.254.0.0/16 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 172.16.0.0/12 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 192.168.0.0/16 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 224.0.0.0/4 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d 240.0.0.0/4 -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -d $SERVER -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set fplan src \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
|
||||
|
||||
if [ "$RUNMODE" = "router" ] ;then
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -m set --match-set gmlan src -m set ! --match-set china dst \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set ! --match-set ss_spec_wan_ac dst \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "gfw" ] ;then
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -m set --match-set china dst -j RETURN
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -m set --match-set gmlan src -m set ! --match-set china dst \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
$ipt -A SS_SPEC_TPROXY -p udp -m set $PROXY_PORTS --match-set gfwlist dst \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "oversea" ] ;then
|
||||
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -m set --match-set china dst \
|
||||
-j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
|
||||
|
||||
elif [ "$RUNMODE" = "all" ] ;then
|
||||
$ipt -A SS_SPEC_TPROXY -p udp $PROXY_PORTS -j TPROXY --on-port "$LOCAL_PORT" --tproxy-mark 0x01/0x01
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
$ipt -I PREROUTING 1 ${IFNAME:+-i $IFNAME} -p udp $EXT_ARGS $MATCH_SET \
|
||||
-m comment --comment "$TAG" -j SS_SPEC_TPROXY
|
||||
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
@ -278,7 +277,7 @@ gen_spec_iplist() {
|
||||
224.0.0.0/4
|
||||
240.0.0.0/4
|
||||
255.255.255.255
|
||||
$(get_wan_ip)
|
||||
$(get_wan_ip)
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -331,19 +330,19 @@ while getopts ":s:l:S:L:i:e:a:b:w:p:G:D:oOuUfgrczh" arg; do
|
||||
;;
|
||||
p)
|
||||
LAN_FP_IP=$OPTARG
|
||||
;;
|
||||
;;
|
||||
G)
|
||||
LAN_GM_IP=$OPTARG
|
||||
;;
|
||||
;;
|
||||
D)
|
||||
PROXY_PORTS=$OPTARG
|
||||
;;
|
||||
;;
|
||||
o)
|
||||
OUTPUT=1
|
||||
;;
|
||||
O)
|
||||
OUTPUT=2
|
||||
;;
|
||||
;;
|
||||
u)
|
||||
TPROXY=1
|
||||
;;
|
||||
@ -355,13 +354,13 @@ while getopts ":s:l:S:L:i:e:a:b:w:p:G:D:oOuUfgrczh" arg; do
|
||||
;;
|
||||
r)
|
||||
RUNMODE=router
|
||||
;;
|
||||
;;
|
||||
c)
|
||||
RUNMODE=oversea
|
||||
;;
|
||||
z)
|
||||
RUNMODE=all
|
||||
;;
|
||||
;;
|
||||
f)
|
||||
flush_r
|
||||
exit 0
|
||||
|
@ -35,27 +35,27 @@ CURRENT_SERVER=$DEFAULT_SERVER
|
||||
|
||||
#判断代理是否正常
|
||||
check_proxy() {
|
||||
local result=0
|
||||
local try_count=$(uci_get_by_type global switch_try_count 3)
|
||||
for i in $(seq 1 $try_count)
|
||||
do
|
||||
/usr/bin/ssr-check www.google.com 80 $switch_time 1
|
||||
if [ "$?" == "0" ]; then
|
||||
# echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Success, count=$i" >> /tmp/ssrplus.log
|
||||
result=0
|
||||
break
|
||||
else
|
||||
# echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Fail, count=$i" >> /tmp/ssrplus.log
|
||||
/usr/bin/ssr-check www.baidu.com 80 $switch_time 1
|
||||
if [ "$?" == "0" ]; then
|
||||
result=1
|
||||
else
|
||||
result=2
|
||||
fi
|
||||
fi
|
||||
sleep 1;
|
||||
done
|
||||
return $result;
|
||||
local result=0
|
||||
local try_count=$(uci_get_by_type global switch_try_count 3)
|
||||
for i in $(seq 1 $try_count)
|
||||
do
|
||||
/usr/bin/ssr-check www.google.com 80 $switch_time 1
|
||||
if [ "$?" == "0" ]; then
|
||||
# echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Success, count=$i" >> /tmp/ssrplus.log
|
||||
result=0
|
||||
break
|
||||
else
|
||||
# echo "$(date "+%Y-%m-%d %H:%M:%S") Check Google Proxy Fail, count=$i" >> /tmp/ssrplus.log
|
||||
/usr/bin/ssr-check www.baidu.com 80 $switch_time 1
|
||||
if [ "$?" == "0" ]; then
|
||||
result=1
|
||||
else
|
||||
result=2
|
||||
fi
|
||||
fi
|
||||
sleep 1;
|
||||
done
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -89,8 +89,8 @@ local servername=$(uci_get_by_name $1 server)
|
||||
local serverport=$(uci_get_by_name $1 server_port)
|
||||
ipset add ss_spec_wan_ac $servername 2>/dev/null
|
||||
ret=$?
|
||||
/usr/bin/ssr-check $servername $serverport $switch_time
|
||||
local ret2=$?
|
||||
/usr/bin/ssr-check $servername $serverport $switch_time
|
||||
local ret2=$?
|
||||
if [ "$ret" = "0" ] ;then
|
||||
ipset del ss_spec_wan_ac $servername 2>/dev/null
|
||||
fi
|
||||
@ -126,57 +126,57 @@ start() {
|
||||
|
||||
while [ "1" = "1" ] #死循环
|
||||
do
|
||||
sleep $cycle_time
|
||||
sleep $cycle_time
|
||||
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
#判断当前代理是否为缺省服务器
|
||||
if [ "$CURRENT_SERVER" != "$DEFAULT_SERVER" ] ;then
|
||||
#echo "not default proxy"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Current server is not default Main server, try to switch back." >> /tmp/ssrplus.log
|
||||
#判断当前代理是否为缺省服务器
|
||||
if [ "$CURRENT_SERVER" != "$DEFAULT_SERVER" ] ;then
|
||||
#echo "not default proxy"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Current server is not default Main server, try to switch back." >> /tmp/ssrplus.log
|
||||
|
||||
#检查缺省服务器是否正常
|
||||
if test_proxy $DEFAULT_SERVER ;then
|
||||
#echo "switch to default proxy"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is avilable." >> /tmp/ssrplus.log
|
||||
#缺省服务器正常,切换回来
|
||||
CURRENT_SERVER=$DEFAULT_SERVER
|
||||
switch_proxy $CURRENT_SERVER
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") switch to default ["$(uci_get_by_name $CURRENT_SERVER server)"] proxy!" >> /tmp/ssrplus.log
|
||||
continue
|
||||
else
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is NOT avilable.Continue using current server." >> /tmp/ssrplus.log
|
||||
fi
|
||||
fi
|
||||
#检查缺省服务器是否正常
|
||||
if test_proxy $DEFAULT_SERVER ;then
|
||||
#echo "switch to default proxy"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is avilable." >> /tmp/ssrplus.log
|
||||
#缺省服务器正常,切换回来
|
||||
CURRENT_SERVER=$DEFAULT_SERVER
|
||||
switch_proxy $CURRENT_SERVER
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") switch to default ["$(uci_get_by_name $CURRENT_SERVER server)"] proxy!" >> /tmp/ssrplus.log
|
||||
continue
|
||||
else
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Main server is NOT avilable.Continue using current server." >> /tmp/ssrplus.log
|
||||
fi
|
||||
fi
|
||||
|
||||
#判断当前代理是否正常
|
||||
check_proxy
|
||||
current_ret=$?
|
||||
#判断当前代理是否正常
|
||||
check_proxy
|
||||
current_ret=$?
|
||||
|
||||
if [ "$current_ret" = "1" ] ;then
|
||||
#当前代理错误,判断有无可用的服务器
|
||||
#echo "current error"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Current server error, try to switch another server." >> /tmp/ssrplus.log
|
||||
if [ "$current_ret" = "1" ] ;then
|
||||
#当前代理错误,判断有无可用的服务器
|
||||
#echo "current error"
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Current server error, try to switch another server." >> /tmp/ssrplus.log
|
||||
|
||||
select_proxy
|
||||
if [ "$ENABLE_SERVER" != nil ] ;then
|
||||
#有其他服务器可用,进行切换
|
||||
#echo $(uci_get_by_name $new_proxy server)
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Another server is avilable, now switching server." >> /tmp/ssrplus.log
|
||||
CURRENT_SERVER=$ENABLE_SERVER
|
||||
switch_proxy $CURRENT_SERVER
|
||||
normal_flag=1
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR server switch OK" >> /tmp/ssrplus.log
|
||||
else
|
||||
switch_proxy $CURRENT_SERVER
|
||||
normal_flag=1
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Try restart current server." >> /tmp/ssrplus.log
|
||||
fi
|
||||
else
|
||||
normal_flag=0
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR No Problem." >> /tmp/ssrplus.log
|
||||
fi
|
||||
select_proxy
|
||||
if [ "$ENABLE_SERVER" != nil ] ;then
|
||||
#有其他服务器可用,进行切换
|
||||
#echo $(uci_get_by_name $new_proxy server)
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Another server is avilable, now switching server." >> /tmp/ssrplus.log
|
||||
CURRENT_SERVER=$ENABLE_SERVER
|
||||
switch_proxy $CURRENT_SERVER
|
||||
normal_flag=1
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR server switch OK" >> /tmp/ssrplus.log
|
||||
else
|
||||
switch_proxy $CURRENT_SERVER
|
||||
normal_flag=1
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") Try restart current server." >> /tmp/ssrplus.log
|
||||
fi
|
||||
else
|
||||
normal_flag=0
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S") ShadowsocksR No Problem." >> /tmp/ssrplus.log
|
||||
fi
|
||||
|
||||
|
||||
done
|
||||
|
@ -1,38 +1,38 @@
|
||||
local ucursor = require "luci.model.uci".cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local server_section = arg[1]
|
||||
local proto = arg[2]
|
||||
local proto = arg[2]
|
||||
local local_port = arg[3]
|
||||
|
||||
local server = ucursor:get_all("shadowsocksr", server_section)
|
||||
|
||||
local trojan = {
|
||||
log_level = 3,
|
||||
run_type = proto,
|
||||
local_addr = "0.0.0.0",
|
||||
local_port = tonumber(local_port),
|
||||
remote_addr = server.server,
|
||||
remote_port = tonumber(server.server_port),
|
||||
udp_timeout = 60,
|
||||
-- 传入连接
|
||||
password = {server.password},
|
||||
-- 传出连接
|
||||
ssl = {
|
||||
verify = false,
|
||||
verify_hostname = (server.tls == "1") and false or true,
|
||||
cert = "",
|
||||
ciper = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA",
|
||||
sni = server.tls_host,
|
||||
alpn = {"h2", "http/1.1"},
|
||||
curve = "",
|
||||
reuse_session = true,
|
||||
session_ticket = false,
|
||||
},
|
||||
tcp = {
|
||||
no_delay = true,
|
||||
keep_alive = true,
|
||||
fast_open = (server.fast_open == "1") and true or false,
|
||||
fast_open_qlen = 20
|
||||
}
|
||||
log_level = 3,
|
||||
run_type = proto,
|
||||
local_addr = "0.0.0.0",
|
||||
local_port = tonumber(local_port),
|
||||
remote_addr = server.server,
|
||||
remote_port = tonumber(server.server_port),
|
||||
udp_timeout = 60,
|
||||
-- 传入连接
|
||||
password = {server.password},
|
||||
-- 传出连接
|
||||
ssl = {
|
||||
verify = false,
|
||||
verify_hostname = (server.tls == "1") and false or true,
|
||||
cert = "",
|
||||
ciper = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA",
|
||||
sni = server.tls_host,
|
||||
alpn = {"h2", "http/1.1"},
|
||||
curve = "",
|
||||
reuse_session = true,
|
||||
session_ticket = false,
|
||||
},
|
||||
tcp = {
|
||||
no_delay = true,
|
||||
keep_alive = true,
|
||||
fast_open = (server.fast_open == "1") and true or false,
|
||||
fast_open_qlen = 20
|
||||
}
|
||||
}
|
||||
print(json.stringify(trojan, 1))
|
||||
|
@ -1,95 +1,95 @@
|
||||
local ucursor = require "luci.model.uci".cursor()
|
||||
local json = require "luci.jsonc"
|
||||
local server_section = arg[1]
|
||||
local proto = arg[2]
|
||||
local proto = arg[2]
|
||||
local local_port = arg[3]
|
||||
|
||||
local server = ucursor:get_all("shadowsocksr", server_section)
|
||||
|
||||
local v2ray = {
|
||||
log = {
|
||||
-- error = "/var/ssrplus.log",
|
||||
loglevel = "warning"
|
||||
},
|
||||
-- 传入连接
|
||||
inbound = {
|
||||
port = local_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {
|
||||
network = proto,
|
||||
followRedirect = true
|
||||
},
|
||||
sniffing = {
|
||||
enabled = true,
|
||||
destOverride = { "http", "tls" }
|
||||
}
|
||||
},
|
||||
-- 传出连接
|
||||
outbound = {
|
||||
protocol = "vmess",
|
||||
settings = {
|
||||
vnext = {
|
||||
{
|
||||
address = server.server,
|
||||
port = tonumber(server.server_port),
|
||||
users = {
|
||||
{
|
||||
id = server.vmess_id,
|
||||
alterId = tonumber(server.alter_id),
|
||||
security = server.security
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- 底层传输配置
|
||||
streamSettings = {
|
||||
network = server.transport,
|
||||
security = (server.tls == '1') and "tls" or "none",
|
||||
tlsSettings = {allowInsecure = (server.insecure == "1") and true or false,serverName=server.ws_host,},
|
||||
kcpSettings = (server.transport == "kcp") and {
|
||||
mtu = tonumber(server.mtu),
|
||||
tti = tonumber(server.tti),
|
||||
uplinkCapacity = tonumber(server.uplink_capacity),
|
||||
downlinkCapacity = tonumber(server.downlink_capacity),
|
||||
congestion = (server.congestion == "1") and true or false,
|
||||
readBufferSize = tonumber(server.read_buffer_size),
|
||||
writeBufferSize = tonumber(server.write_buffer_size),
|
||||
header = {
|
||||
type = server.kcp_guise
|
||||
}
|
||||
} or nil,
|
||||
wsSettings = (server.transport == "ws") and (server.ws_path ~= nil or server.ws_host ~= nil) and {
|
||||
path = server.ws_path,
|
||||
headers = (server.ws_host ~= nil) and {
|
||||
Host = server.ws_host
|
||||
} or nil,
|
||||
} or nil,
|
||||
httpSettings = (server.transport == "h2") and {
|
||||
path = server.h2_path,
|
||||
host = server.h2_host,
|
||||
} or nil,
|
||||
quicSettings = (server.transport == "quic") and {
|
||||
security = server.quic_security,
|
||||
key = server.quic_key,
|
||||
header = {
|
||||
type = server.quic_guise
|
||||
}
|
||||
} or nil
|
||||
},
|
||||
mux = {
|
||||
enabled = (server.mux == "1") and true or false,
|
||||
concurrency = tonumber(server.concurrency)
|
||||
}
|
||||
},
|
||||
log = {
|
||||
-- error = "/var/ssrplus.log",
|
||||
loglevel = "warning"
|
||||
},
|
||||
-- 传入连接
|
||||
inbound = {
|
||||
port = local_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {
|
||||
network = proto,
|
||||
followRedirect = true
|
||||
},
|
||||
sniffing = {
|
||||
enabled = true,
|
||||
destOverride = { "http", "tls" }
|
||||
}
|
||||
},
|
||||
-- 传出连接
|
||||
outbound = {
|
||||
protocol = "vmess",
|
||||
settings = {
|
||||
vnext = {
|
||||
{
|
||||
address = server.server,
|
||||
port = tonumber(server.server_port),
|
||||
users = {
|
||||
{
|
||||
id = server.vmess_id,
|
||||
alterId = tonumber(server.alter_id),
|
||||
security = server.security
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- 底层传输配置
|
||||
streamSettings = {
|
||||
network = server.transport,
|
||||
security = (server.tls == '1') and "tls" or "none",
|
||||
tlsSettings = {allowInsecure = (server.insecure == "1") and true or false,serverName=server.tls_host,},
|
||||
kcpSettings = (server.transport == "kcp") and {
|
||||
mtu = tonumber(server.mtu),
|
||||
tti = tonumber(server.tti),
|
||||
uplinkCapacity = tonumber(server.uplink_capacity),
|
||||
downlinkCapacity = tonumber(server.downlink_capacity),
|
||||
congestion = (server.congestion == "1") and true or false,
|
||||
readBufferSize = tonumber(server.read_buffer_size),
|
||||
writeBufferSize = tonumber(server.write_buffer_size),
|
||||
header = {
|
||||
type = server.kcp_guise
|
||||
}
|
||||
} or nil,
|
||||
wsSettings = (server.transport == "ws") and (server.ws_path ~= nil or server.ws_host ~= nil) and {
|
||||
path = server.ws_path,
|
||||
headers = (server.ws_host ~= nil) and {
|
||||
Host = server.ws_host
|
||||
} or nil,
|
||||
} or nil,
|
||||
httpSettings = (server.transport == "h2") and {
|
||||
path = server.h2_path,
|
||||
host = server.h2_host,
|
||||
} or nil,
|
||||
quicSettings = (server.transport == "quic") and {
|
||||
security = server.quic_security,
|
||||
key = server.quic_key,
|
||||
header = {
|
||||
type = server.quic_guise
|
||||
}
|
||||
} or nil
|
||||
},
|
||||
mux = {
|
||||
enabled = (server.mux == "1") and true or false,
|
||||
concurrency = tonumber(server.concurrency)
|
||||
}
|
||||
},
|
||||
|
||||
-- 额外传出连接
|
||||
outboundDetour = {
|
||||
{
|
||||
protocol = "freedom",
|
||||
tag = "direct",
|
||||
settings = { keep = "" }
|
||||
}
|
||||
}
|
||||
-- 额外传出连接
|
||||
outboundDetour = {
|
||||
{
|
||||
protocol = "freedom",
|
||||
tag = "direct",
|
||||
settings = { keep = "" }
|
||||
}
|
||||
}
|
||||
}
|
||||
print(json.stringify(v2ray, 1))
|
||||
|
594
package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua
Executable file → Normal file
594
package/lean/luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua
Executable file → Normal file
@ -11,8 +11,7 @@ require 'luci.sys'
|
||||
-- these global functions are accessed all the time by the event handler
|
||||
-- so caching them is worth the effort
|
||||
local tinsert = table.insert
|
||||
local ssub, slen, schar, srep, sbyte, sformat, sgsub =
|
||||
string.sub, string.len, string.char, string.rep, string.byte, string.format, string.gsub
|
||||
local ssub, slen, schar, srep, sbyte, sformat, sgsub = string.sub, string.len, string.char, string.rep, string.byte, string.format, string.gsub
|
||||
local cache = {}
|
||||
local nodeResult = setmetatable({}, { __index = cache }) -- update result
|
||||
local name = 'shadowsocksr'
|
||||
@ -22,36 +21,36 @@ local proxy = ucic:get_first(name, 'server_subscribe', 'proxy', '0')
|
||||
local subscribe_url = ucic:get_first(name, 'server_subscribe', 'subscribe_url', {})
|
||||
|
||||
local log = function(...)
|
||||
print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " "))
|
||||
print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " "))
|
||||
end
|
||||
-- 分割字符串
|
||||
local function split(full, sep)
|
||||
full = full:gsub("%z", "") -- 这里不是很清楚 有时候结尾带个\0
|
||||
local off, result = 1, {}
|
||||
while true do
|
||||
local nEnd = full:find(sep, off)
|
||||
if not nEnd then
|
||||
local res = ssub(full, off, slen(full))
|
||||
if #res > 0 then -- 过滤掉 \0
|
||||
tinsert(result, res)
|
||||
end
|
||||
break
|
||||
else
|
||||
tinsert(result, ssub(full, off, nEnd - 1))
|
||||
off = nEnd + slen(sep)
|
||||
end
|
||||
end
|
||||
return result
|
||||
full = full:gsub("%z", "") -- 这里不是很清楚 有时候结尾带个\0
|
||||
local off, result = 1, {}
|
||||
while true do
|
||||
local nEnd = full:find(sep, off)
|
||||
if not nEnd then
|
||||
local res = ssub(full, off, slen(full))
|
||||
if #res > 0 then -- 过滤掉 \0
|
||||
tinsert(result, res)
|
||||
end
|
||||
break
|
||||
else
|
||||
tinsert(result, ssub(full, off, nEnd - 1))
|
||||
off = nEnd + slen(sep)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
-- urlencode
|
||||
local function get_urlencode(c)
|
||||
return sformat("%%%02X", sbyte(c))
|
||||
return sformat("%%%02X", sbyte(c))
|
||||
end
|
||||
|
||||
local function urlEncode(szText)
|
||||
local str = szText:gsub("([^0-9a-zA-Z ])", get_urlencode)
|
||||
str = str:gsub(" ", "+")
|
||||
return str
|
||||
local str = szText:gsub("([^0-9a-zA-Z ])", get_urlencode)
|
||||
str = str:gsub(" ", "+")
|
||||
return str
|
||||
end
|
||||
|
||||
local function get_urldecode(h)
|
||||
@ -63,287 +62,308 @@ end
|
||||
|
||||
-- trim
|
||||
local function trim(text)
|
||||
if not text or text == "" then
|
||||
return ""
|
||||
end
|
||||
return (sgsub(text, "^%s*(.-)%s*$", "%1"))
|
||||
if not text or text == "" then
|
||||
return ""
|
||||
end
|
||||
return (sgsub(text, "^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
-- md5
|
||||
local function md5(content)
|
||||
local stdout = luci.sys.exec('echo \"' .. urlEncode(content) .. '\" | md5sum | cut -d \" \" -f1')
|
||||
-- assert(nixio.errno() == 0)
|
||||
return trim(stdout)
|
||||
local stdout = luci.sys.exec('echo \"' .. urlEncode(content) .. '\" | md5sum | cut -d \" \" -f1')
|
||||
-- assert(nixio.errno() == 0)
|
||||
return trim(stdout)
|
||||
end
|
||||
-- base64
|
||||
local function base64Decode(text, safe)
|
||||
local raw = text
|
||||
if not text then return '' end
|
||||
text = text:gsub("%z", "")
|
||||
if safe then
|
||||
text = text:gsub("_", "/")
|
||||
text = text:gsub("-", "+")
|
||||
local mod4 = #text % 4
|
||||
text = text .. string.sub('====', mod4 + 1)
|
||||
end
|
||||
local result = nixio.bin.b64decode(text)
|
||||
if result then
|
||||
return result:gsub("%z", "")
|
||||
else
|
||||
return raw
|
||||
end
|
||||
local raw = text
|
||||
if not text then return '' end
|
||||
text = text:gsub("%z", "")
|
||||
if safe then
|
||||
text = text:gsub("_", "/")
|
||||
text = text:gsub("-", "+")
|
||||
local mod4 = #text % 4
|
||||
text = text .. string.sub('====', mod4 + 1)
|
||||
end
|
||||
local result = nixio.bin.b64decode(text)
|
||||
if result then
|
||||
return result:gsub("%z", "")
|
||||
else
|
||||
return raw
|
||||
end
|
||||
end
|
||||
-- 处理数据
|
||||
local function processData(szType, content)
|
||||
local result = {
|
||||
auth_enable = '0',
|
||||
switch_enable = '1',
|
||||
type = szType,
|
||||
local_port = 1234,
|
||||
timeout = 60, -- 不太确定 好像是死的
|
||||
fast_open = 0,
|
||||
kcp_enable = 0,
|
||||
kcp_port = 0,
|
||||
kcp_param = '--nocomp'
|
||||
}
|
||||
local hash
|
||||
if type(content) == 'string' then
|
||||
hash = md5(content)
|
||||
else
|
||||
hash = md5(luci.jsonc.stringify(content))
|
||||
end
|
||||
result.hashkey = hash
|
||||
-- 如果节点内容为空,返回无效的节点信息
|
||||
if content == '' then
|
||||
result.server = ''
|
||||
return result, hash
|
||||
end
|
||||
if szType == 'ssr' then
|
||||
local dat = split(content, "/\\?")
|
||||
local hostInfo = split(dat[1], ':')
|
||||
result.server = hostInfo[1]
|
||||
result.server_port = hostInfo[2]
|
||||
result.protocol = hostInfo[3]
|
||||
result.encrypt_method = hostInfo[4]
|
||||
result.obfs = hostInfo[5]
|
||||
result.password = base64Decode(hostInfo[6], true)
|
||||
local params = {}
|
||||
for k, v in pairs(split(dat[2], '&')) do
|
||||
local t = split(v, '=')
|
||||
params[t[1]] = t[2]
|
||||
end
|
||||
result.obfs_param = base64Decode(params.bfsparam, true)
|
||||
result.protocol_param = base64Decode(params.protoparam, true)
|
||||
local group = base64Decode(params.group, true)
|
||||
if group then
|
||||
result.alias = "[" .. group .. "] "
|
||||
end
|
||||
result.alias = result.alias .. base64Decode(params.remarks, true)
|
||||
elseif szType == 'vmess' then
|
||||
local info = luci.jsonc.parse(content)
|
||||
result.type = 'v2ray'
|
||||
result.server = info.add
|
||||
result.server_port = info.port
|
||||
result.tcp_guise = "none"
|
||||
result.transport = info.net
|
||||
result.alter_id = info.aid
|
||||
result.vmess_id = info.id
|
||||
result.alias = info.ps
|
||||
result.ws_host = info.host
|
||||
result.ws_path = info.path
|
||||
result.h2_host = info.host
|
||||
result.h2_path = info.path
|
||||
if not info.security then
|
||||
result.security = "auto"
|
||||
end
|
||||
if info.tls == "tls" or info.tls == "1" then
|
||||
result.tls = "1"
|
||||
else
|
||||
result.tls = "0"
|
||||
end
|
||||
elseif szType == "ss" then
|
||||
local idx_sp = 0
|
||||
local alias = ""
|
||||
if content:find("#") then
|
||||
idx_sp = content:find("#")
|
||||
alias = content:sub(idx_sp + 1, -1)
|
||||
end
|
||||
local info = content:sub(1, idx_sp - 1)
|
||||
local hostInfo = split(base64Decode(info, true), "@")
|
||||
local host = split(hostInfo[2], ":")
|
||||
local userinfo = base64Decode(hostInfo[1], true)
|
||||
local method = userinfo:sub(1, userinfo:find(":") - 1)
|
||||
local password = userinfo:sub(userinfo:find(":") + 1, #userinfo)
|
||||
result.alias = UrlDecode(alias)
|
||||
result.type = "ss"
|
||||
result.server = host[1]
|
||||
if host[2]:find("/\\?") then
|
||||
local query = split(host[2], "/\\?")
|
||||
result.server_port = query[1]
|
||||
-- local params = {}
|
||||
-- for k, v in pairs(split(query[2], '&')) do
|
||||
-- local t = split(v, '=')
|
||||
-- params[t[1]] = t[2]
|
||||
-- end
|
||||
-- 这里似乎没什么用 我看数据结构没有写插件的支持 先抛弃
|
||||
else
|
||||
result.server_port = host[2]
|
||||
end
|
||||
result.encrypt_method_ss = method
|
||||
result.password = password
|
||||
elseif szType == "ssd" then
|
||||
result.type = "ss"
|
||||
result.server = content.server
|
||||
result.server_port = content.port
|
||||
result.password = content.password
|
||||
result.encrypt_method_ss = content.encryption
|
||||
result.alias = "[" .. content.airport .. "] " .. content.remarks
|
||||
end
|
||||
return result, hash
|
||||
local result = {
|
||||
auth_enable = '0',
|
||||
switch_enable = '1',
|
||||
type = szType,
|
||||
local_port = 1234,
|
||||
timeout = 60, -- 不太确定 好像是死的
|
||||
fast_open = 0,
|
||||
kcp_enable = 0,
|
||||
kcp_port = 0,
|
||||
kcp_param = '--nocomp'
|
||||
}
|
||||
local hash
|
||||
if type(content) == 'string' then
|
||||
hash = md5(content)
|
||||
else
|
||||
hash = md5(luci.jsonc.stringify(content))
|
||||
end
|
||||
result.hashkey = hash
|
||||
if szType == 'ssr' then
|
||||
local dat = split(content, "/\\?")
|
||||
local hostInfo = split(dat[1], ':')
|
||||
result.server = hostInfo[1]
|
||||
result.server_port = hostInfo[2]
|
||||
result.protocol = hostInfo[3]
|
||||
result.encrypt_method = hostInfo[4]
|
||||
result.obfs = hostInfo[5]
|
||||
result.password = base64Decode(hostInfo[6], true)
|
||||
local params = {}
|
||||
for k, v in pairs(split(dat[2], '&')) do
|
||||
local t = split(v, '=')
|
||||
params[t[1]] = t[2]
|
||||
end
|
||||
result.obfs_param = base64Decode(params.bfsparam, true)
|
||||
result.protocol_param = base64Decode(params.protoparam, true)
|
||||
local group = base64Decode(params.group, true)
|
||||
if group then
|
||||
result.alias = "[" .. group .. "] "
|
||||
end
|
||||
result.alias = result.alias .. base64Decode(params.remarks, true)
|
||||
elseif szType == 'vmess' then
|
||||
local info = luci.jsonc.parse(content)
|
||||
result.type = 'v2ray'
|
||||
result.server = info.add
|
||||
result.server_port = info.port
|
||||
result.transport = info.net
|
||||
result.alter_id = info.aid
|
||||
result.vmess_id = info.id
|
||||
result.alias = info.ps
|
||||
result.mux = 1
|
||||
result.concurrency = 8
|
||||
if info.net == 'ws'then
|
||||
result.ws_host = info.host
|
||||
result.ws_path = info.path
|
||||
end
|
||||
if info.net == 'h2'then
|
||||
result.h2_host = info.host
|
||||
result.h2_path = info.path
|
||||
end
|
||||
if info.net == 'tcp'then
|
||||
result.tcp_guise = info.type
|
||||
result.http_host = info.host
|
||||
result.http_path = info.path
|
||||
end
|
||||
if info.net == 'kcp'then
|
||||
result.kcp_guise = info.type
|
||||
result.mtu = 1350
|
||||
result.tti = 50
|
||||
result.uplink_capacity = 5
|
||||
result.downlink_capacity = 20
|
||||
result.read_buffer_size = 2
|
||||
result.write_buffer_size = 2
|
||||
end
|
||||
if info.net == 'quic'then
|
||||
result.quic_guise = info.type
|
||||
result.quic_key = info.key
|
||||
result.quic_security = info.securty
|
||||
end
|
||||
if not info.security then
|
||||
result.security = "auto"
|
||||
end
|
||||
if info.tls == "tls" or info.tls == "1" then
|
||||
result.tls = "1"
|
||||
result.tls_host = info.host
|
||||
else
|
||||
result.tls = "0"
|
||||
end
|
||||
elseif szType == "ss" then
|
||||
local idx_sp = 0
|
||||
local alias = ""
|
||||
if content:find("#") then
|
||||
idx_sp = content:find("#")
|
||||
alias = content:sub(idx_sp + 1, -1)
|
||||
end
|
||||
local info = content:sub(1, idx_sp - 1)
|
||||
local hostInfo = split(base64Decode(info, true), "@")
|
||||
local host = split(hostInfo[2], ":")
|
||||
local userinfo = base64Decode(hostInfo[1], true)
|
||||
local method = userinfo:sub(1, userinfo:find(":") - 1)
|
||||
local password = userinfo:sub(userinfo:find(":") + 1, #userinfo)
|
||||
result.alias = UrlDecode(alias)
|
||||
result.type = "ss"
|
||||
result.server = host[1]
|
||||
if host[2]:find("/\\?") then
|
||||
local query = split(host[2], "/\\?")
|
||||
result.server_port = query[1]
|
||||
-- local params = {}
|
||||
-- for k, v in pairs(split(query[2], '&')) do
|
||||
-- local t = split(v, '=')
|
||||
-- params[t[1]] = t[2]
|
||||
-- end
|
||||
-- 这里似乎没什么用 我看数据结构没有写插件的支持 先抛弃
|
||||
else
|
||||
result.server_port = host[2]
|
||||
end
|
||||
result.encrypt_method_ss = method
|
||||
result.password = password
|
||||
elseif szType == "ssd" then
|
||||
result.type = "ss"
|
||||
result.server = content.server
|
||||
result.server_port = content.port
|
||||
result.password = content.password
|
||||
result.encrypt_method_ss = content.encryption
|
||||
result.alias = "[" .. content.airport .. "] " .. content.remarks
|
||||
end
|
||||
if result.alias == ''then result.alias = result.server ..':'.. result.server_port end
|
||||
return result, hash
|
||||
end
|
||||
-- wget
|
||||
local function wget(url)
|
||||
local stdout = luci.sys.exec('wget-ssl --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" --no-check-certificate -t 3 -T 10 -O- "' .. url .. '"')
|
||||
return trim(stdout)
|
||||
local stdout = luci.sys.exec('wget-ssl --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" --no-check-certificate -t 3 -T 10 -O- "' .. url .. '"')
|
||||
return trim(stdout)
|
||||
end
|
||||
|
||||
local execute = function()
|
||||
-- exec
|
||||
do
|
||||
-- subscribe_url = {'https://www.google.comc'}
|
||||
if proxy == '0' then -- 不使用代理更新的话先暂停
|
||||
log('服务正在暂停')
|
||||
luci.sys.init.stop(name)
|
||||
end
|
||||
for k, url in ipairs(subscribe_url) do
|
||||
local raw = wget(url)
|
||||
if #raw > 0 then
|
||||
local node, szType
|
||||
local groupHash = md5(url)
|
||||
cache[groupHash] = {}
|
||||
tinsert(nodeResult, {})
|
||||
local index = #nodeResult
|
||||
-- SSD 似乎是这种格式 ssd:// 开头的
|
||||
if raw:find('ssd://') then
|
||||
szType = 'ssd'
|
||||
local nEnd = select(2, raw:find('ssd://'))
|
||||
node = base64Decode(raw:sub(nEnd + 1, #raw), true)
|
||||
node = luci.jsonc.parse(node)
|
||||
local extra = {
|
||||
airport = node.airport,
|
||||
port = node.port,
|
||||
encryption = node.encryption,
|
||||
password = node.password
|
||||
}
|
||||
local servers = {}
|
||||
-- SS里面包着 干脆直接这样
|
||||
for _, server in ipairs(node.servers) do
|
||||
tinsert(servers, setmetatable(server, { __index = extra }))
|
||||
end
|
||||
node = servers
|
||||
else
|
||||
-- ssd 外的格式
|
||||
node = split(base64Decode(raw, true):gsub(" ", "\n"), "\n")
|
||||
end
|
||||
for _, v in ipairs(node) do
|
||||
if v then
|
||||
v = trim(v)
|
||||
local result, hash
|
||||
if szType == 'ssd' then
|
||||
result, hash = processData(szType, v)
|
||||
elseif not szType then
|
||||
local dat = split(v, "://")
|
||||
if dat and dat[1] and dat[2] then
|
||||
if dat[1] == 'ss' then
|
||||
result, hash = processData(dat[1], dat[2])
|
||||
else
|
||||
result, hash = processData(dat[1], base64Decode(dat[2], true))
|
||||
end
|
||||
end
|
||||
else
|
||||
log('跳过未知类型: ' .. szType)
|
||||
end
|
||||
-- log(hash, result)
|
||||
if hash and result then
|
||||
if result.alias:find("过期时间") or
|
||||
result.alias:find("剩余流量") or
|
||||
result.alias:find("QQ群") or
|
||||
result.alias:find("官网") or
|
||||
result.server == ''
|
||||
then
|
||||
log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias)
|
||||
else
|
||||
log('成功解析: ' .. result.type ..' 节点, ' .. result.alias)
|
||||
result.grouphashkey = groupHash
|
||||
tinsert(nodeResult[index], result)
|
||||
cache[groupHash][hash] = nodeResult[index][#nodeResult[index]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
log('成功解析节点数量: ' ..#node)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- diff
|
||||
do
|
||||
assert(next(nodeResult), "node result is empty")
|
||||
local add, del = 0, 0
|
||||
ucic:foreach(name, uciType, function(old)
|
||||
if old.grouphashkey or old.hashkey then -- 没有 hash 的不参与删除
|
||||
if not nodeResult[old.grouphashkey] or not nodeResult[old.grouphashkey][old.hashkey] then
|
||||
ucic:delete(name, old['.name'])
|
||||
del = del + 1
|
||||
else
|
||||
local dat = nodeResult[old.grouphashkey][old.hashkey]
|
||||
ucic:tset(name, old['.name'], dat)
|
||||
-- 标记一下
|
||||
setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } })
|
||||
end
|
||||
else
|
||||
log('忽略手动添加的节点: ' .. old.alias)
|
||||
end
|
||||
end)
|
||||
for k, v in ipairs(nodeResult) do
|
||||
for kk, vv in ipairs(v) do
|
||||
if not vv._ignore then
|
||||
local section = ucic:add(name, uciType)
|
||||
ucic:tset(name, section, vv)
|
||||
add = add + 1
|
||||
end
|
||||
-- exec
|
||||
do
|
||||
-- subscribe_url = {'https://www.google.comc'}
|
||||
if proxy == '0' then -- 不使用代理更新的话先暂停
|
||||
log('服务正在暂停')
|
||||
luci.sys.init.stop(name)
|
||||
end
|
||||
for k, url in ipairs(subscribe_url) do
|
||||
local raw = wget(url)
|
||||
if #raw > 0 then
|
||||
local node, szType
|
||||
local groupHash = md5(url)
|
||||
cache[groupHash] = {}
|
||||
tinsert(nodeResult, {})
|
||||
local index = #nodeResult
|
||||
-- SSD 似乎是这种格式 ssd:// 开头的
|
||||
if raw:find('ssd://') then
|
||||
szType = 'ssd'
|
||||
local nEnd = select(2, raw:find('ssd://'))
|
||||
node = base64Decode(raw:sub(nEnd + 1, #raw), true)
|
||||
node = luci.jsonc.parse(node)
|
||||
local extra = {
|
||||
airport = node.airport,
|
||||
port = node.port,
|
||||
encryption = node.encryption,
|
||||
password = node.password
|
||||
}
|
||||
local servers = {}
|
||||
-- SS里面包着 干脆直接这样
|
||||
for _, server in ipairs(node.servers) do
|
||||
tinsert(servers, setmetatable(server, { __index = extra }))
|
||||
end
|
||||
node = servers
|
||||
else
|
||||
-- ssd 外的格式
|
||||
node = split(base64Decode(raw, true):gsub(" ", "\n"), "\n")
|
||||
end
|
||||
for _, v in ipairs(node) do
|
||||
if v then
|
||||
v = trim(v)
|
||||
local result, hash
|
||||
if szType == 'ssd' then
|
||||
result, hash = processData(szType, v)
|
||||
elseif not szType then
|
||||
local dat = split(v, "://")
|
||||
if dat and dat[1] and dat[2] then
|
||||
if dat[1] == 'ss' then
|
||||
result, hash = processData(dat[1], dat[2])
|
||||
else
|
||||
result, hash = processData(dat[1], base64Decode(dat[2], true))
|
||||
end
|
||||
end
|
||||
else
|
||||
log('跳过未知类型: ' .. szType)
|
||||
end
|
||||
-- log(hash, result)
|
||||
if hash or result then
|
||||
if result.alias:find("过期时间") or
|
||||
result.alias:find("剩余流量") or
|
||||
result.alias:find("QQ群") or
|
||||
result.alias:find("官网") or
|
||||
result.server == ''
|
||||
then
|
||||
log('丢弃无效节点: ' .. result.type ..' 节点, ' .. result.alias)
|
||||
else
|
||||
log('成功解析: ' .. result.type ..' 节点, ' .. result.alias)
|
||||
result.grouphashkey = groupHash
|
||||
tinsert(nodeResult[index], result)
|
||||
cache[groupHash][hash] = nodeResult[index][#nodeResult[index]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
log('成功解析节点数量: ' ..#node)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- diff
|
||||
do
|
||||
assert(next(nodeResult), "node result is empty")
|
||||
local add, del = 0, 0
|
||||
ucic:foreach(name, uciType, function(old)
|
||||
if old.grouphashkey or old.hashkey then -- 没有 hash 的不参与删除
|
||||
if not nodeResult[old.grouphashkey] or not nodeResult[old.grouphashkey][old.hashkey] then
|
||||
ucic:delete(name, old['.name'])
|
||||
del = del + 1
|
||||
else
|
||||
local dat = nodeResult[old.grouphashkey][old.hashkey]
|
||||
ucic:tset(name, old['.name'], dat)
|
||||
-- 标记一下
|
||||
setmetatable(nodeResult[old.grouphashkey][old.hashkey], { __index = { _ignore = true } })
|
||||
end
|
||||
else
|
||||
log('忽略手动添加的节点: ' .. old.alias)
|
||||
end
|
||||
end)
|
||||
for k, v in ipairs(nodeResult) do
|
||||
for kk, vv in ipairs(v) do
|
||||
if not vv._ignore then
|
||||
local section = ucic:add(name, uciType)
|
||||
ucic:tset(name, section, vv)
|
||||
add = add + 1
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
ucic:commit(name)
|
||||
-- 如果服务器已经不见了把帮换一个
|
||||
local globalServer = ucic:get_first(name, 'global', 'global_server', '')
|
||||
local firstServer = ucic:get_first(name, uciType)
|
||||
if not ucic:get(name, globalServer) then
|
||||
if firstServer then
|
||||
ucic:set(name, ucic:get_first(name, 'global'), 'global_server', firstServer)
|
||||
ucic:commit(name)
|
||||
log('当前主服务器已更新,正在自动更换。')
|
||||
end
|
||||
end
|
||||
if firstServer then
|
||||
luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
else
|
||||
luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
end
|
||||
log('新增节点数量: ' ..add, '删除节点数量: ' .. del)
|
||||
log('更新成功服务正在启动')
|
||||
end
|
||||
end
|
||||
end
|
||||
ucic:commit(name)
|
||||
-- 如果服务器已经不见了把帮换一个
|
||||
local globalServer = ucic:get_first(name, 'global', 'global_server', '')
|
||||
local firstServer = ucic:get_first(name, uciType)
|
||||
if not ucic:get(name, globalServer) then
|
||||
if firstServer then
|
||||
ucic:set(name, ucic:get_first(name, 'global'), 'global_server', firstServer)
|
||||
ucic:commit(name)
|
||||
log('当前主服务器已更新,正在自动更换。')
|
||||
end
|
||||
end
|
||||
if firstServer then
|
||||
luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
else
|
||||
luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
end
|
||||
log('新增节点数量: ' ..add, '删除节点数量: ' .. del)
|
||||
log('更新成功服务正在启动')
|
||||
end
|
||||
end
|
||||
|
||||
if subscribe_url and #subscribe_url > 0 then
|
||||
xpcall(execute, function(e)
|
||||
log(e)
|
||||
log(debug.traceback())
|
||||
log('发生错误, 正在恢复服务')
|
||||
local firstServer = ucic:get_first(name, uciType)
|
||||
if firstServer then
|
||||
luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
else
|
||||
luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
end
|
||||
end)
|
||||
xpcall(execute, function(e)
|
||||
log(e)
|
||||
log(debug.traceback())
|
||||
log('发生错误, 正在恢复服务')
|
||||
local firstServer = ucic:get_first(name, uciType)
|
||||
if firstServer then
|
||||
luci.sys.call("/etc/init.d/" .. name .." restart > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
else
|
||||
luci.sys.call("/etc/init.d/" .. name .." stop > /dev/null 2>&1 &") -- 不加&的话日志会出现的更早
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/lua
|
||||
------------------------------------------------
|
||||
-- This file is part of the luci-app-ssr-plus update.lua
|
||||
-- By Mattraks
|
||||
------------------------------------------------
|
||||
require 'nixio'
|
||||
require 'luci.util'
|
||||
require 'luci.jsonc'
|
||||
require 'luci.sys'
|
||||
local icount =0
|
||||
local ucic = luci.model.uci.cursor()
|
||||
|
||||
local log = function(...)
|
||||
print(os.date("%Y-%m-%d %H:%M:%S ") .. table.concat({ ... }, " "))
|
||||
end
|
||||
|
||||
log('正在更新【GFW列表】数据库')
|
||||
if nixio.fs.access("/usr/bin/wget-ssl") then
|
||||
refresh_cmd="wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64"
|
||||
else
|
||||
refresh_cmd="wget -O /tmp/gfw.b64 http://iytc.net/tools/list.b64"
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
luci.sys.call("/usr/bin/ssr-gfw")
|
||||
icount = luci.sys.exec("cat /tmp/gfwnew.txt | wc -l")
|
||||
if tonumber(icount)>1000 then
|
||||
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l")
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf")
|
||||
-- retstring=tostring(math.ceil(tonumber(icount)/2))
|
||||
log('更新成功! 新的总纪录数:'.. icount)
|
||||
else
|
||||
log('你已经是最新数据,无需更新!')
|
||||
end
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/gfwnew.txt")
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
|
||||
log('正在更新【国内IP段】数据库')
|
||||
refresh_cmd="wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' 2>/dev/null| awk -F\\| '/CN\\|ipv4/ { printf(\"%s/%d\\n\", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt"
|
||||
sret=luci.sys.call(refresh_cmd)
|
||||
icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
|
||||
if sret== 0 then
|
||||
icount = luci.sys.exec("cat /tmp/china_ssr.txt | wc -l")
|
||||
if tonumber(icount)>1000 then
|
||||
oldcount=luci.sys.exec("cat /etc/china_ssr.txt | wc -l")
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/china_ssr.txt /etc/china_ssr.txt")
|
||||
-- retstring=tostring(math.ceil(tonumber(icount)/2))
|
||||
log('更新成功! 新的总纪录数:'.. icount)
|
||||
else
|
||||
log('你已经是最新数据,无需更新!')
|
||||
end
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/china_ssr.txt")
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
|
||||
-- --[[
|
||||
if ucic:get_first('shadowsocksr', 'global', 'adblock', '') == '1' then
|
||||
log('正在更新【广告屏蔽】数据库')
|
||||
local need_process = 0
|
||||
if nixio.fs.access("/usr/bin/wget-ssl") then
|
||||
refresh_cmd="wget-ssl --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt > /tmp/adnew.conf"
|
||||
need_process = 1
|
||||
else
|
||||
refresh_cmd="wget -O /tmp/ad.conf http://iytc.net/tools/ad.conf"
|
||||
end
|
||||
sret=luci.sys.call(refresh_cmd .. " 2>/dev/null")
|
||||
if sret== 0 then
|
||||
if need_process == 1 then
|
||||
luci.sys.call("/usr/bin/ssr-ad")
|
||||
end
|
||||
icount = luci.sys.exec("cat /tmp/ad.conf | wc -l")
|
||||
if tonumber(icount)>1000 then
|
||||
if nixio.fs.access("/etc/dnsmasq.ssr/ad.conf") then
|
||||
oldcount=luci.sys.exec("cat /etc/dnsmasq.ssr/ad.conf | wc -l")
|
||||
else
|
||||
oldcount=0
|
||||
end
|
||||
if tonumber(icount) ~= tonumber(oldcount) then
|
||||
luci.sys.exec("cp -f /tmp/ad.conf /etc/dnsmasq.ssr/ad.conf")
|
||||
-- retstring=tostring(math.ceil(tonumber(icount)))
|
||||
if oldcount==0 then
|
||||
luci.sys.call("/etc/init.d/dnsmasq restart")
|
||||
end
|
||||
log('更新成功! 新的总纪录数:'.. icount)
|
||||
else
|
||||
log('你已经是最新数据,无需更新!')
|
||||
end
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
luci.sys.exec("rm -f /tmp/ad.conf")
|
||||
else
|
||||
log('更新失败!')
|
||||
end
|
||||
end
|
||||
-- --]]
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
chnroute_data=$(wget -O- -t 3 -T 3 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest)
|
||||
[ $? -eq 0 ] && {
|
||||
echo "$chnroute_data" | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/china_ssr.txt
|
||||
}
|
||||
|
||||
if [ -s "/tmp/china_ssr.txt" ];then
|
||||
if ( ! cmp -s /tmp/china_ssr.txt /etc/china_ssr.txt );then
|
||||
mv /tmp/china_ssr.txt /etc/china_ssr.txt
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/share/shadowsocksr/chinaipset.sh
|
||||
|
||||
wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O /tmp/gfw.b64
|
||||
/usr/bin/ssr-gfw
|
||||
|
||||
if [ -s "/tmp/gfwnew.txt" ];then
|
||||
if ( ! cmp -s /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf );then
|
||||
mv /tmp/gfwnew.txt /etc/dnsmasq.ssr/gfw_list.conf
|
||||
echo "copy"
|
||||
fi
|
||||
fi
|
||||
|
||||
/etc/init.d/shadowsocksr restart
|
149
package/lean/v2ray-core/Config.in
Normal file
149
package/lean/v2ray-core/Config.in
Normal file
@ -0,0 +1,149 @@
|
||||
menu "V2Ray Configuration"
|
||||
depends on PACKAGE_v2ray-core
|
||||
|
||||
choice
|
||||
prompt "JSON Config Support"
|
||||
default V2RAY_JSON_INTERNAL
|
||||
|
||||
config V2RAY_JSON_V2CTL
|
||||
bool "Load JSON from V2Ctl"
|
||||
|
||||
config V2RAY_JSON_INTERNAL
|
||||
bool "Load JSON Internally"
|
||||
|
||||
config V2RAY_JSON_NONE
|
||||
bool "None"
|
||||
|
||||
endchoice
|
||||
|
||||
config V2RAY_EXCLUDE_V2CTL
|
||||
bool "Exclude V2Ctl"
|
||||
depends on V2RAY_JSON_INTERNAL || V2RAY_JSON_NONE
|
||||
default y
|
||||
|
||||
config V2RAY_EXCLUDE_ASSETS
|
||||
bool "Exclude geoip.dat & geosite.dat"
|
||||
default y
|
||||
|
||||
config V2RAY_COMPRESS_UPX
|
||||
bool "Compress executable files with UPX"
|
||||
default y
|
||||
|
||||
choice
|
||||
prompt "Disable Features"
|
||||
default V2RAY_DISABLE_NONE
|
||||
|
||||
config V2RAY_DISABLE_NONE
|
||||
bool "None"
|
||||
|
||||
config V2RAY_DISABLE_CUSTOM
|
||||
bool "Custom"
|
||||
|
||||
endchoice
|
||||
|
||||
config V2RAY_DISABLE_DNS
|
||||
bool "Disable Internal DNS Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_LOG
|
||||
bool "Disable Log Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_POLICY
|
||||
bool "Disable Local Policy Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_REVERSE
|
||||
bool "Disable Reverse Proxy Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_ROUTING
|
||||
bool "Disable Internal Routing Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_STATISTICS
|
||||
bool "Disable Statistics Support"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_BLACKHOLE_PROTO
|
||||
bool "Disable Blackhole Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_DNS_PROXY
|
||||
bool "Disable DNS Proxy"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_DOKODEMO_PROTO
|
||||
bool "Disable Dokodemo-door Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_FREEDOM_PROTO
|
||||
bool "Disable Freedom Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_MTPROTO_PROXY
|
||||
bool "Disable MTProto Proxy"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_HTTP_PROTO
|
||||
bool "Disable HTTP Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_SHADOWSOCKS_PROTO
|
||||
bool "Disable Shadowsocks Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_SOCKS_PROTO
|
||||
bool "Disable Socks Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_VMESS_PROTO
|
||||
bool "Disable VMess Protocol"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_TCP_TRANS
|
||||
bool "Disable TCP Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_MKCP_TRANS
|
||||
bool "Disable mKCP Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_WEBSOCKET_TRANS
|
||||
bool "Disable WebSocket Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_HTTP2_TRANS
|
||||
bool "Disable HTTP/2 Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_DOMAIN_SOCKET_TRANS
|
||||
bool "Disable Domain Socket Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
config V2RAY_DISABLE_QUIC_TRANS
|
||||
bool "Disable QUIC Transport"
|
||||
depends on V2RAY_DISABLE_CUSTOM
|
||||
default n
|
||||
|
||||
endmenu
|
304
package/lean/v2ray-core/Makefile
Normal file
304
package/lean/v2ray-core/Makefile
Normal file
@ -0,0 +1,304 @@
|
||||
#
|
||||
# Copyright (C) 2019-2020 Xingwang Liao
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=v2ray-core
|
||||
PKG_VERSION:=4.22.1
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/v2ray/v2ray-core/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=31c1934eeac3552c7ab68eac9dc3e964e05f3c743b3733b0b6a0159c495019d6
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Xingwang Liao <kuoruan@gmail.com>
|
||||
|
||||
PKG_CONFIG_DEPENDS := \
|
||||
CONFIG_V2RAY_JSON_V2CTL \
|
||||
CONFIG_V2RAY_JSON_INTERNAL \
|
||||
CONFIG_V2RAY_JSON_NONE \
|
||||
CONFIG_V2RAY_EXCLUDE_V2CTL \
|
||||
CONFIG_V2RAY_EXCLUDE_ASSETS \
|
||||
CONFIG_V2RAY_COMPRESS_UPX \
|
||||
CONFIG_V2RAY_DISABLE_NONE \
|
||||
CONFIG_V2RAY_DISABLE_CUSTOM \
|
||||
CONFIG_V2RAY_DISABLE_DNS \
|
||||
CONFIG_V2RAY_DISABLE_LOG \
|
||||
CONFIG_V2RAY_DISABLE_POLICY \
|
||||
CONFIG_V2RAY_DISABLE_REVERSE \
|
||||
CONFIG_V2RAY_DISABLE_ROUTING \
|
||||
CONFIG_V2RAY_DISABLE_STATISTICS \
|
||||
CONFIG_V2RAY_DISABLE_BLACKHOLE_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_DNS_PROXY \
|
||||
CONFIG_V2RAY_DISABLE_DOKODEMO_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_FREEDOM_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_MTPROTO_PROXY \
|
||||
CONFIG_V2RAY_DISABLE_HTTP_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_SHADOWSOCKS_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_SOCKS_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_VMESS_PROTO \
|
||||
CONFIG_V2RAY_DISABLE_TCP_TRANS \
|
||||
CONFIG_V2RAY_DISABLE_MKCP_TRANS \
|
||||
CONFIG_V2RAY_DISABLE_WEBSOCKET_TRANS \
|
||||
CONFIG_V2RAY_DISABLE_HTTP2_TRANS \
|
||||
CONFIG_V2RAY_DISABLE_DOMAIN_SOCKET_TRANS \
|
||||
CONFIG_V2RAY_DISABLE_QUIC_TRANS
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
export GO111MODULE=on
|
||||
export GOPROXY=https://goproxy.cn
|
||||
|
||||
GO_PKG:=v2ray.com/core
|
||||
GO_PKG_LDFLAGS:=-s -w
|
||||
GO_PKG_LDFLAGS_X:= \
|
||||
v2ray.com/core.version=$(PKG_VERSION) \
|
||||
v2ray.com/core.build=R$(PKG_RELEASE) \
|
||||
v2ray.com/core.codename=OpenWrt
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/v2ray-core
|
||||
TITLE:=A platform for building proxies
|
||||
URL:=https://www.v2ray.com
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Project V
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-certificates
|
||||
endef
|
||||
|
||||
define Package/v2ray-core/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/v2ray-core/description
|
||||
Project V is a set of network tools that help you to build your own computer network.
|
||||
It secures your network connections and thus protects your privacy.
|
||||
|
||||
This package contains v2ray, v2ctl and v2ray-assets.
|
||||
endef
|
||||
|
||||
V2RAY_SED_ARGS:=
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_JSON_INTERNAL),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/main\/json"/\/\/ &/; \
|
||||
/\/\/ _ "v2ray.com\/core\/main\/jsonem"/s/\/\/ //;
|
||||
else ifeq ($(CONFIG_V2RAY_JSON_NONE),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/main\/json"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_CUSTOM),y)
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_DNS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/dns"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_LOG),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/log"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/app\/log\/command"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_POLICY),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/policy"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_REVERSE),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/reverse"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_ROUTING),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/router"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_STATISTICS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/app\/stats"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/app\/stats\/command"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_BLACKHOLE_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/blackhole"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_DNS_PROXY),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/dns"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_DOKODEMO_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/dokodemo"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_FREEDOM_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/freedom"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_MTPROTO_PROXY),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/mtproto"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_HTTP_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/http"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_SHADOWSOCKS_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/shadowsocks"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_SOCKS_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/socks"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_VMESS_PROTO),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/proxy\/vmess\/inbound"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/proxy\/vmess\/outbound"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_TCP_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/tcp"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_MKCP_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/kcp"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_WEBSOCKET_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/websocket"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_HTTP2_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/http"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/http"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_DOMAIN_SOCKET_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/domainsocket"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_QUIC_TRANS),y)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/quic"/\/\/ &/;
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_DISABLE_MKCP_TRANS)$(CONFIG_V2RAY_DISABLE_QUIC_TRANS),yy)
|
||||
V2RAY_SED_ARGS += \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/noop"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/srtp"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/tls"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/utp"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/wechat"/\/\/ &/; \
|
||||
s/_ "v2ray.com\/core\/transport\/internet\/headers\/wireguard"/\/\/ &/;
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
GEOIP_VER:=latest
|
||||
GEOIP_FILE:=geoip-$(GEOIP_VER).dat
|
||||
|
||||
define Download/geoip.dat
|
||||
URL:=https://github.com/v2ray/geoip/releases/$(GEOIP_VER)/download
|
||||
URL_FILE:=geoip.dat
|
||||
FILE:=$(GEOIP_FILE)
|
||||
HASH:=skip
|
||||
endef
|
||||
|
||||
GEOSITE_VER:=latest
|
||||
GEOSITE_FILE:=geosite-$(GEOSITE_VER).dat
|
||||
|
||||
define Download/geosite.dat
|
||||
URL:=https://github.com/v2ray/domain-list-community/releases/$(GEOSITE_VER)/download
|
||||
URL_FILE:=dlc.dat
|
||||
FILE:=$(GEOSITE_FILE)
|
||||
HASH:=skip
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y)
|
||||
# move file to make sure download new file every build
|
||||
mv -f $(DL_DIR)/$(GEOIP_FILE) $(PKG_BUILD_DIR)/release/config/geoip.dat
|
||||
mv -f $(DL_DIR)/$(GEOSITE_FILE) $(PKG_BUILD_DIR)/release/config/geosite.dat
|
||||
endif
|
||||
|
||||
ifneq ($(V2RAY_SED_ARGS),)
|
||||
( \
|
||||
sed -i \
|
||||
'$(V2RAY_SED_ARGS)' \
|
||||
$(PKG_BUILD_DIR)/main/distro/all/all.go ; \
|
||||
)
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(eval GO_PKG_BUILD_PKG:=v2ray.com/core/main)
|
||||
$(call GoPackage/Build/Compile)
|
||||
mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ray
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_COMPRESS_UPX),y)
|
||||
upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ray
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_V2RAY_EXCLUDE_V2CTL),y)
|
||||
$(eval GO_PKG_BUILD_PKG:=v2ray.com/core/infra/control/main)
|
||||
$(call GoPackage/Build/Compile)
|
||||
mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ctl
|
||||
|
||||
ifeq ($(CONFIG_V2RAY_COMPRESS_UPX),y)
|
||||
upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ctl
|
||||
endif
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/v2ray-core/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ray $(1)/usr/bin
|
||||
|
||||
ifneq ($(CONFIG_V2RAY_EXCLUDE_V2CTL),y)
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ctl $(1)/usr/bin
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y)
|
||||
$(INSTALL_DATA) \
|
||||
$(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \
|
||||
$(1)/usr/bin
|
||||
endif
|
||||
endef
|
||||
|
||||
ifneq ($(CONFIG_V2RAY_EXCLUDE_ASSETS),y)
|
||||
$(eval $(call Download,geoip.dat))
|
||||
$(eval $(call Download,geosite.dat))
|
||||
endif
|
||||
|
||||
$(eval $(call GoBinPackage,v2ray-core))
|
||||
$(eval $(call BuildPackage,v2ray-core))
|
Loading…
Reference in New Issue
Block a user