增加trojan 支持 和 广告屏蔽功能

New features

- NEW: 增加了Trojan支持
- NEW: 增加了广告屏蔽的功能

Updates

- UPD: 更新了gfwlist chinaip 和 ad conf的更新代码。
- UPD: 当在节点列表应用新的节点时,会先中断所有的ping,以保证切换节点优先。
This commit is contained in:
jerrykuku 2020-02-10 22:46:26 +08:00
parent 3399c4fd14
commit e82abc5c2d
17 changed files with 531 additions and 173 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-vssr
PKG_VERSION:=1.04
PKG_RELEASE:=20200209-1
PKG_VERSION:=1.05
PKG_RELEASE:=20200210-1
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server \
@ -15,7 +15,11 @@ define Package/$(PKG_NAME)/config
config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray
bool "Include V2ray"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_Trojan
bool "Include Trojan"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server
bool "Include ShadowsocksR Server"
default n
@ -29,10 +33,12 @@ define Package/luci-app-vssr
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=A New SS/SSR/V2Ray LuCI interface
TITLE:=A New SS/SSR/V2Ray/Trojan LuCI interface
PKGARCH:=all
DEPENDS:=+shadowsocksr-libev-alt +ipset +ip-full +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64 +bash +pdnsd-alt +wget +luasocket +jshn +lua-cjson +coreutils-nohup +python3-maxminddb +curl \
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:trojan \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan:ipt2socks \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Socks:shadowsocksr-libev-ssr-local
endef

View File

@ -12,12 +12,19 @@ a new SSR SS V2ray luci app bese luci-app-ssr-plus
稳定性的差异来自于你固件的内核还有ss ssr v2ray 这几个核心插件的稳定性,当然你的节点才是影响稳定性的最大因素。
Luci 能决定的只有操作起来是否便利、顺手,还有对几个核心应用功能的适配挖掘而已。
### Update Log 2020-02-09
### Update Log 2020-02-10
1. 增加了V2ray简易分流模式现在当你在使用v2ray作为主节点的时候可以选择为几个主流的视频插件指定特定的节点来达到分流的目的。目前可以分流的视频有Youtube 一些台湾的视频平台 Netflix Diseny+ Prime Video
1. 修改了订阅代码。
1. 修复一些节点列表的显示问题。
1. 更新了GeoIp2 库 并增加了 Licence。
#### New features
- NEW: 增加了Trojan支持
- NEW: 增加了广告屏蔽的功能
#### Updates
- UPD: 更新了gfwlist chinaip 和 ad conf的更新代码。
- UPD: 当在节点列表应用新的节点时会先中断所有的ping以保证切换节点优先。
详情见[具体日志](./relnotes.txt)。
### Intro
@ -26,7 +33,7 @@ Luci 能决定的只有操作起来是否便利、顺手,还有对几个核心
1. 优化了在节点列表页面点击应用后节点切换的速度。同时也优化了自动切换的速度。
1. 将节点订阅转移至 高级设置 请悉知 由于需要获取ip的国家code 新的订阅速度可能会比原来慢一点点 x86无影响。
1. 去掉了ss插件ss节点将通过v2ray进行代理支持ss的v2ray plugin可能会遇到老的加密方式不兼容的情况。
1. 给Hello World 增加了IP状态显示在页面底部 左边显示当前节点国旗 ip 和中文国家 右边 是四个网站的访问状态 可以访问是彩色 不能访问是灰色。
1. 给Hello World 增加了IP状态显示在页面底部 左边显示当前节点国旗 ip 和中文国家 右边 是四个网站的访问状态 可以访问是彩色不能访问是灰色。
1. 优化了国旗匹配方法在部分带有emoji counrty code的节点名称中 优先使用 emoji code 匹配国旗。
1. 建议搭配argon theme能有最好的显示体验。

View File

@ -40,9 +40,9 @@ function index()
entry({"admin", "services", "vssr", "log"}, cbi("vssr/log"), _("Log"), 30).leaf =
true
entry({"admin", "services", "vssr", "licence"}, template("vssr/licence"), _("Licence"), 40).leaf =
true
entry({"admin", "services", "vssr", "licence"}, template("vssr/licence"),
_("Licence"), 40).leaf = true
entry({"admin", "services", "vssr", "refresh"}, call("refresh_data")) -- 更新白名单和GFWLIST
entry({"admin", "services", "vssr", "checkport"}, call("check_port")) -- 检测单个端口并返回Ping
entry({"admin", "services", "vssr", "run"}, call("act_status")) -- 检测全局服务器状态
@ -174,7 +174,7 @@ function refresh_data()
if set == "gfw_data" then
if nixio.fs.access("/usr/bin/wget-ssl") then
refresh_cmd =
"wget-ssl --no-check-certificate https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt -O /tmp/gfw.b64"
"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
@ -201,7 +201,7 @@ function refresh_data()
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'
"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
@ -217,14 +217,19 @@ function refresh_data()
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 --no-check-certificate -O - https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt | grep ^\\|\\|[^\\*]*\\^$ | sed -e 's:||:address\\=\\/:' -e 's:\\^:/127\\.0\\.0\\.1:' > /tmp/ad.conf"
"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/vssr-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
@ -233,7 +238,6 @@ function refresh_data()
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)))
@ -246,7 +250,7 @@ function refresh_data()
else
retstring = "-1"
end
luci.sys.exec("rm -f /tmp/ad.conf ")
luci.sys.exec("rm -f /tmp/ad.conf")
else
retstring = "-1"
end
@ -316,13 +320,9 @@ function check_ip()
http.TIMEOUT = 1
result = luci.sys.exec("curl -s https://api.ip.sb/ip")
if JudgeIPString(result) then
local cmd = '/usr/share/vssr/getip.sh ' .. result
e.outboard = result
e.outboardip = luci.sys.exec(cmd)
else
e.outboard = false
end
local cmd = '/usr/share/vssr/getip.sh ' .. result
e.outboard = result
e.outboardip = luci.sys.exec(cmd)
-- 检测国内通道
e.baidu = false

View File

@ -2,48 +2,51 @@ local vssr = "vssr"
local uci = luci.model.uci.cursor()
local server_table = {}
local gfwmode=0
local gfw_count=0
local ip_count=0
local gfwmode = 0
local gfw_count = 0
local ip_count = 0
local ad_count = 0
if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then
gfwmode=1
end
if nixio.fs.access("/etc/dnsmasq.ssr/gfw_list.conf") then gfwmode = 1 end
local sys = require "luci.sys"
if gfwmode==1 then
gfw_count = tonumber(sys.exec("cat /etc/dnsmasq.ssr/gfw_list.conf | wc -l"))/2
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 nixio.fs.access("/etc/china_ssr.txt") then
ip_count = sys.exec("cat /etc/china_ssr.txt | wc -l")
end
uci:foreach(vssr, "servers", function(s)
if s["type"] == "v2ray" then
if s.alias then
server_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias}
elseif s.server and s.server_port then
server_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port}
end
end
if s["type"] == "v2ray" then
if s.alias then
server_table[s[".name"]] = "[%s]:%s" %
{string.upper(s.type), s.alias}
elseif s.server and s.server_port then
server_table[s[".name"]] = "[%s]:%s:%s" %
{
string.upper(s.type), s.server, s.server_port
}
end
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)
m = Map(vssr)
-- [[ 服务器节点故障自动切换设置 ]]--
s = m:section(TypedSection, "global", translate("Server failsafe auto swith settings"))
s = m:section(TypedSection, "global",
translate("Server failsafe auto swith settings"))
s.anonymous = true
o = s:option(Flag, "monitor_enable", translate("Enable Process Deamon"))
@ -64,19 +67,19 @@ o.default = 5
-- [[ 节点订阅 ]]--
s = m:section(TypedSection, "server_subscribe", translate("Servers subscription and manage"))
s = m:section(TypedSection, "server_subscribe",
translate("Servers subscription and manage"))
s.anonymous = true
o = s:option(Flag, "auto_update", translate("Auto Update"))
o.rmempty = false
o.description = translate("Auto Update Server subscription, GFW list and CHN route")
o.description = translate(
"Auto Update Server subscription, GFW list and CHN route")
o = s:option(ListValue, "auto_update_time", translate("Update time (every day)"))
for t = 0,23 do
o:value(t, t..":00")
end
o.default=2
o =
s:option(ListValue, "auto_update_time", translate("Update time (every day)"))
for t = 0, 23 do o:value(t, t .. ":00") end
o.default = 2
o.rmempty = false
o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL"))
@ -86,34 +89,47 @@ o = s:option(Flag, "proxy", translate("Through proxy update"))
o.rmempty = false
o.description = translate("Through proxy update list, Not Recommended ")
o = s:option(DummyValue, "", "")
o.rawhtml = true
o.template = "vssr/update_subscribe"
o = s:option(Button,"delete",translate("Delete all severs"))
o = s:option(Button, "delete", translate("Delete all severs"))
o.inputstyle = "reset"
o.write = function()
uci:delete_all("vssr", "servers", function(s) return true end)
uci:commit("vssr")
uci:commit("vssr")
luci.sys.call("/etc/init.d/vssr stop")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "vssr", "servers"))
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "vssr",
"servers"))
end
-- [[ adblock ]]--
s = m:section(TypedSection, "global", translate("adblock settings"))
s.anonymous = true
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false
-- [[ 更新设置 ]]--
s = m:section(TypedSection,"socks5_proxy",translate("Update Setting"))
s = m:section(TypedSection, "socks5_proxy", translate("Update Setting"))
s.anonymous = true
o = s:option(Button,"gfw_data",translate("GFW List Data"))
o.rawhtml = true
o = s:option(Button, "gfw_data", translate("GFW List Data"))
o.rawhtml = true
o.template = "vssr/refresh"
o.value =tostring(math.ceil(gfw_count)) .. " " .. translate("Records")
o.value = tostring(math.ceil(gfw_count)) .. " " .. translate("Records")
o = s:option(Button,"ip_data",translate("China IP Data"))
o.rawhtml = true
o = s:option(Button, "ip_data", translate("China IP Data"))
o.rawhtml = true
o.template = "vssr/refresh"
o.value =ip_count .. " " .. translate("Records")
o.value = ip_count .. " " .. translate("Records")
if uci:get_first('vssr', 'global', 'adblock', '') == '1' then
o = s:option(Button, "ad_data", translate("Advertising Data"))
o.rawhtml = true
o.template = "vssr/refresh"
o.value = ad_count .. " " .. translate("Records")
end
return m

View File

@ -67,18 +67,22 @@ o.value = sid
o = s:option(ListValue, "type", translate("Server Node Type"))
o:value("ssr", translate("ShadowsocksR"))
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("ss", translate("Shadowsocks New Version"))
o:value("v2ray", translate("V2Ray"))
end
if nixio.fs.access("/usr/sbin/trojan") then
o:value("trojan", translate("Trojan"))
end
o.description = translate(
"Using incorrect encryption mothod may causes service fail to start")
o = s:option(Value, "alias", translate("Alias(optional)"))
o = s:option(Value, "flag", translate("Country"))
o.description = translate(
"请自己指定。格式cn us hk 等")
o.description = translate("请自己指定。格式cn us hk 等")
o.rmempty = true
o = s:option(Value, "server", translate("Server Address"))
@ -99,6 +103,7 @@ o.password = true
o.rmempty = true
o:depends("type", "ssr")
o:depends("type", "ss")
o:depends("type", "trojan")
o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
for _, v in ipairs(encrypt_methods) do o:value(v) end
@ -297,12 +302,14 @@ o.rmempty = true
o = s:option(Flag, "insecure", translate("allowInsecure"))
o.rmempty = true
o:depends("type", "v2ray")
o:depends("type", "trojan")
-- [[ TLS ]]--
o = s:option(Flag, "tls", translate("TLS"))
o.rmempty = true
o.default = "0"
o:depends("type", "v2ray")
o:depends("type", "trojan")
-- [[ Mux ]]--
o = s:option(Flag, "mux", translate("Mux"))
@ -321,6 +328,7 @@ o.rmempty = true
o.default = "0"
o:depends("type", "ssr")
o:depends("type", "ss")
o:depends("type", "trojan")
o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
o.rmempty = false

View File

@ -2,34 +2,29 @@
<script type="text/javascript">//<![CDATA[
function refresh_data(btn,dataname)
{
function refresh_data(btn, dataname) {
btn.disabled = true;
btn.value = '<%:Refresh...%> ';
murl=dataname;
btn.value = '<%:Refresh...%> ';
murl = dataname;
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "vssr","refresh")%>',
{ set:murl },
function(x,rv)
{
var s = document.getElementById(dataname+'-status');
if (s)
{
if (rv.ret=="0")
s.innerHTML ="<font color='green'>"+"<%:No new data!%> "+"</font>";
else if(rv.ret=="-1")
{
s.innerHTML ="<font color='red'>"+"<%:Refresh Error!%> "+"</font>";
}
else
{
s.innerHTML ="<font color='green'>"+"<%:Refresh OK!%> "+"<%:Total Records:%>"+rv.ret+"</font>";
}
{ set: murl },
function (x, rv) {
var s = document.getElementById(dataname + '-status');
if (s) {
if (rv.ret == "0")
s.innerHTML = "<font color='green'>" + "<%:No new data!%> " + "</font>";
else if (rv.ret == "-1") {
s.innerHTML = "<font color='red'>" + "<%:Refresh Error!%> " + "</font>";
}
else {
s.innerHTML = "<font color='green'>" + "<%:Refresh OK!%> " + "<%:Total Records:%>" + rv.ret + "</font>";
}
}
}
btn.disabled = false;
btn.value = '<%:Refresh Data %>';
btn.value = '<%:Refresh Data %>';
}
);
@ -38,7 +33,8 @@
//]]></script>
<input type="button" class="cbi-button cbi-input-reload" value="<%:Refresh Data%> " onclick="return refresh_data(this,'<%=self.option%>')" />
<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%>

View File

@ -2,7 +2,7 @@
<script type="text/javascript">//<![CDATA[
function getFlag(remark,hosts, sid) {
function getFlag(remark, hosts, sid) {
$.get('<%=luci.dispatcher.build_url("admin", "services", "vssr","flag")%>',
{
host: hosts,
@ -116,10 +116,11 @@
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
var rema = "";
if (ssu[0] == "ssr") {
var sstr = b64decsafe(ssu[1]);
var ploc = sstr.indexOf("/?");
var rema = "";
document.getElementById('cbid.vssr.' + sid + '.type').value = "ssr";
document.getElementById('cbid.vssr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
@ -146,12 +147,12 @@
document.getElementById('cbid.vssr.' + sid + '.password').value = b64decsafe(ssm[6]);
document.getElementById('cbid.vssr.' + sid + '.obfs_param').value = dictvalue(pdict, 'obfsparam');
document.getElementById('cbid.vssr.' + sid + '.protocol_param').value = dictvalue(pdict, 'protoparam');
var rem = pdict['remarks'];
if (typeof (rem) != 'undefined' && rem != '' && rem.length > 0)
rema = b64decutf8safe(rem);
document.getElementById('cbid.vssr.' + sid + '.alias').value = b64decutf8safe(rem);
getFlag(rema,ssm[1], sid);
document.getElementById('cbid.vssr.' + sid + '.alias').value = b64decutf8safe(rem);
getFlag(rema, ssm[1], sid); //get flag iso code
s.innerHTML = "<font color='green'><%:Import%>ShadowsocksR<%:Configuration Succeeded%></font>";
return false;
} else if (ssu[0] == "ss") {
@ -163,7 +164,7 @@
url0 = ssu[1]
}
var sstr = b64decsafe(url0);
var rema = "";
document.getElementById('cbid.vssr.' + sid + '.type').value = "ss";
@ -176,18 +177,43 @@
document.getElementById('cbid.vssr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.vssr.' + sid + '.password').value = part1[1];
document.getElementById('cbid.vssr.' + sid + '.encrypt_method_ss').value = part1[0];
if (param != undefined) {
rema = decodeURI(param)
document.getElementById('cbid.vssr.' + sid + '.alias').value = decodeURI(param);
}
getFlag(rema,part2[0], sid);
getFlag(rema, part2[0], sid); //get flag iso code
s.innerHTML = "<font color='green'><%:Import%>Shadowsocks<%:Configuration Succeeded%></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.vssr.' + sid + '.type').value = "trojan";
document.getElementById('cbid.vssr.' + sid + '.type').dispatchEvent(event);
var team = sstr.split('@');
console.log(param);
var part1 = team[0].split(':');
var part2 = team[1].split(':');
document.getElementById('cbid.vssr.' + sid + '.server').value = part2[0];
document.getElementById('cbid.vssr.' + sid + '.server_port').value = part2[1];
document.getElementById('cbid.vssr.' + sid + '.password').value = part1[1];
if (param != undefined) {
rema = decodeURI(param)
document.getElementById('cbid.vssr.' + sid + '.alias').value = decodeURI(param);
}
getFlag(rema, part2[0], sid); //get flag iso code
s.innerHTML = "<font color='green'>导入Trojan<%:Configuration Succeeded%></font>";
return false;
} else if (ssu[0] == "vmess") {
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
var rema = "";
document.getElementById('cbid.vssr.' + sid + '.type').value = "v2ray";
document.getElementById('cbid.vssr.' + sid + '.type').dispatchEvent(event);
var url0, param = "";
@ -202,34 +228,35 @@
document.getElementById('cbid.vssr.' + sid + '.alter_id').value = ssm.aid;
document.getElementById('cbid.vssr.' + sid + '.vmess_id').value = ssm.id;
document.getElementById('cbid.vssr.' + sid + '.transport').value = ssm.net;
document.getElementById('cbid.vssr.' + sid + '.transport').dispatchEvent(event);
if (ssm.net == "tcp") {
document.getElementById('cbid.vssr.' + sid + '.http_host').value = ssm.host;
document.getElementById('cbid.vssr.' + sid + '.http_path').value = ssm.path;
}
if (ssm.net == "ws") {
document.getElementById('cbid.vssr.' + sid + '.ws_host').value = ssm.host;
document.getElementById('cbid.vssr.' + sid + '.ws_path').value = ssm.path;
}
if (ssm.net == "h2") {
document.getElementById('cbid.vssr.' + sid + '.h2_host').value = ssm.host;
document.getElementById('cbid.vssr.' + sid + '.h2_path').value = ssm.path;
}
if (ssm.net == "quic") {
document.getElementById('cbid.vssr.' + sid + '.quic_security').value = ssm.securty;
document.getElementById('cbid.vssr.' + sid + '.quic_key').value = ssm.key;
}
if (ssm.net == "kcp") {
document.getElementById('cbid.vssr.' + sid + '.kcp_guise').value = ssm.type;
}
if (ssm.tls == "tls") {
document.getElementById('cbid.vssr.' + sid + '.tls').checked = true;
document.getElementById('cbid.vssr.' + sid + '.insecure').checked = true;
document.getElementById('cbid.vssr.' + sid + '.tls').dispatchEvent(event);
document.getElementById('cbid.vssr.' + sid + '.tls_host').value = ssm.host;
}
document.getElementById('cbid.vssr.' + sid + '.transport').dispatchEvent(event);
switch (ssm.net) {
case "tcp":
break;
case "kcp":
break;
case "ws":
document.getElementById('cbid.vssr.' + sid + '.ws_host').value = ssm.host;
document.getElementById('cbid.vssr.' + sid + '.ws_path').value = ssm.path;
break;
case "h2":
break;
case "quic":
break;
}
getFlag(ssm.ps,ssm.add, sid);
document.getElementById('cbid.vssr.' + sid + '.mux').checked = true;
document.getElementById('cbid.vssr.' + sid + '.mux').dispatchEvent(event);
getFlag(ssm.ps, ssm.add, sid); //get flag iso code
s.innerHTML = "<font color='green'><%:Import%>V2ray<%:Configuration Succeeded%></font>";
return false;

View File

@ -94,7 +94,8 @@
<!-- /tblsection -->
<script type="text/javascript">
var servers = '<%= self.servers%>';
servers = JSON.parse(servers.replace(/\t/g,""));
var ajaxArray = new Array();
servers = JSON.parse(servers.replace(/\t/g, ""));
$.each(servers, function (i, val) {
var id = '#cbi-<%=self.config%>-' + val.name;
if (val.name == "<%=self.current%>") {
@ -115,6 +116,10 @@
function apply_node(node) {
$("#cbi-apply-vssr1").show();
$.each(ajaxArray, function (n,value) {
value.abort();
})
$.get('<%=luci.dispatcher.build_url("admin", "services", "vssr","change")%>',
{
set: node
@ -130,22 +135,23 @@
});
}
$(document).ready(function () {
setTimeout(function() { check(); }, 500);
setTimeout(function () { check(); }, 500);
$(".cbi-page-actions").hide();
function check() {
$(".host_con").html("");
ajaxArray = [];
$(".pure-u-1-5").each(function () {
host = $(this).find(".cbi-section-table-row ").attr("server");
port = $(this).find(".cbi-section-table-row ").attr("server_port");
$(".host_con").text("--ms");
$(".host_con").text("");
check_port(host, port, this);
});
}
function check_port(hosts, ports, target) {
$.get('<%=luci.dispatcher.build_url("admin", "services", "vssr","checkport")%>',
var axhr;
$.ajaxSettings.async = true;
axhr = $.get('<%=luci.dispatcher.build_url("admin", "services", "vssr","checkport")%>',
{
host: hosts,
port: ports
@ -180,6 +186,7 @@
$(target).find(".host_con").text("Error");
}
});
ajaxArray.push(axhr);
}
$(".cbi-button-check").click(function () {

View File

@ -628,4 +628,10 @@ msgid "Diseny+ Proxy"
msgstr "Diseny+ 代理"
msgid "Prime Video Proxy"
msgstr "Prime Video 代理"
msgstr "Prime Video 代理"
msgid "adblock settings"
msgstr "广告屏蔽设置"
msgid "Enable adblock"
msgstr "开启广告屏蔽"

63
relnotes.txt Normal file
View File

@ -0,0 +1,63 @@
########################################################
#
# RELEASE NOTES
#
########################################################
########################################################
//
// 1.05 2020-02-10
//
########################################################
New features
- NEW: 增加了Trojan支持
- NEW: 增加了广告屏蔽的功能
Updates
- UPD: 更新了gfwlist chinaip 和 ad conf的更新代码。
- UPD: 当在节点列表应用新的节点时会先中断所有的ping以保证切换节点优先。
########################################################
//
// 1.04 2020-02-09
//
########################################################
Updates
- UPD: 增加了V2ray简易分流模式现在当你在使用v2ray作为主节点的时候可以选择为几个主流的视频插件指定特定的节点来达到分流的目的。目前可以分流的视频有Youtube 一些台湾的视频平台 Netflix Diseny+ Prime Video
- UPD: 更新了GeoIp2 库
- UPD: 同步更新lean源的订阅代码
- UPD: 增加了一个Licence页面用来显示GEOIP2的授权
Bug fixes
- FIX: 修复一些节点列表的显示问题。
########################################################
//
// 1.02 2019-12-14
//
########################################################
New features
- NEW: 给Hello World 增加了IP状态显示在页面底部 左边显示当前节点国旗 ip 和中文国家 右边 是四个网站的访问状态 可以访问是彩色 不能访问是灰色。
Updates
- UPD: 基于lean ssr+ 全新修改的Vssr更名为Hello World 主要做了很多的修改,同时感谢插件原作者所做出的的努力和贡献!
- UPD: 节点列表支持国旗显示 TW节点为五星红旗 节点列表页面 打开自动ping.
- UPD: 优化了在节点列表页面点击应用后节点切换的速度。同时也优化了自动切换的速度。
- UPD: 将节点订阅转移至 高级设置 请悉知 由于需要获取ip的国家code 新的订阅速度可能会比原来慢一点点 x86无影响。
- UPD: 去掉了ss插件ss节点将通过v2ray进行代理支持ss的v2ray plugin可能会遇到老的加密方式不兼容的情况。
- UPD: 优化了国旗匹配方法在部分带有emoji counrty code的节点名称中 优先使用 emoji code 匹配国旗。
########################################################==
//
// END RELEASE NOTES
//
########################################################==

View File

@ -9,6 +9,7 @@ config global
option enable_switch '1'
option switch_timeout '5'
option switch_time '667'
option adblock '0'
config socks5_proxy
option server 'nil'

View File

@ -45,11 +45,9 @@ uci_get_by_type() {
}
add_cron() {
sed -i '/vssr.log/d' $CRON_FILE
echo '0 1 * * 0 echo "" > /tmp/vssr.log' >>$CRON_FILE
[ -n "$(grep -w "/usr/share/vssr/subscribe.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/vssr\/subscribe.sh/d' $CRON_FILE
sed -i '/vssr.log/d' $CRON_FILE && echo '0 1 * * * echo "" > /tmp/vssr.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/vssr/subscribe.lua" >> $CRON_FILE
[ -z "$(grep -w "/usr/share/vssr/update.sh" $CRON_FILE)" ] && echo "0 5 * * 0 /usr/share/vssr/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/vssr/update.lua" >> $CRON_FILE
crontab $CRON_FILE
}
@ -68,7 +66,7 @@ gen_config_file() {
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`
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
@ -89,12 +87,20 @@ gen_config_file() {
if [ $(uci_get_by_name $1 fast_open 0) = "1" ]; then
fastopen="true"
else
fastopen="false"
fastopen="false"
fi
local stype=$(uci_get_by_name $1 type)
lua /usr/share/vssr/genconfig_${stype}.lua ${server_obj} ${re_type} $(uci_get_by_name $1 local_port) ${hostip} >${config_file}
local port=$(uci_get_by_name $1 local_port)
if [ "$stype" == "trojan" ]; then
if [ "$re_type" == "udp" ]; then
re_type="client"
port="10801"
else
re_type="nat"
fi
fi
lua /usr/share/vssr/genconfig_${stype}.lua ${server_obj} ${re_type} ${port} ${hostip} >${config_file}
sed -i 's/\\//g' $config_file
}
@ -114,7 +120,7 @@ start_rules() {
elif [ "$server" != "${server#*:[0-9a-fA-F]}" ]; then
server=${server}
else
server=`ping ${server} -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1`
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
@ -267,16 +273,21 @@ start_redir() {
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" -o "$stype" == "v2ray" ]; then
sscmd="/usr/bin/v2ray/v2ray"
[ ! -f "$sscmd" ] && sscmd="/usr/bin/v2ray"
elif [ "$stype" == "ssr" ]; then
sscmd="/usr/bin/ssr-redir"
elif [ "$stype" == "trojan" ]; then
sscmd="/usr/sbin/trojan"
fi
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
if [ "$utype" == "ss" -o "$utype" == "v2ray" ]; then
ucmd="/usr/bin/v2ray/v2ray"
[ ! -f "$ucmd" ] && ucmd="/usr/bin/v2ray"
elif [ "$utype" == "ssr" ]; then
ucmd="/usr/bin/ssr-redir"
elif [ "$utype" == "trojan" ]; then
ucmd="/usr/sbin/trojan"
fi
if [ "$(uci_get_by_type global threads 0)" = "0" ]; then
@ -288,18 +299,19 @@ start_redir() {
redir_tcp=1
local last_config_file=$CONFIG_FILE
if [ "$stype" == "ssr" ]; then
local pid_file="/var/run/ssr-retcp.pid"
for i in $(seq 1 $threads); do
$sscmd -c $last_config_file $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1
done
echo "$(date "+%Y-%m-%d %H:%M:%S") SSR $threads 线程 已启动!" >> /tmp/vssr.log
echo "$(date "+%Y-%m-%d %H:%M:%S") SSR $threads 线程 已启动!" >>/tmp/vssr.log
elif [ "$stype" == "v2ray" -o "$stype" == "ss" ]; then
$sscmd -config $last_config_file >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) 已启动!" >> /tmp/vssr.log
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) 已启动!" >>/tmp/vssr.log
elif [ "$stype" == "trojan" ]; then
$sscmd -c $last_config_file >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -V 2>&1 | head -1) 已启动!" >>/tmp/vssr.log
fi
#转发UDP
@ -309,7 +321,7 @@ start_redir() {
last_config_file=$CONFIG_UDP_FILE
echo $utype
if [ "$utype" == "ssr" ]; then
case "$(uci_get_by_name $UDP_RELAY_SERVER auth_enable)" in
1 | on | true | yes | enabled) ARG_OTA="-A" ;;
*) ARG_OTA="" ;;
@ -320,6 +332,9 @@ start_redir() {
#echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) UDP已启动!" >> /tmp/vssr.log
elif [ "$utype" == "ss" -o "$utype" == "v2ray" ]; then
$ucmd -config $last_config_file >/dev/null 2>&1 &
elif [ "$stype" == "trojan" ]; then
$ucmd --config $last_config_file >/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
@ -432,7 +447,6 @@ start_local() {
lua /usr/share/vssr/genconfig_v2ray_s.lua "socks" ${local_port} ${Socks_user} ${Socks_pass} >$CONFIG_SOCK5_FILE
sed -i 's/\\//g' $config_file
/usr/bin/v2ray/v2ray -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 &
local_enable=1
@ -472,6 +486,10 @@ 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/vssr/gfw2ipset.sh
/etc/init.d/dnsmasq restart >/dev/null 2>&1
@ -512,14 +530,12 @@ stop() {
killall -q -9 vssr-monitor
killall -q -9 ssr-redir
killall -q -9 v2ray
killall -q -9 trojan
killall -q -9 ipt2socks
killall -q -9 ssr-server
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
fi
killall -q -9 pdnsd
if [ -f "/tmp/dnsmasq.d/dnsmasq-ssr.conf" ]; then
rm -f /tmp/dnsmasq.d/dnsmasq-ssr.conf

View File

@ -3,4 +3,3 @@
if [ -f /tmp/adnew.conf ]; then
cat /tmp/adnew.conf | grep ^\|\|[^\*]*\^$ | sed -e 's:||:address\=\/:' -e 's:\^:/0\.0\.0\.0:' > /tmp/ad.conf
fi

View File

@ -112,7 +112,7 @@ while [ "1" = "1" ]; do #这里是个死循环
#pdnsd
if [ $pdnsd_process -gt 0 ]; then
icount=$(busybox ps -w | grep pdnsd | grep -v grep | wc -l)
if [ $icount -lt $pdnsd_process ]; then
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

View File

@ -40,6 +40,7 @@ gen_config_file() {
hostip=$(cat /etc/ssr_ip)
fi
fi
[ $2 = "0" -a $kcp_flag = "1" ] && hostip="127.0.0.1"
if [ $2 = "0" ]; then
re_type="tcp"
@ -57,27 +58,37 @@ gen_config_file() {
fi
local stype=$(uci_get_by_name $1 type)
lua /usr/share/vssr/genconfig_${stype}.lua ${server_obj} ${re_type} $(uci_get_by_name $1 local_port) ${hostip} >${config_file}
local port=$(uci_get_by_name $1 local_port)
if [ "$stype" == "trojan" ]; then
if [ "$re_type" == "udp" ]; then
re_type="client"
port="10801"
else
re_type="nat"
fi
fi
lua /usr/share/vssr/genconfig_${stype}.lua ${server_obj} ${re_type} ${port} ${hostip} >${config_file}
sed -i 's/\\//g' $config_file
}
start_local() {
local local_server=$(uci_get_by_type socks5_proxy enable_server)
local local_port=$(uci_get_by_type socks5_proxy local_port)
local Socks_user=$(uci_get_by_type socks5_proxy Socks_user)
local Socks_pass=$(uci_get_by_type socks5_proxy Socks_pass)
[ "$local_server" = "0" ] && return 1
mkdir -p /var/run /var/etc
local local_server=$(uci_get_by_type socks5_proxy enable_server)
local local_port=$(uci_get_by_type socks5_proxy local_port)
local Socks_user=$(uci_get_by_type socks5_proxy Socks_user)
local Socks_pass=$(uci_get_by_type socks5_proxy Socks_pass)
[ "$local_server" = "0" ] && return 1
mkdir -p /var/run /var/etc
lua /usr/share/vssr/genconfig_v2ray_s.lua "socks" ${local_port} ${Socks_user} ${Socks_pass} >$CONFIG_SOCK5_FILE
sed -i 's/\\//g' $config_file
lua /usr/share/vssr/genconfig_v2ray_s.lua "socks" ${local_port} ${Socks_user} ${Socks_pass} >$CONFIG_SOCK5_FILE
sed -i 's/\\//g' $config_file
/usr/bin/v2ray/v2ray -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 &
/usr/bin/v2ray/v2ray -config $CONFIG_SOCK5_FILE >/dev/null 2>&1 &
}
killall -q -9 ssr-redir
killall -q -9 v2ray
killall -q -9 trojan
killall -q -9 ipt2socks
case "$(uci_get_by_name $GLOBAL_SERVER auth_enable)" in
1 | on | true | yes | enabled) ARG_OTA="-A" ;;
@ -92,13 +103,33 @@ fi
gen_config_file $GLOBAL_SERVER 0
stype=$(uci_get_by_name $GLOBAL_SERVER type)
local stype=$(uci_get_by_name $GLOBAL_SERVER type)
if [ "$stype" == "ss" -o "$stype" == "v2ray" ]; then
sscmd="/usr/bin/v2ray/v2ray"
[ ! -f "$sscmd" ] && sscmd="/usr/bin/v2ray"
elif [ "$stype" == "ssr" ]; then
sscmd="/usr/bin/ssr-redir"
elif [ "$stype" == "trojan" ]; then
sscmd="/usr/sbin/trojan"
fi
local utype=$(uci_get_by_name $UDP_RELAY_SERVER type)
if [ "$utype" == "ss" -o "$utype" == "v2ray" ]; then
ucmd="/usr/bin/v2ray/v2ray"
[ ! -f "$ucmd" ] && ucmd="/usr/bin/v2ray"
elif [ "$utype" == "ssr" ]; then
ucmd="/usr/bin/ssr-redir"
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
#转发TCP
if [ "$(uci_get_by_type global threads 0)" = "0" ]; then
threads=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
else
@ -106,15 +137,44 @@ else
fi
#转发TCP
redir_tcp=1
last_config_file=$CONFIG_FILE
local last_config_file=$CONFIG_FILE
if [ "$stype" == "ssr" ]; then
pid_file="/var/run/ssr-retcp.pid"
local pid_file="/var/run/ssr-retcp.pid"
for i in $(seq 1 $threads); do
$sscmd -c $last_config_file $ARG_OTA -f /var/run/ssr-retcp_$i.pid >/dev/null 2>&1
done
echo "$(date "+%Y-%m-%d %H:%M:%S") SSR $threads 线程 已启动!" >>/tmp/vssr.log
elif [ "$stype" == "v2ray" -o "$stype" == "ss" ]; then
$sscmd -config $last_config_file >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) 已启动!" >>/tmp/vssr.log
elif [ "$stype" == "trojan" ]; then
$sscmd -c $last_config_file >/dev/null 2>&1 &
echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -V 2>&1 | head -1) 已启动!" >>/tmp/vssr.log
fi
start_local
#转发UDP
if [ -n "$UDP_RELAY_SERVER" ]; then
redir_udp=1
gen_config_file $UDP_RELAY_SERVER 1
last_config_file=$CONFIG_UDP_FILE
echo $utype
if [ "$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
pid_file="/var/run/ssr-reudp.pid"
#echo $ucmd >> /tmp/vssr.log
$ucmd -c $last_config_file $ARG_OTA -U -f /var/run/ssr-reudp.pid >/tmp/vssr.log 2>&1
#echo "$(date "+%Y-%m-%d %H:%M:%S") $($sscmd -version | head -1) UDP已启动!" >> /tmp/vssr.log
elif [ "$utype" == "ss" -o "$utype" == "v2ray" ]; then
$ucmd -config $last_config_file >/dev/null 2>&1 &
elif [ "$stype" == "trojan" ]; then
$ucmd --config $last_config_file >/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
start_local

View File

@ -0,0 +1,39 @@
local ucursor = require "luci.model.uci".cursor()
local json = require "luci.jsonc"
local server_section = arg[1]
local proto = arg[2]
local local_port = arg[3]
local server = ucursor:get_all("vssr", 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 = "",
cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA",
cipher_tls13 = "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
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))

View File

@ -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('vssr', '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/vssr-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
-- --]]