mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
commit
78b9b34b8a
@ -4,11 +4,11 @@ LINUX_RELEASE?=1
|
||||
|
||||
LINUX_VERSION-3.18 = .71
|
||||
LINUX_VERSION-4.4 = .88
|
||||
LINUX_VERSION-4.9 = .51
|
||||
LINUX_VERSION-4.9 = .52
|
||||
|
||||
LINUX_KERNEL_HASH-3.18.71 = 5abc9778ad44ce02ed6c8ab52ece8a21c6d20d21f6ed8a19287b4a38a50c1240
|
||||
LINUX_KERNEL_HASH-4.4.88 = 144fe8dd773ec317fa06109b8d7bd04141bf1941daa03799fb4f437bbbb919b4
|
||||
LINUX_KERNEL_HASH-4.9.51 = 83faa66102d8a4c164857014c5304e08ca6c16f1697851862af17ba61378aa8a
|
||||
LINUX_KERNEL_HASH-4.9.52 = ffdd034f1bf32fa41d1a66a347388c0dc4c3cff6f578a1e29d88b20fbae1048a
|
||||
|
||||
ifdef KERNEL_PATCHVER
|
||||
LINUX_VERSION:=$(KERNEL_PATCHVER)$(strip $(LINUX_VERSION-$(KERNEL_PATCHVER)))
|
||||
|
@ -47,7 +47,7 @@ sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
|
||||
wifi up
|
||||
|
||||
sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release
|
||||
echo "DISTRIB_REVISION='R7.4 By Lean'" >> /etc/openwrt_release
|
||||
echo "DISTRIB_REVISION='R7.4.1 By Lean'" >> /etc/openwrt_release
|
||||
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
|
||||
echo "DISTRIB_DESCRIPTION='LEDE 17.01.2'" >> /etc/openwrt_release
|
||||
|
||||
|
@ -10,7 +10,7 @@ LUCI_DEPENDS:=+adbyby +wget +ipset +coreutils +coreutils-nohup +dnsmasq-full
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-adbyby-plus
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=19
|
||||
PKG_RELEASE:=20
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -70,7 +70,8 @@ o.description = translate(string.format("%s<br /><br />", Status))
|
||||
o.description = translate(string.format("<strong>Lazy Rule:</strong>%s <strong> Video Rule:</strong>%s<br /><strong>Third Party Subscription Rule:</strong>%d lines <strong>User-defined Rule:</strong>%d lines", DL, DV, math.abs(NR-NU), NR))
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
SYS.call("/etc/init.d/adbyby restart")
|
||||
SYS.call("nohup sh /usr/share/adbyby/adupdate.sh > /tmp/adupdate.log 2>&1 &")
|
||||
SYS.call("sleep 4")
|
||||
HTTP.redirect(DISP.build_url("admin", "services", "adbyby"))
|
||||
end
|
||||
|
||||
@ -82,7 +83,6 @@ o.default = 0
|
||||
o.rmempty = false
|
||||
o.description = translate(string.format("<strong><font color=blue>Adblock Plus Host List:</font></strong> %s Lines<br /><br />", ND))
|
||||
|
||||
|
||||
updatead = s:taboption("advanced", Button, "updatead", translate("Manually force update<br />Adblock Plus Host List"), translate("Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > After completed it would automatically refresh, please do not duplicate click!"))
|
||||
updatead.inputtitle = translate("Manually force update")
|
||||
updatead.inputstyle = "apply"
|
||||
@ -90,6 +90,11 @@ updatead.write = function()
|
||||
SYS.call("nohup sh /usr/share/adbyby/adblock.sh > /tmp/adupdate.log 2>&1 &")
|
||||
end
|
||||
|
||||
o = s:taboption("advanced", Flag, "update_source")
|
||||
o.title = translate("Update adbyby rules form official website first")
|
||||
o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("advanced", Flag, "block_ios")
|
||||
o.title = translate("Block Apple iOS OTA update")
|
||||
o.default = 0
|
||||
|
@ -114,5 +114,12 @@ msgstr "<strong><font color=blue>Adblock Plus Host 列表:</font></strong>"
|
||||
msgid "Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > After completed it would automatically refresh, please do not duplicate click!"
|
||||
msgstr "注意:需要下载并转换规则。后台进程可能需要60-120秒运行。完成后会自动刷新,请不要重复点击!"
|
||||
|
||||
msgid "No filter"
|
||||
msgstr "不过滤"
|
||||
|
||||
msgid "Global filter"
|
||||
msgstr "全局过滤"
|
||||
|
||||
msgid "Update adbyby rules form official website first"
|
||||
msgstr "优先从官方网站更新规则"
|
||||
|
||||
|
@ -1,8 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
wget -t 1 -T 10 -O /tmp/lazy.txt http://update.adbyby.com/rule3/lazy.jpg
|
||||
wget -t 1 -T 10 -O /tmp/video.txt http://update.adbyby.com/rule3/video.jpg
|
||||
wget -t 1 -T 10 -O /tmp/user.action http://update.adbyby.com/rule3/user.action
|
||||
update_source=$(uci get adbyby.@adbyby[0].update_source 2>/dev/null)
|
||||
|
||||
rm -f /usr/share/adbyby/data/*.bak
|
||||
|
||||
if [ $update_source -eq 1 ]; then
|
||||
wget -t 1 -T 10 -O /tmp/lazy.txt http://update.adbyby.com/rule3/lazy.jpg
|
||||
wget -t 1 -T 10 -O /tmp/video.txt http://update.adbyby.com/rule3/video.jpg
|
||||
wget -t 1 -T 10 -O /tmp/user.action http://update.adbyby.com/rule3/user.action
|
||||
fi
|
||||
|
||||
[ ! -s "/tmp/lazy.txt" ] && wget --no-check-certificate -O /tmp/lazy.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/lazy.txt
|
||||
[ ! -s "/tmp/video.txt" ] && wget --no-check-certificate -O /tmp/video.txt https://raw.githubusercontent.com/adbyby/xwhyc-rules/master/video.txt
|
||||
|
35
package/lean/luci-app-kcptun/Makefile
Normal file
35
package/lean/luci-app-kcptun/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
# Licensed to the public under the Apache License 2.0.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-kcptun
|
||||
PKG_VERSION:=1.4.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_MAINTAINER:=Xingwang Liao <kuoruan@gmail.com>
|
||||
|
||||
LUCI_TITLE:=LuCI support for Kcptun
|
||||
LUCI_DEPENDS:=+jshn +wget +luci-lib-jsonc
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/kcptun
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
( . /etc/uci-defaults/40_luci-kcptun ) && rm -f /etc/uci-defaults/40_luci-kcptun
|
||||
fi
|
||||
chmod 755 $${IPKG_INSTROOT}/etc/init.d/kcptun >/dev/null 2>&1
|
||||
$${IPKG_INSTROOT}/etc/init.d/kcptun enable >/dev/null 2>&1
|
||||
exit 0
|
||||
endef
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
120
package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua
Normal file
120
package/lean/luci-app-kcptun/luasrc/controller/kcptun.lua
Normal file
@ -0,0 +1,120 @@
|
||||
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
module("luci.controller.kcptun", package.seeall)
|
||||
|
||||
local http = require "luci.http"
|
||||
local kcp = require "luci.model.kcptun"
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/kcptun") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "kcptun"},
|
||||
firstchild(), _("Kcptun Client")).dependent = false
|
||||
|
||||
entry({"admin", "services", "kcptun", "settings"},
|
||||
cbi("kcptun/settings"), _("Settings"), 1)
|
||||
|
||||
entry({"admin", "services", "kcptun", "servers"},
|
||||
arcombine(cbi("kcptun/servers"), cbi("kcptun/servers-detail")),
|
||||
_("Server Manage"), 2).leaf = true
|
||||
|
||||
entry({"admin", "services", "kcptun", "log"},
|
||||
template("kcptun/log_view"), _("Log"), 3)
|
||||
|
||||
entry({"admin", "services", "kcptun", "status"}, call("action_status"))
|
||||
|
||||
entry({"admin", "services", "kcptun", "check"}, call("action_check")).leaf = true
|
||||
|
||||
entry({"admin", "services", "kcptun", "update"}, call("action_update")).leaf = true
|
||||
|
||||
entry({"admin", "services", "kcptun", "log", "data"}, call("action_log_data"))
|
||||
|
||||
entry({"admin", "services", "kcptun", "log", "clear"}, call("action_log_clear")).leaf = true
|
||||
end
|
||||
|
||||
local function http_write_json(content)
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(content or { code = 1 })
|
||||
end
|
||||
|
||||
function action_status()
|
||||
local client_file = kcp.get_config_option("client_file")
|
||||
|
||||
http_write_json({
|
||||
client = kcp.is_running(client_file)
|
||||
})
|
||||
end
|
||||
|
||||
function action_check(type)
|
||||
local json = nil
|
||||
if type == "kcptun" then
|
||||
json = kcp.check_kcptun(http.formvalue("arch"))
|
||||
elseif type == "luci" then
|
||||
json = kcp.check_luci()
|
||||
else
|
||||
http.status(500, "Bad address")
|
||||
return
|
||||
end
|
||||
|
||||
http_write_json(json)
|
||||
end
|
||||
|
||||
function action_update(type)
|
||||
local json = nil
|
||||
if type == "kcptun" then
|
||||
local task = http.formvalue("task")
|
||||
if task == "extract" then
|
||||
json = kcp.extract_kcptun(http.formvalue("file"), http.formvalue("subfix"))
|
||||
elseif task == "move" then
|
||||
json = kcp.move_kcptun(http.formvalue("file"))
|
||||
else
|
||||
json = kcp.download_kcptun(http.formvalue("url"))
|
||||
end
|
||||
elseif type == "luci" then
|
||||
json = kcp.update_luci(http.formvalue("url"), http.formvalue("save"))
|
||||
else
|
||||
http.status(500, "Bad address")
|
||||
return
|
||||
end
|
||||
|
||||
http_write_json(json)
|
||||
end
|
||||
|
||||
function action_log_data()
|
||||
local util = require "luci.util"
|
||||
|
||||
local log_data = { }
|
||||
|
||||
local enable_logging = kcp.get_config_option("enable_logging", "0") == "1"
|
||||
|
||||
if enable_logging then
|
||||
local client_log_file = kcp.get_current_log_file("client")
|
||||
log_data.client = util.trim(
|
||||
util.exec("tail -n 50 %s 2>/dev/null | sed 'x;1!H;$!d;x'" % client_log_file))
|
||||
end
|
||||
|
||||
log_data.syslog = util.trim(
|
||||
util.exec("logread | grep kcptun | tail -n 50 | sed 'x;1!H;$!d;x'"))
|
||||
|
||||
http_write_json(log_data)
|
||||
end
|
||||
|
||||
function action_log_clear(type)
|
||||
if type and type ~= "" then
|
||||
local log_file = kcp.get_current_log_file(type)
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
if fs.access(log_file) then
|
||||
fs.writefile(log_file, "")
|
||||
else
|
||||
http.status(404, "Not found")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
http_write_json({ code = 0 })
|
||||
end
|
@ -0,0 +1,182 @@
|
||||
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local dsp = require "luci.dispatcher"
|
||||
|
||||
local m, s, o
|
||||
local sid = arg[1]
|
||||
|
||||
local encrypt_methods = {
|
||||
"aes",
|
||||
"aes-128",
|
||||
"aes-192",
|
||||
"salsa20",
|
||||
"blowfish",
|
||||
"twofish",
|
||||
"cast5",
|
||||
"3des",
|
||||
"tea",
|
||||
"xtea",
|
||||
"xor",
|
||||
"none",
|
||||
}
|
||||
|
||||
local modes = {
|
||||
"normal",
|
||||
"fast",
|
||||
"fast2",
|
||||
"fast3",
|
||||
"manual",
|
||||
}
|
||||
|
||||
m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Edit Server") })
|
||||
m.redirect = dsp.build_url("admin/services/kcptun/servers")
|
||||
|
||||
if m.uci:get("kcptun", sid) ~= "servers" then
|
||||
luci.http.redirect(m.redirect)
|
||||
return
|
||||
end
|
||||
|
||||
s = m:section(NamedSection, sid, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(Value, "alias", "%s (%s)" % { translate("Alias"), translate("optional") })
|
||||
|
||||
o = s:option(Value, "server_addr", translate("Server"))
|
||||
o.datatype = "host"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "server_port", translate("Server Port"))
|
||||
o.datatype = "port"
|
||||
o.placeholder = "29900"
|
||||
|
||||
o = s:option(Value, "listen_addr", "%s (%s)" % { translate("Local Listen Host"), translate("optional") },
|
||||
translate("Local listen host."))
|
||||
o.datatype = "host"
|
||||
o.placeholder = "0.0.0.0"
|
||||
|
||||
o = s:option(Value, "listen_port", translate("Local Port"), translate("Local Listen Port."))
|
||||
o.datatype = "port"
|
||||
o.placeholder = "12948"
|
||||
|
||||
o = s:option(Value, "key", "%s (%s)" % { translate("Key"), translate("optional") },
|
||||
translate("Pre-shared secret for client and server."))
|
||||
o.password = true
|
||||
o.placeholder = "it's a secret"
|
||||
|
||||
o = s:option(Value, "crypt", translate("crypt"), translate("Encrypt Method"))
|
||||
for _, v in ipairs(encrypt_methods) do
|
||||
o:value(v, v:upper())
|
||||
end
|
||||
o.default = "aes"
|
||||
|
||||
o = s:option(ListValue, "mode", translate("mode"), translate("Embedded Mode"))
|
||||
for _, v in ipairs(modes) do
|
||||
o:value(v, v:upper())
|
||||
end
|
||||
o.default = "fast"
|
||||
|
||||
o = s:option(Flag, "nodelay", translate("nodelay"), translate("Enable nodelay Mode."))
|
||||
o:depends("mode", "manual")
|
||||
|
||||
o = s:option(Value, "interval", translate("interval"))
|
||||
o:depends("mode", "manual")
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "50"
|
||||
|
||||
o = s:option(ListValue, "resend", translate("resend"))
|
||||
o:depends("mode", "manual")
|
||||
o:value("0", translate("Off"))
|
||||
o:value("1", translate("On"))
|
||||
o:value("2", translate("2nd ACK"))
|
||||
|
||||
o = s:option(Flag, "nc", translate("nc"))
|
||||
o:depends("mode", "manual")
|
||||
|
||||
o = s:option(Value, "mtu", "%s (%s)" % { translate("mtu"), translate("optional") },
|
||||
translate("Maximum transmission unit of UDP packets."))
|
||||
o.datatype = "range(64,9200)"
|
||||
o.placeholder = "1350"
|
||||
|
||||
o = s:option(Value, "sndwnd", "%s (%s)" % { translate("sndwnd"), translate("optional") },
|
||||
translate("Send Window Size(num of packets)."))
|
||||
o.datatype = "min(1)"
|
||||
o.default = "128"
|
||||
o.placeholder = "128"
|
||||
|
||||
o = s:option(Value, "rcvwnd", "%s (%s)" % { translate("rcvwnd"), translate("optional") },
|
||||
translate("Receive Window Size(num of packets)."))
|
||||
o.datatype = "min(1)"
|
||||
o.default = "512"
|
||||
o.placeholder = "512"
|
||||
|
||||
o = s:option(Value, "datashard", "%s (%s)" % { translate("datashard"), translate("optional") },
|
||||
translate("Reed-solomon Erasure Coding - datashard."))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "10"
|
||||
|
||||
o = s:option(Value, "parityshard", "%s (%s)" % { translate("parityshard"), translate("optional") },
|
||||
translate("Reed-solomon Erasure Coding - parityshard."))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "3"
|
||||
|
||||
o = s:option(Value, "dscp", "%s (%s)" % { translate("dscp"), translate("optional") }, translate("DSCP(6bit)"))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "0"
|
||||
|
||||
o = s:option(Flag, "nocomp", translate("nocomp"), translate("Disable Compression?"))
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "acknodelay", translate("acknodelay"))
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
|
||||
o = s:option(Value, "conn", "%s (%s)" %{ translate("conn"), translate("optional") },
|
||||
translate("Number of UDP connections to server."))
|
||||
o.datatype = "min(1)"
|
||||
o.placeholder = "1"
|
||||
|
||||
o = s:option(Value, "autoexpire", "%s (%s)" % { translate("autoexpire"), translate("optional") },
|
||||
translate("Auto expiration time(in seconds) for a single UDP connection, 0 to disable."))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "0"
|
||||
|
||||
o = s:option(Value, "scavengettl", "%s (%s)" % { translate("scavengettl"), translate("optional") },
|
||||
translate("How long an expired connection can live(in sec), -1 to disable."))
|
||||
o.datatype = "min(-1)"
|
||||
o.placeholder = "600"
|
||||
|
||||
o = s:option(Value, "sockbuf", "%s (%s)" % { translate("sockbuf"), translate("optional") },
|
||||
translate("Send/secv buffer size of udp sockets, default unit is MB."))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "4"
|
||||
o.cfgvalue = function(...)
|
||||
local value = Value.cfgvalue(...)
|
||||
|
||||
if value then
|
||||
return tonumber(value) / 1024 / 1024
|
||||
end
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
local number = tonumber(value)
|
||||
if number then
|
||||
Value.write(self, section, number * 1024 * 1024)
|
||||
else
|
||||
Value.remove(self, section)
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(Value, "keepalive", "%s (%s)" % { translate("keepalive"), translate("optional") },
|
||||
translate("NAT keepalive interval to prevent your router from removing port mapping, default unit is seconds."))
|
||||
o.datatype = "uinteger"
|
||||
o.placeholder = "10"
|
||||
|
||||
o = s:option(Value, "snmpperiod", "%s (%s)" % { translate("snmpperiod"),
|
||||
translate("optional") }, translate("SNMP collect period, in seconds"))
|
||||
o.datatype = "min(1)"
|
||||
o.placeholder = "60"
|
||||
|
||||
return m
|
@ -0,0 +1,71 @@
|
||||
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local dsp = require "luci.dispatcher"
|
||||
local http = require "luci.http"
|
||||
|
||||
local m, s, o
|
||||
|
||||
local function get_ip_string(ip)
|
||||
if ip and ip:find(":") then
|
||||
return "[%s]" % ip
|
||||
else
|
||||
return ip or ""
|
||||
end
|
||||
end
|
||||
|
||||
m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Server List") })
|
||||
|
||||
s = m:section(TypedSection, "servers")
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.sortable = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = dsp.build_url("admin/services/kcptun/servers/%s")
|
||||
function s.create(...)
|
||||
local sid = TypedSection.create(...)
|
||||
if sid then
|
||||
m.uci:save("kcptun")
|
||||
http.redirect(s.extedit % sid)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "alias", translate("Alias"))
|
||||
function o.cfgvalue(self, section)
|
||||
return Value.cfgvalue(self, section) or translate("None")
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_server_address", translate("Server Address"))
|
||||
function o.cfgvalue(self, section)
|
||||
local server = m.uci:get("kcptun", section, "server_addr") or "?"
|
||||
local server_port = m.uci:get("kcptun", section, "server_port") or "29900"
|
||||
return "%s:%s" % { get_ip_string(server), server_port }
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_listen_addres", translate("Listen Address"))
|
||||
function o.cfgvalue(self, section)
|
||||
local local_host = m.uci.get("kcptun", section, "listen_addr") or "0.0.0.0"
|
||||
local local_port = m.uci.get("kcptun", section, "listen_port") or "12984"
|
||||
return "%s:%s" % { get_ip_string(local_host), local_port }
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "crypt", translate("Encrypt Method"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:upper() or "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "mode", translate("Embedded Mode"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v and v:upper() or "?"
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "nocomp", translate("Disable Compression"))
|
||||
function o.cfgvalue(...)
|
||||
local v = Value.cfgvalue(...)
|
||||
return v == "true" and translate("True") or translate("False")
|
||||
end
|
||||
|
||||
return m
|
@ -0,0 +1,112 @@
|
||||
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local util = require "luci.util"
|
||||
local sys = require "luci.sys"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local m, s, o
|
||||
local server_table = { }
|
||||
|
||||
local function get_ip_string(ip)
|
||||
if ip and ip:find(":") then
|
||||
return "[%s]" % ip
|
||||
else
|
||||
return ip or ""
|
||||
end
|
||||
end
|
||||
|
||||
uci:foreach("kcptun", "servers", function(s)
|
||||
if s.alias then
|
||||
server_table[s[".name"]] = s.alias
|
||||
elseif s.server_addr and s.server_port then
|
||||
server_table[s[".name"]] = "%s:%s" % { get_ip_string(s.server_addr), s.server_port }
|
||||
end
|
||||
end)
|
||||
|
||||
m = Map("kcptun", "%s - %s" % { translate("Kcptun"), translate("Settings") })
|
||||
m:append(Template("kcptun/status"))
|
||||
|
||||
s = m:section(NamedSection, "general", "general", translate("General Settings"))
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
o = s:option(ListValue, "server", translate("Server"))
|
||||
o:value("", translate("Disable"))
|
||||
for k, v in pairs(server_table) do
|
||||
o:value(k, v)
|
||||
end
|
||||
|
||||
o = s:option(Value, "client_file", translate("Client File"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "daemon_user", translate("Run Daemon as User"))
|
||||
for u in util.execi("cat /etc/passwd | cut -d ':' -f1") do
|
||||
o:value(u)
|
||||
end
|
||||
|
||||
o = s:option(Flag, "enable_logging", translate("Enable Logging"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "log_folder", translate("Log Folder"))
|
||||
o.datatype = "directory"
|
||||
o.placeholder = "/var/log/kcptun"
|
||||
o:depends("enable_logging", "1")
|
||||
o.formvalue = function(...)
|
||||
local v = (Value.formvalue(...) or ""):trim()
|
||||
if v ~= "" then
|
||||
v = string.gsub(v, "\\", "/")
|
||||
if v:sub(1, 1) ~= "/" then
|
||||
v = "/" .. v
|
||||
end
|
||||
|
||||
while v:sub(-1) == "/" do
|
||||
v = v:sub(1, -2)
|
||||
end
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
||||
o.validate = function(self, value, section)
|
||||
if value and not fs.stat(value) then
|
||||
local res, code, msg = fs.mkdir(value)
|
||||
if not res then
|
||||
return nil, msg
|
||||
end
|
||||
end
|
||||
return Value.validate(self, value, section)
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "arch", translate("CPU Architecture"),
|
||||
translate("The ARCH for checking updates." ..
|
||||
" Note: Make sure OpenWrt/LEDE 'MIPS FPU Emulator' is enabled on MIPS/MIPSLE devices."))
|
||||
o:value("", translate("Auto"))
|
||||
o:value("i386", "x86")
|
||||
o:value("x86_64", "x86_64")
|
||||
o:value("armv5", "ARMv5")
|
||||
o:value("armv6", "ARMv6")
|
||||
o:value("armv7", "ARMv7+")
|
||||
o:value("ar71xx", "MIPS")
|
||||
o:value("ramips", "MIPSLE")
|
||||
|
||||
o = s:option(Button, "_check_kcptun", translate("Check Kcptun Update"),
|
||||
translate("Make sure that the 'Client File' dictionary has enough space."))
|
||||
o.template = "kcptun/button"
|
||||
o.inputstyle = "apply"
|
||||
o.placeholder = translate("Check Kcptun Update")
|
||||
o.btnclick = "check_update('kcptun', this);"
|
||||
o.id = "_kcptun-check_kcptun"
|
||||
|
||||
o = s:option(Flag, "save_config", translate("Save Config File"),
|
||||
translate("Save config file while upgrade LuCI."))
|
||||
|
||||
o = s:option(Button, "_check_luci", translate("Check LuCI Update"),
|
||||
translate("You may need to reload current page after update LuCI. Note that translation will not be updated."))
|
||||
o.template = "kcptun/button"
|
||||
o.inputstyle = "apply"
|
||||
o.placeholder = translate("Check LuCI Update")
|
||||
o.btnclick = "check_update('luci', this);"
|
||||
o.id = "_kcptun-check_luci"
|
||||
|
||||
return m
|
486
package/lean/luci-app-kcptun/luasrc/model/kcptun.lua
Normal file
486
package/lean/luci-app-kcptun/luasrc/model/kcptun.lua
Normal file
@ -0,0 +1,486 @@
|
||||
-- Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local util = require "luci.util"
|
||||
local i18n = require "luci.i18n"
|
||||
|
||||
module("luci.model.kcptun", package.seeall)
|
||||
|
||||
local kcptun_api = "https://api.github.com/repos/xtaci/kcptun/releases/latest"
|
||||
local luci_api = "https://api.github.com/repos/kuoruan/luci-app-kcptun/releases/latest"
|
||||
|
||||
local wget = "/usr/bin/wget"
|
||||
local wget_args = { "--no-check-certificate", "--quiet", "--timeout=10", "--tries=2" }
|
||||
local command_timeout = 40
|
||||
|
||||
local function _unpack(t, i)
|
||||
i = i or 1
|
||||
if t[i] ~= nil then
|
||||
return t[i], _unpack(t, i + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function exec(cmd, args, writer, timeout)
|
||||
local os = require "os"
|
||||
local nixio = require "nixio"
|
||||
|
||||
local fdi, fdo = nixio.pipe()
|
||||
local pid = nixio.fork()
|
||||
|
||||
if pid > 0 then
|
||||
fdo:close()
|
||||
|
||||
if writer or timeout then
|
||||
local starttime = os.time()
|
||||
while true do
|
||||
if timeout and os.difftime(os.time(), starttime) >= timeout then
|
||||
nixio.kill(pid, nixio.const.SIGTERM)
|
||||
return 1
|
||||
end
|
||||
|
||||
if writer then
|
||||
local buffer = fdi:read(2048)
|
||||
if buffer and #buffer > 0 then
|
||||
writer(buffer)
|
||||
end
|
||||
end
|
||||
|
||||
local wpid, stat, code = nixio.waitpid(pid, "nohang")
|
||||
|
||||
if wpid and stat == "exited" then
|
||||
return code
|
||||
end
|
||||
|
||||
if not writer and timeout then
|
||||
nixio.nanosleep(1)
|
||||
end
|
||||
end
|
||||
else
|
||||
local wpid, stat, code = nixio.waitpid(pid)
|
||||
return wpid and stat == "exited" and code
|
||||
end
|
||||
elseif pid == 0 then
|
||||
nixio.dup(fdo, nixio.stdout)
|
||||
fdi:close()
|
||||
fdo:close()
|
||||
nixio.exece(cmd, args, nil)
|
||||
nixio.stdout:close()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
local function compare_versions(ver1, comp, ver2)
|
||||
local table = table
|
||||
|
||||
local av1 = util.split(ver1, "[%.%-]", nil, true)
|
||||
local av2 = util.split(ver2, "[%.%-]", nil, true)
|
||||
|
||||
local max = table.getn(av1)
|
||||
local n2 = table.getn(av2)
|
||||
if (max < n2) then
|
||||
max = n2
|
||||
end
|
||||
|
||||
for i = 1, max, 1 do
|
||||
local s1 = av1[i] or ""
|
||||
local s2 = av2[i] or ""
|
||||
|
||||
if comp == "~=" and (s1 ~= s2) then return true end
|
||||
if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
|
||||
if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
|
||||
if (s1 ~= s2) then return false end
|
||||
end
|
||||
|
||||
return not (comp == "<" or comp == ">")
|
||||
end
|
||||
|
||||
local function auto_get_arch()
|
||||
local arch = nixio.uname().machine or ""
|
||||
|
||||
if arch == "mips" then
|
||||
if fs.access("/usr/lib/os-release") then
|
||||
arch = sys.exec("grep 'LEDE_BOARD' /usr/lib/os-release | grep -oE 'ramips|ar71xx'")
|
||||
elseif fs.access("/etc/openwrt_release") then
|
||||
arch = sys.exec("grep 'DISTRIB_TARGET' /etc/openwrt_release | grep -oE 'ramips|ar71xx'")
|
||||
end
|
||||
end
|
||||
|
||||
return util.trim(arch)
|
||||
end
|
||||
|
||||
local function get_file_info(arch)
|
||||
local file_tree = ""
|
||||
local sub_version = ""
|
||||
|
||||
if arch == "x86_64" then
|
||||
file_tree = "amd64"
|
||||
elseif arch == "ramips" then
|
||||
file_tree = "mipsle"
|
||||
elseif arch == "ar71xx" then
|
||||
file_tree = "mips"
|
||||
elseif arch:match("^i[%d]86$") then
|
||||
file_tree = "386"
|
||||
elseif arch:match("^armv[5-8]") then
|
||||
file_tree = "arm"
|
||||
sub_version = arch:match("[5-8]")
|
||||
end
|
||||
|
||||
return file_tree, sub_version
|
||||
end
|
||||
|
||||
local function get_api_json(url)
|
||||
local jsonc = require "luci.jsonc"
|
||||
|
||||
local output = { }
|
||||
exec(wget, { "-O-", url, _unpack(wget_args) },
|
||||
function(chunk) output[#output + 1] = chunk end)
|
||||
|
||||
local json_content = util.trim(table.concat(output))
|
||||
|
||||
if json_content == "" then
|
||||
return { }
|
||||
end
|
||||
|
||||
return jsonc.parse(json_content) or { }
|
||||
end
|
||||
|
||||
function get_config_option(option, default)
|
||||
return uci:get("kcptun", "general", option) or default
|
||||
end
|
||||
|
||||
function get_current_log_file(type)
|
||||
local log_folder = get_config_option("log_folder", "/var/log/kcptun")
|
||||
return "%s/%s.%s.log" % { log_folder, type, "general" }
|
||||
end
|
||||
|
||||
function is_running(client)
|
||||
if client and client ~= "" then
|
||||
local file_name = client:match(".*/([^/]+)$") or ""
|
||||
if file_name ~= "" then
|
||||
return sys.call("pidof %s >/dev/null" % file_name) == 0
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function get_kcptun_version(file)
|
||||
if file and file ~= "" then
|
||||
if not fs.access(file, "rwx", "rx", "rx") then
|
||||
fs.chmod(file, 755)
|
||||
end
|
||||
|
||||
local info = util.trim(sys.exec("%s -v 2>/dev/null" % file))
|
||||
|
||||
if info ~= "" then
|
||||
local tb = util.split(info, "%s+", nil, true)
|
||||
return tb[1] == "kcptun" and tb[3] or ""
|
||||
end
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
function get_luci_version()
|
||||
local ipkg = require "luci.model.ipkg"
|
||||
|
||||
local package_name = "luci-app-kcptun"
|
||||
local package_info = ipkg.info(package_name) or {}
|
||||
|
||||
if next(package_info) ~= nil then
|
||||
return package_info[package_name]["Version"]
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
function check_kcptun(arch)
|
||||
if not arch or arch == "" then
|
||||
arch = auto_get_arch()
|
||||
end
|
||||
|
||||
local file_tree, sub_version = get_file_info(arch)
|
||||
|
||||
if file_tree == "" then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Can't determine ARCH, or ARCH not supported. Please select manually.")
|
||||
}
|
||||
end
|
||||
|
||||
local json = get_api_json(kcptun_api)
|
||||
|
||||
if json.tag_name == nil then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Get remote version info failed.")
|
||||
}
|
||||
end
|
||||
|
||||
local remote_version = json.tag_name:match("[^v]+")
|
||||
|
||||
local client_file = get_config_option("client_file")
|
||||
|
||||
local needs_update = compare_versions(get_kcptun_version(client_file), "<", remote_version)
|
||||
local html_url, download_url
|
||||
|
||||
if needs_update then
|
||||
html_url = json.html_url
|
||||
for _, v in ipairs(json.assets) do
|
||||
if v.name and v.name:match("linux%-" .. file_tree) then
|
||||
download_url = v.browser_download_url
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if needs_update and not download_url then
|
||||
return {
|
||||
code = 1,
|
||||
version = remote_version,
|
||||
html_url = html_url,
|
||||
error = i18n.translate("New version found, but failed to get new version download url.")
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
code = 0,
|
||||
update = needs_update,
|
||||
version = remote_version,
|
||||
url = {
|
||||
html = html_url,
|
||||
download = download_url
|
||||
},
|
||||
type = file_tree .. sub_version
|
||||
}
|
||||
end
|
||||
|
||||
function check_luci()
|
||||
local json = get_api_json(luci_api)
|
||||
|
||||
if json.tag_name == nil then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Get remote version info failed.")
|
||||
}
|
||||
end
|
||||
|
||||
local remote_version = json.tag_name:match("[^v]+")
|
||||
|
||||
local needs_update = compare_versions(get_luci_version(), "<", remote_version)
|
||||
local html_url, luci_url
|
||||
local i18n_urls = { }
|
||||
|
||||
if needs_update then
|
||||
html_url = json.html_url
|
||||
for _, v in ipairs(json.assets) do
|
||||
local n = v.name
|
||||
if n then
|
||||
if n:match("luci%-app%-kcptun") then
|
||||
luci_url = v.browser_download_url
|
||||
elseif n:match("luci%-i18n%-kcptun") then
|
||||
i18n_urls[#i18n_urls + 1] = v.browser_download_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if needs_update and not luci_url then
|
||||
return {
|
||||
code = 1,
|
||||
version = remote_version,
|
||||
html_url = html_url,
|
||||
error = i18n.translate("New version found, but failed to get new version download url.")
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
code = 0,
|
||||
update = needs_update,
|
||||
version = remote_version,
|
||||
url = {
|
||||
html = html_url,
|
||||
luci = luci_url,
|
||||
i18n = i18n_urls
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function download_kcptun(url)
|
||||
if not url or url == "" then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Download url is required.")
|
||||
}
|
||||
end
|
||||
|
||||
sys.call("/bin/rm -f /tmp/kcptun_download.*")
|
||||
|
||||
local tmp_file = util.trim(util.exec("mktemp -u -t kcptun_download.XXXXXX"))
|
||||
|
||||
local result = exec(wget, {
|
||||
"-O", tmp_file, url, _unpack(wget_args) }, nil, command_timeout) == 0
|
||||
|
||||
if not result then
|
||||
exec("/bin/rm", { "-f", tmp_file })
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translatef("File download failed or timed out: %s", url)
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
code = 0,
|
||||
file = tmp_file
|
||||
}
|
||||
end
|
||||
|
||||
function extract_kcptun(file, subfix)
|
||||
if not file or file == "" or not fs.access(file) then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("File path required.")
|
||||
}
|
||||
end
|
||||
|
||||
sys.call("/bin/rm -rf /tmp/kcptun_extract.*")
|
||||
local tmp_dir = util.trim(util.exec("mktemp -d -t kcptun_extract.XXXXXX"))
|
||||
|
||||
local output = { }
|
||||
exec("/bin/tar", { "-C", tmp_dir, "-zxvf", file },
|
||||
function(chunk) output[#output + 1] = chunk end)
|
||||
|
||||
local files = util.split(table.concat(output))
|
||||
|
||||
exec("/bin/rm", { "-f", file })
|
||||
|
||||
local new_file = nil
|
||||
for _, f in pairs(files) do
|
||||
if f:match("client_linux_%s" % subfix) then
|
||||
new_file = tmp_dir .. "/" .. util.trim(f)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not new_file then
|
||||
for _, f in pairs(files) do
|
||||
if f:match("client_") then
|
||||
new_file = tmp_dir .. "/" .. util.trim(f)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not new_file then
|
||||
exec("/bin/rm", { "-rf", tmp_dir })
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translatef("Can't find client in file: %s", file)
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
code = 0,
|
||||
file = new_file
|
||||
}
|
||||
end
|
||||
|
||||
function move_kcptun(file)
|
||||
if not file or file == "" or not fs.access(file) then
|
||||
sys.call("/bin/rm -rf /tmp/kcptun_extract.*")
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Client file is required.")
|
||||
}
|
||||
end
|
||||
|
||||
local version = get_kcptun_version(file)
|
||||
if version == "" then
|
||||
sys.call("/bin/rm -rf /tmp/kcptun_extract.*")
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("The client file is not suitable for current device. Please reselect ARCH.")
|
||||
}
|
||||
end
|
||||
|
||||
local client_file = get_config_option("client_file", "/var/kcptun_client")
|
||||
local client_file_bak
|
||||
|
||||
if fs.access(client_file) then
|
||||
client_file_bak = client_file .. ".bak"
|
||||
exec("/bin/mv", { "-f", client_file, client_file_bak })
|
||||
end
|
||||
|
||||
local result = exec("/bin/mv", { "-f", file, client_file }, nil, command_timeout) == 0
|
||||
|
||||
if not result or not fs.access(client_file) then
|
||||
sys.call("/bin/rm -rf /tmp/kcptun_extract.*")
|
||||
if client_file_bak then
|
||||
exec("/bin/mv", { "-f", client_file_bak, client_file })
|
||||
end
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translatef("Can't move new file to path: %s", client_file)
|
||||
}
|
||||
end
|
||||
|
||||
exec("/bin/chmod", { "755", client_file })
|
||||
|
||||
if client_file_bak then
|
||||
exec("/bin/rm", { "-f", client_file_bak })
|
||||
end
|
||||
|
||||
sys.call("/bin/rm -rf /tmp/kcptun_extract.*")
|
||||
|
||||
uci:set("kcptun", "general", "client_file", client_file)
|
||||
uci:commit("kcptun")
|
||||
|
||||
return { code = 0 }
|
||||
end
|
||||
|
||||
function update_luci(url, save)
|
||||
if not url or url == "" then
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Download url is required.")
|
||||
}
|
||||
end
|
||||
|
||||
sys.call("/bin/rm -f /tmp/luci_kcptun.*.ipk")
|
||||
|
||||
local tmp_file = util.trim(util.exec("mktemp -u -t luci_kcptun.XXXXXX")) .. ".ipk"
|
||||
|
||||
local result = exec("/usr/bin/wget", {
|
||||
"-O", tmp_file, url, _unpack(wget_args) }, nil, command_timeout) == 0
|
||||
|
||||
if not result then
|
||||
exec("/bin/rm", { "-f", tmp_file })
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translatef("File download failed or timed out: %s", url)
|
||||
}
|
||||
end
|
||||
|
||||
local opkg_args = { "--force-downgrade", "--force-reinstall" }
|
||||
|
||||
if save ~= "true" then
|
||||
opkg_args[#opkg_args + 1] = "--force-maintainer"
|
||||
end
|
||||
|
||||
result = exec("/bin/opkg", { "install", tmp_file, _unpack(opkg_args) }) == 0
|
||||
|
||||
if not result then
|
||||
exec("/bin/rm", { "-f", tmp_file })
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Package update failed.")
|
||||
}
|
||||
end
|
||||
|
||||
exec("/bin/rm", { "-f", tmp_file })
|
||||
exec("/bin/rm", { "-rf", "/tmp/luci-indexcache", "/tmp/luci-modulecache" })
|
||||
|
||||
return { code = 0 }
|
||||
end
|
19
package/lean/luci-app-kcptun/luasrc/view/kcptun/button.htm
Normal file
19
package/lean/luci-app-kcptun/luasrc/view/kcptun/button.htm
Normal file
@ -0,0 +1,19 @@
|
||||
<%#
|
||||
Copyright 2017 Hsing-wang Liao <kuoruan@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%+cbi/valueheader%>
|
||||
<% if self:cfgvalue(section) ~= false then %>
|
||||
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" type="button"<%=
|
||||
attr("name", cbid) ..
|
||||
attr("id", self.id or cbid) ..
|
||||
attr("value", self.inputtitle or self.title) ..
|
||||
ifattr(self.btnclick, "onclick", self.btnclick) ..
|
||||
ifattr(self.placeholder, "placeholder")
|
||||
%> />
|
||||
<span id="<%=self.id or cbid%>-detail"></span>
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
<%+cbi/valuefooter%>
|
74
package/lean/luci-app-kcptun/luasrc/view/kcptun/log_view.htm
Normal file
74
package/lean/luci-app-kcptun/luasrc/view/kcptun/log_view.htm
Normal file
@ -0,0 +1,74 @@
|
||||
<%#
|
||||
Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% css = [[
|
||||
|
||||
#log_text {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
#log_text pre {
|
||||
word-break: break-all;
|
||||
margin: 0;
|
||||
}
|
||||
.description {
|
||||
background-color: #33ccff;
|
||||
}
|
||||
|
||||
]]
|
||||
%>
|
||||
|
||||
<%+header%>
|
||||
|
||||
<div class="cbi-map">
|
||||
<h2 name="content"><%:Kcptun%> - <%:Log Data%></h2>
|
||||
<fieldset class="cbi-section">
|
||||
<div class="cbi-section-descr">
|
||||
<input type="button" class="cbi-button" value="<%:Clear Log File%>" placeholder="<%:Clear Log File%>" onclick="return log_clear('client', this)" />
|
||||
</div>
|
||||
<fieldset class="cbi-section-node">
|
||||
<div id="log_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%></div>
|
||||
<div style="text-align:right"><small><%:Refresh every 5 seconds.%></small></div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function log_clear(type, btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Processing...%>';
|
||||
|
||||
(new XHR()).get('<%=luci.dispatcher.build_url("admin/services/kcptun/log/clear")%>/' + type,
|
||||
{ token: '<%=token%>' },
|
||||
function(x, json) {
|
||||
btn.disabled = false;
|
||||
btn.value = btn.placeholder;
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
(function(doc) {
|
||||
var log_elm = doc.getElementById('log_text');
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin/services/kcptun/log/data")%>', null,
|
||||
function(x, data) {
|
||||
if (log_elm && data) {
|
||||
log_elm.innerHTML = String.format(
|
||||
'<pre>%s%s%s%s</pre>',
|
||||
'<span class="description"><%:Last 50 lines of log file:%></span><br/><br/>',
|
||||
data.client || '<%:No log data.%>',
|
||||
'<br/><br/><span class="description"><%:Last 50 lines of syslog:%></span><br/><br/>',
|
||||
data.syslog || '<%:No log data.%>'
|
||||
);
|
||||
} else if (log_elm) {
|
||||
log_elm.innerHTML = '<strong><%:Error get log data.%></strong>';
|
||||
}
|
||||
}
|
||||
);
|
||||
}(document));
|
||||
//]]></script>
|
||||
|
||||
<%+footer%>
|
258
package/lean/luci-app-kcptun/luasrc/view/kcptun/status.htm
Normal file
258
package/lean/luci-app-kcptun/luasrc/view/kcptun/status.htm
Normal file
@ -0,0 +1,258 @@
|
||||
<%#
|
||||
Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%
|
||||
local kcp = require "luci.model.kcptun"
|
||||
local dsp = require "luci.dispatcher"
|
||||
|
||||
local client_file = kcp.get_config_option("client_file")
|
||||
local client_version = kcp.get_kcptun_version(client_file)
|
||||
local luci_version = kcp.get_luci_version()
|
||||
-%>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Running Status%></legend>
|
||||
<table width="100%" cellspacing="10" id="_kcptun-status_table">
|
||||
<tr>
|
||||
<td width="33%"><%:Client Version%></td>
|
||||
<td>
|
||||
<% if client_version == "" then -%>
|
||||
<em><%:Invalid Client File.%></em>
|
||||
<% else -%>
|
||||
<%=pcdata(client_version)%>
|
||||
<%- end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td width="33%"><%:Client Status%></td><td id="_kcptun-client_status"><em><%:Collecting data...%></em></td></tr>
|
||||
<% if luci_version ~= "" then -%>
|
||||
<tr><td width="33%"><%:LuCI Version%></td><td><%=pcdata(luci_version)%></td></tr>
|
||||
<% end -%>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var client_status = document.getElementById('_kcptun-client_status');
|
||||
XHR.poll(5, '<%=dsp.build_url("admin/services/kcptun/status")%>', null,
|
||||
function(x, json) {
|
||||
if (x && x.status == 200) {
|
||||
client_status.innerHTML = json.client ? '<%:Running%>' : '<%:Not Running%>';
|
||||
}
|
||||
});
|
||||
|
||||
function add_remove_page_notice(isAdd) {
|
||||
if (isAdd) {
|
||||
window.onbeforeunload = function(e) {
|
||||
var dialogText = '<%:Update in progress. Are you sure to close window?%>';
|
||||
e.returnValue = dialogText;
|
||||
return dialogText;
|
||||
};
|
||||
} else {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
}
|
||||
|
||||
function on_update_success(btn) {
|
||||
add_remove_page_notice(false);
|
||||
|
||||
var success = '<%:Update Success.%>';
|
||||
|
||||
if (btn) {
|
||||
btn.value = success;
|
||||
btn.placeholder = success;
|
||||
btn.disabled = true;
|
||||
}
|
||||
|
||||
alert(success);
|
||||
|
||||
window.setTimeout(function () {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function on_request_error(btn, json) {
|
||||
add_remove_page_notice(false);
|
||||
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.value = btn.placeholder;
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
alert(json.error);
|
||||
}
|
||||
}
|
||||
|
||||
function createVersionUrl(version, url) {
|
||||
var urlNode = '';
|
||||
if (url) {
|
||||
urlNode += '<a href="' + url + '" target="_blank">';
|
||||
}
|
||||
|
||||
urlNode += '<em style="color:red;">' + version + '</em>';
|
||||
|
||||
if (url) {
|
||||
urlNode += '</a>';
|
||||
}
|
||||
|
||||
return urlNode;
|
||||
}
|
||||
|
||||
var kcptun_info, luci_info;
|
||||
|
||||
var token_str = '<%=token%>';
|
||||
var arch_select;
|
||||
|
||||
function init_arch_select() {
|
||||
if (!arch_select) {
|
||||
arch_select = document.getElementById('cbid.kcptun.general.arch');
|
||||
|
||||
arch_select.addEventListener('change', function() {
|
||||
kcptun_info = null;
|
||||
var check_kcptun_btn = document.getElementById('_kcptun-check_kcptun');
|
||||
var text = '<%:Check Kcptun Update%>';
|
||||
check_kcptun_btn.value = text;
|
||||
check_kcptun_btn.placeholder = text;
|
||||
check_kcptun_btn.setAttribute('onclick', 'check_update(\'kcptun\', this);');
|
||||
|
||||
var detail = document.getElementById('_kcptun-check_kcptun-detail');
|
||||
detail.innerHTML = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function check_update(type, btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Processing...%>';
|
||||
|
||||
init_arch_select();
|
||||
add_remove_page_notice(true);
|
||||
|
||||
(new XHR()).get('<%=dsp.build_url("admin/services/kcptun/check")%>/' + type, {
|
||||
token: token_str,
|
||||
arch: arch_select ? arch_select.value : ""
|
||||
}, function(x, json) {
|
||||
if (x && x.status == 200) {
|
||||
var detailElm = document.getElementById(btn.id + '-detail');
|
||||
|
||||
if (json.code == 0) {
|
||||
add_remove_page_notice(false);
|
||||
|
||||
if (json.update) {
|
||||
eval(type + '_info = json');
|
||||
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Click to Update%>';
|
||||
btn.placeholder = '<%:Click to Update%>';
|
||||
|
||||
btn.setAttribute('onclick', 'do_' + type + '_update(this);');
|
||||
|
||||
if (detailElm) {
|
||||
detailElm.innerHTML = createVersionUrl(json.version, json.url.html);
|
||||
}
|
||||
} else {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:No Update Found%>';
|
||||
|
||||
if (detailElm) {
|
||||
detailElm.innerHTML = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (detailElm && json.html_url) {
|
||||
detailElm.innerHTML = createVersionUrl(json.version, json.html_url)
|
||||
}
|
||||
|
||||
on_request_error(btn, json);
|
||||
}
|
||||
} else {
|
||||
on_request_error(btn);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function do_kcptun_update(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Downloading...%>';
|
||||
|
||||
add_remove_page_notice(true);
|
||||
|
||||
var kcptun_update_url = '<%=dsp.build_url("admin/services/kcptun/update/kcptun")%>';
|
||||
|
||||
(new XHR()).get(kcptun_update_url, {
|
||||
token: token_str,
|
||||
url: kcptun_info ? kcptun_info.url.download : ''
|
||||
}, function (x, json) {
|
||||
if (x && x.status == 200) {
|
||||
if (json.code == 0) {
|
||||
btn.value = '<%:Extracting...%>';
|
||||
|
||||
(new XHR()).get(kcptun_update_url, {
|
||||
token: token_str,
|
||||
task: "extract",
|
||||
file: json.file,
|
||||
subfix: kcptun_info ? kcptun_info.type : ''
|
||||
}, function (x, json) {
|
||||
if (x && x.status == 200) {
|
||||
if (json.code == 0) {
|
||||
btn.value = '<%:Moving...%>';
|
||||
|
||||
(new XHR()).get(kcptun_update_url, {
|
||||
token: token_str,
|
||||
task: "move",
|
||||
file: json.file
|
||||
}, function (x, json) {
|
||||
if (x && x.status == 200) {
|
||||
if (json.code == 0) {
|
||||
on_update_success(btn);
|
||||
} else {
|
||||
on_request_error(btn, json);
|
||||
}
|
||||
} else {
|
||||
on_request_error(btn);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
on_request_error(btn, json);
|
||||
}
|
||||
} else {
|
||||
on_request_error(btn);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
on_request_error(btn, json);
|
||||
}
|
||||
} else {
|
||||
on_request_error(btn);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function do_luci_update(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Processing...%>';
|
||||
|
||||
add_remove_page_notice(true);
|
||||
|
||||
var save_config = document.getElementById('cbid.kcptun.general.save_config');
|
||||
|
||||
(new XHR()).get('<%=dsp.build_url("admin/services/kcptun/update/luci")%>', {
|
||||
token: token_str,
|
||||
url: luci_info ? luci_info.url.luci : '',
|
||||
save: save_config ? save_config.checked : false
|
||||
}, function(x, json) {
|
||||
btn.disabled = false;
|
||||
btn.value = btn.placeholder;
|
||||
if (x && x.status == 200) {
|
||||
if (json.code == 0) {
|
||||
on_update_success(btn);
|
||||
} else {
|
||||
on_request_error(btn, json);
|
||||
}
|
||||
} else {
|
||||
on_request_error(btn);
|
||||
}
|
||||
});
|
||||
}
|
||||
//]]></script>
|
346
package/lean/luci-app-kcptun/po/templates/kcptun.pot
Normal file
346
package/lean/luci-app-kcptun/po/templates/kcptun.pot
Normal file
@ -0,0 +1,346 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
msgid "2nd ACK"
|
||||
msgstr ""
|
||||
|
||||
msgid "Alias"
|
||||
msgstr ""
|
||||
|
||||
msgid "Auto"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"Auto expiration time(in seconds) for a single UDP connection, 0 to disable."
|
||||
msgstr ""
|
||||
|
||||
msgid "CPU Architecture"
|
||||
msgstr ""
|
||||
|
||||
msgid "Can't determine ARCH, or ARCH not supported. Please select manually."
|
||||
msgstr ""
|
||||
|
||||
msgid "Can't find client in file: %s"
|
||||
msgstr ""
|
||||
|
||||
msgid "Can't move new file to path: %s"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check Kcptun Update"
|
||||
msgstr ""
|
||||
|
||||
msgid "Check LuCI Update"
|
||||
msgstr ""
|
||||
|
||||
msgid "Clear Log File"
|
||||
msgstr ""
|
||||
|
||||
msgid "Click to Update"
|
||||
msgstr ""
|
||||
|
||||
msgid "Client File"
|
||||
msgstr ""
|
||||
|
||||
msgid "Client Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Client Version"
|
||||
msgstr ""
|
||||
|
||||
msgid "Client file is required."
|
||||
msgstr ""
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr ""
|
||||
|
||||
msgid "DSCP(6bit)"
|
||||
msgstr ""
|
||||
|
||||
msgid "Disable"
|
||||
msgstr ""
|
||||
|
||||
msgid "Disable Compression"
|
||||
msgstr ""
|
||||
|
||||
msgid "Disable Compression?"
|
||||
msgstr ""
|
||||
|
||||
msgid "Download url is required."
|
||||
msgstr ""
|
||||
|
||||
msgid "Downloading..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Edit Server"
|
||||
msgstr ""
|
||||
|
||||
msgid "Embedded Mode"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enable Logging"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enable nodelay Mode."
|
||||
msgstr ""
|
||||
|
||||
msgid "Encrypt Method"
|
||||
msgstr ""
|
||||
|
||||
msgid "Error get log data."
|
||||
msgstr ""
|
||||
|
||||
msgid "Extracting..."
|
||||
msgstr ""
|
||||
|
||||
msgid "False"
|
||||
msgstr ""
|
||||
|
||||
msgid "File download failed or timed out: %s"
|
||||
msgstr ""
|
||||
|
||||
msgid "File path required."
|
||||
msgstr ""
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "Get remote version info failed."
|
||||
msgstr ""
|
||||
|
||||
msgid "How long an expired connection can live(in sec), -1 to disable."
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid Client File."
|
||||
msgstr ""
|
||||
|
||||
msgid "Kcptun"
|
||||
msgstr ""
|
||||
|
||||
msgid "Kcptun Client"
|
||||
msgstr ""
|
||||
|
||||
msgid "Key"
|
||||
msgstr ""
|
||||
|
||||
msgid "Last 50 lines of log file:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Last 50 lines of syslog:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Listen Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "Loading"
|
||||
msgstr ""
|
||||
|
||||
msgid "Local Listen Host"
|
||||
msgstr ""
|
||||
|
||||
msgid "Local Listen Port."
|
||||
msgstr ""
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr ""
|
||||
|
||||
msgid "Local listen host."
|
||||
msgstr ""
|
||||
|
||||
msgid "Log"
|
||||
msgstr ""
|
||||
|
||||
msgid "Log Data"
|
||||
msgstr ""
|
||||
|
||||
msgid "Log Folder"
|
||||
msgstr ""
|
||||
|
||||
msgid "LuCI Version"
|
||||
msgstr ""
|
||||
|
||||
msgid "Make sure that the 'Client File' dictionary has enough space."
|
||||
msgstr ""
|
||||
|
||||
msgid "Maximum transmission unit of UDP packets."
|
||||
msgstr ""
|
||||
|
||||
msgid "Moving..."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"NAT keepalive interval to prevent your router from removing port mapping, "
|
||||
"default unit is seconds."
|
||||
msgstr ""
|
||||
|
||||
msgid "New version found, but failed to get new version download url."
|
||||
msgstr ""
|
||||
|
||||
msgid "No Update Found"
|
||||
msgstr ""
|
||||
|
||||
msgid "No log data."
|
||||
msgstr ""
|
||||
|
||||
msgid "None"
|
||||
msgstr ""
|
||||
|
||||
msgid "Not Running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Number of UDP connections to server."
|
||||
msgstr ""
|
||||
|
||||
msgid "Off"
|
||||
msgstr ""
|
||||
|
||||
msgid "On"
|
||||
msgstr ""
|
||||
|
||||
msgid "Package update failed."
|
||||
msgstr ""
|
||||
|
||||
msgid "Pre-shared secret for client and server."
|
||||
msgstr ""
|
||||
|
||||
msgid "Processing..."
|
||||
msgstr ""
|
||||
|
||||
msgid "Receive Window Size(num of packets)."
|
||||
msgstr ""
|
||||
|
||||
msgid "Reed-solomon Erasure Coding - datashard."
|
||||
msgstr ""
|
||||
|
||||
msgid "Reed-solomon Erasure Coding - parityshard."
|
||||
msgstr ""
|
||||
|
||||
msgid "Refresh every 5 seconds."
|
||||
msgstr ""
|
||||
|
||||
msgid "Run Daemon as User"
|
||||
msgstr ""
|
||||
|
||||
msgid "Running"
|
||||
msgstr ""
|
||||
|
||||
msgid "Running Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "SNMP collect period, in seconds"
|
||||
msgstr ""
|
||||
|
||||
msgid "Save Config File"
|
||||
msgstr ""
|
||||
|
||||
msgid "Save config file while upgrade LuCI."
|
||||
msgstr ""
|
||||
|
||||
msgid "Send Window Size(num of packets)."
|
||||
msgstr ""
|
||||
|
||||
msgid "Send/secv buffer size of udp sockets, default unit is MB."
|
||||
msgstr ""
|
||||
|
||||
msgid "Server"
|
||||
msgstr ""
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "Server List"
|
||||
msgstr ""
|
||||
|
||||
msgid "Server Manage"
|
||||
msgstr ""
|
||||
|
||||
msgid "Server Port"
|
||||
msgstr ""
|
||||
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"The ARCH for checking updates. Note: Make sure OpenWrt/LEDE 'MIPS FPU "
|
||||
"Emulator' is enabled on MIPS/MIPSLE devices."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"The client file is not suitable for current device. Please reselect ARCH."
|
||||
msgstr ""
|
||||
|
||||
msgid "True"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Success."
|
||||
msgstr ""
|
||||
|
||||
msgid "Update in progress. Are you sure to close window?"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"You may need to reload current page after update LuCI. Note that translation "
|
||||
"will not be updated."
|
||||
msgstr ""
|
||||
|
||||
msgid "acknodelay"
|
||||
msgstr ""
|
||||
|
||||
msgid "autoexpire"
|
||||
msgstr ""
|
||||
|
||||
msgid "conn"
|
||||
msgstr ""
|
||||
|
||||
msgid "crypt"
|
||||
msgstr ""
|
||||
|
||||
msgid "datashard"
|
||||
msgstr ""
|
||||
|
||||
msgid "dscp"
|
||||
msgstr ""
|
||||
|
||||
msgid "interval"
|
||||
msgstr ""
|
||||
|
||||
msgid "keepalive"
|
||||
msgstr ""
|
||||
|
||||
msgid "mode"
|
||||
msgstr ""
|
||||
|
||||
msgid "mtu"
|
||||
msgstr ""
|
||||
|
||||
msgid "nc"
|
||||
msgstr ""
|
||||
|
||||
msgid "nocomp"
|
||||
msgstr ""
|
||||
|
||||
msgid "nodelay"
|
||||
msgstr ""
|
||||
|
||||
msgid "optional"
|
||||
msgstr ""
|
||||
|
||||
msgid "parityshard"
|
||||
msgstr ""
|
||||
|
||||
msgid "rcvwnd"
|
||||
msgstr ""
|
||||
|
||||
msgid "resend"
|
||||
msgstr ""
|
||||
|
||||
msgid "scavengettl"
|
||||
msgstr ""
|
||||
|
||||
msgid "sndwnd"
|
||||
msgstr ""
|
||||
|
||||
msgid "snmpperiod"
|
||||
msgstr ""
|
||||
|
||||
msgid "sockbuf"
|
||||
msgstr ""
|
348
package/lean/luci-app-kcptun/po/zh-cn/kcptun.po
Normal file
348
package/lean/luci-app-kcptun/po/zh-cn/kcptun.po
Normal file
@ -0,0 +1,348 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "2nd ACK"
|
||||
msgstr "2次 ACK 跨越重传"
|
||||
|
||||
msgid "Alias"
|
||||
msgstr "别名"
|
||||
|
||||
msgid "Auto"
|
||||
msgstr "自动"
|
||||
|
||||
msgid ""
|
||||
"Auto expiration time(in seconds) for a single UDP connection, 0 to disable."
|
||||
msgstr "单个 UDP 连接的自动过期时间(秒),设置 0 来禁用"
|
||||
|
||||
msgid "CPU Architecture"
|
||||
msgstr "CPU 架构"
|
||||
|
||||
msgid "Can't determine ARCH, or ARCH not supported. Please select manually."
|
||||
msgstr "无法自动确定 ARCH,或者不支持该 ARCH,请手动重新选择。"
|
||||
|
||||
msgid "Can't find client in file: %s"
|
||||
msgstr "无法在文件中找到客户端:%s"
|
||||
|
||||
msgid "Can't move new file to path: %s"
|
||||
msgstr "无法移动新文件到:%s"
|
||||
|
||||
msgid "Check Kcptun Update"
|
||||
msgstr "检查 Kcptun 更新"
|
||||
|
||||
msgid "Check LuCI Update"
|
||||
msgstr "检查 LuCI 更新"
|
||||
|
||||
msgid "Clear Log File"
|
||||
msgstr "清理日志文件"
|
||||
|
||||
msgid "Click to Update"
|
||||
msgstr "点击更新"
|
||||
|
||||
msgid "Client File"
|
||||
msgstr "客户端文件"
|
||||
|
||||
msgid "Client Status"
|
||||
msgstr "客户端状态"
|
||||
|
||||
msgid "Client Version"
|
||||
msgstr "客户端版本"
|
||||
|
||||
msgid "Client file is required."
|
||||
msgstr "请指定客户端文件。"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "正在收集数据..."
|
||||
|
||||
msgid "DSCP(6bit)"
|
||||
msgstr "DSCP(6bit)"
|
||||
|
||||
msgid "Disable"
|
||||
msgstr "禁用"
|
||||
|
||||
msgid "Disable Compression"
|
||||
msgstr "禁用压缩"
|
||||
|
||||
msgid "Disable Compression?"
|
||||
msgstr "是否禁用压缩?"
|
||||
|
||||
msgid "Download url is required."
|
||||
msgstr "请指定下载链接。"
|
||||
|
||||
msgid "Downloading..."
|
||||
msgstr "正在下载..."
|
||||
|
||||
msgid "Edit Server"
|
||||
msgstr "编辑服务端"
|
||||
|
||||
msgid "Embedded Mode"
|
||||
msgstr "内置模式"
|
||||
|
||||
msgid "Enable Logging"
|
||||
msgstr "启用日志记录"
|
||||
|
||||
msgid "Enable nodelay Mode."
|
||||
msgstr "启用 nodelay 模式"
|
||||
|
||||
msgid "Encrypt Method"
|
||||
msgstr "加密方式"
|
||||
|
||||
msgid "Error get log data."
|
||||
msgstr "获取日志数据失败。"
|
||||
|
||||
msgid "Extracting..."
|
||||
msgstr "正在解压..."
|
||||
|
||||
msgid "False"
|
||||
msgstr "否"
|
||||
|
||||
msgid "File download failed or timed out: %s"
|
||||
msgstr "文件下载失败或超时:%s"
|
||||
|
||||
msgid "File path required."
|
||||
msgstr "请指定文件路径。"
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Get remote version info failed."
|
||||
msgstr "获取远程版本信息失败。"
|
||||
|
||||
msgid "How long an expired connection can live(in sec), -1 to disable."
|
||||
msgstr "过期连接保留多长时间(秒),设置 -1 来禁用"
|
||||
|
||||
msgid "Invalid Client File."
|
||||
msgstr "客户端文件配置有误"
|
||||
|
||||
msgid "Kcptun"
|
||||
msgstr ""
|
||||
|
||||
msgid "Kcptun Client"
|
||||
msgstr "Kcptun 客户端"
|
||||
|
||||
msgid "Key"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "Last 50 lines of log file:"
|
||||
msgstr "日志文件的最新 50 行:"
|
||||
|
||||
msgid "Last 50 lines of syslog:"
|
||||
msgstr "系统日志的最新 50 行:"
|
||||
|
||||
msgid "Listen Address"
|
||||
msgstr "监听地址"
|
||||
|
||||
msgid "Loading"
|
||||
msgstr "正在加载..."
|
||||
|
||||
msgid "Local Listen Host"
|
||||
msgstr "本地监听地址"
|
||||
|
||||
msgid "Local Listen Port."
|
||||
msgstr "本地监听端口"
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr "本地端口"
|
||||
|
||||
msgid "Local listen host."
|
||||
msgstr "本地监听主机"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Log Data"
|
||||
msgstr "日志数据"
|
||||
|
||||
msgid "Log Folder"
|
||||
msgstr "日志文件夹"
|
||||
|
||||
msgid "LuCI Version"
|
||||
msgstr "LuCI 版本"
|
||||
|
||||
msgid "Make sure that the 'Client File' dictionary has enough space."
|
||||
msgstr "请确保“客户端文件”所在的文件夹具有足够的空间。"
|
||||
|
||||
msgid "Maximum transmission unit of UDP packets."
|
||||
msgstr "UDP数据包的最大传输单元"
|
||||
|
||||
msgid "Moving..."
|
||||
msgstr "正在移动..."
|
||||
|
||||
msgid ""
|
||||
"NAT keepalive interval to prevent your router from removing port mapping, "
|
||||
"default unit is seconds."
|
||||
msgstr "NAT Keepalive 包间隔时间(秒), 防止路由器删除端口映射"
|
||||
|
||||
msgid "New version found, but failed to get new version download url."
|
||||
msgstr "发现新版本,但是获取下载地址失败。"
|
||||
|
||||
msgid "No Update Found"
|
||||
msgstr "未发现更新"
|
||||
|
||||
msgid "No log data."
|
||||
msgstr "无日志数据。"
|
||||
|
||||
msgid "None"
|
||||
msgstr "无"
|
||||
|
||||
msgid "Not Running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Number of UDP connections to server."
|
||||
msgstr "到服务端的UDP连接数量"
|
||||
|
||||
msgid "Off"
|
||||
msgstr "关闭"
|
||||
|
||||
msgid "On"
|
||||
msgstr "开启"
|
||||
|
||||
msgid "Package update failed."
|
||||
msgstr "软件包升级失败。"
|
||||
|
||||
msgid "Pre-shared secret for client and server."
|
||||
msgstr "客户端和服务端的通信密码"
|
||||
|
||||
msgid "Processing..."
|
||||
msgstr "正在操作..."
|
||||
|
||||
msgid "Receive Window Size(num of packets)."
|
||||
msgstr "接收窗口大小 (数据包数量)"
|
||||
|
||||
msgid "Reed-solomon Erasure Coding - datashard."
|
||||
msgstr "前向纠错 - datashard"
|
||||
|
||||
msgid "Reed-solomon Erasure Coding - parityshard."
|
||||
msgstr "前向纠错 - parityshard"
|
||||
|
||||
msgid "Refresh every 5 seconds."
|
||||
msgstr "每 5 秒刷新。"
|
||||
|
||||
msgid "Run Daemon as User"
|
||||
msgstr "以该用户启动"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Running Status"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "SNMP collect period, in seconds"
|
||||
msgstr "SNMP采集周期(秒)"
|
||||
|
||||
msgid "Save Config File"
|
||||
msgstr "保留配置文件"
|
||||
|
||||
msgid "Save config file while upgrade LuCI."
|
||||
msgstr "在更新 LuCI 时保留配置文件"
|
||||
|
||||
msgid "Send Window Size(num of packets)."
|
||||
msgstr "发送窗口大小 (数据包数量)"
|
||||
|
||||
msgid "Send/secv buffer size of udp sockets, default unit is MB."
|
||||
msgstr "发送/接收UDP数据包的缓冲区大小(MB)"
|
||||
|
||||
msgid "Server"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "Server List"
|
||||
msgstr "服务端列表"
|
||||
|
||||
msgid "Server Manage"
|
||||
msgstr "服务端管理"
|
||||
|
||||
msgid "Server Port"
|
||||
msgstr "服务端端口"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
msgid ""
|
||||
"The ARCH for checking updates. Note: Make sure OpenWrt/LEDE 'MIPS FPU "
|
||||
"Emulator' is enabled on MIPS/MIPSLE devices."
|
||||
msgstr ""
|
||||
"用于检查更新的 ARCH。注意: 在 MIPS/MIPSLE 设备上,请确保 OpenWrt/LEDE 的 "
|
||||
"'MIPS FPU Emulator' 已经启用。"
|
||||
|
||||
msgid ""
|
||||
"The client file is not suitable for current device. Please reselect ARCH."
|
||||
msgstr "客户端文件不适用于当前设备,请重新选择 ARCH。"
|
||||
|
||||
msgid "True"
|
||||
msgstr "是"
|
||||
|
||||
msgid "Update Success."
|
||||
msgstr "更新成功!"
|
||||
|
||||
msgid "Update in progress. Are you sure to close window?"
|
||||
msgstr "正在更新,确定关闭窗口?"
|
||||
|
||||
msgid ""
|
||||
"You may need to reload current page after update LuCI. Note that translation "
|
||||
"will not be updated."
|
||||
msgstr "更新 LuCI 之后你可能需要手动刷新当前页面。注意:翻译不会被更新"
|
||||
|
||||
msgid "acknodelay"
|
||||
msgstr ""
|
||||
|
||||
msgid "autoexpire"
|
||||
msgstr ""
|
||||
|
||||
msgid "conn"
|
||||
msgstr ""
|
||||
|
||||
msgid "crypt"
|
||||
msgstr ""
|
||||
|
||||
msgid "datashard"
|
||||
msgstr ""
|
||||
|
||||
msgid "dscp"
|
||||
msgstr ""
|
||||
|
||||
msgid "interval"
|
||||
msgstr ""
|
||||
|
||||
msgid "keepalive"
|
||||
msgstr ""
|
||||
|
||||
msgid "mode"
|
||||
msgstr ""
|
||||
|
||||
msgid "mtu"
|
||||
msgstr ""
|
||||
|
||||
msgid "nc"
|
||||
msgstr ""
|
||||
|
||||
msgid "nocomp"
|
||||
msgstr ""
|
||||
|
||||
msgid "nodelay"
|
||||
msgstr ""
|
||||
|
||||
msgid "optional"
|
||||
msgstr "可选"
|
||||
|
||||
msgid "parityshard"
|
||||
msgstr ""
|
||||
|
||||
msgid "rcvwnd"
|
||||
msgstr ""
|
||||
|
||||
msgid "resend"
|
||||
msgstr ""
|
||||
|
||||
msgid "scavengettl"
|
||||
msgstr ""
|
||||
|
||||
msgid "sndwnd"
|
||||
msgstr ""
|
||||
|
||||
msgid "snmpperiod"
|
||||
msgstr ""
|
||||
|
||||
msgid "sockbuf"
|
||||
msgstr ""
|
15
package/lean/luci-app-kcptun/root/etc/config/kcptun
Normal file
15
package/lean/luci-app-kcptun/root/etc/config/kcptun
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
config general 'general'
|
||||
option server ''
|
||||
option client_file '/var/kcptun_client'
|
||||
option daemon_user 'root'
|
||||
option enable_logging '1'
|
||||
|
||||
config servers 'default'
|
||||
option server_addr ''
|
||||
option server_port '29900'
|
||||
option listen_addr '0.0.0.0'
|
||||
option listen_port '12948'
|
||||
option crypt 'aes'
|
||||
option mode 'fast'
|
||||
option nocomp 'false'
|
244
package/lean/luci-app-kcptun/root/etc/init.d/kcptun
Executable file
244
package/lean/luci-app-kcptun/root/etc/init.d/kcptun
Executable file
@ -0,0 +1,244 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright 2016-2017 Xingwang Liao <kuoruan@gmail.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
KCPTUN=kcptun
|
||||
CONFIG_FOLDER=/var/etc/$KCPTUN
|
||||
|
||||
if [ -r /usr/share/libubox/jshn.sh ]; then
|
||||
. /usr/share/libubox/jshn.sh
|
||||
elif [ -r /lib/functions/jshn.sh ]; then
|
||||
. /lib/functions/jshn.sh
|
||||
else
|
||||
logger -p daemon.err -t "$KCPTUN" \
|
||||
"Package required: jshn."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_log() {
|
||||
local level="$1"
|
||||
local msg="$2"
|
||||
|
||||
logger -p "daemon.${level}" -t "$KCPTUN" "$msg"
|
||||
}
|
||||
|
||||
gen_client_config_file() {
|
||||
local config_file="$1"
|
||||
|
||||
json_init
|
||||
json_add_string "remoteaddr" "${server_addr}:${server_port}"
|
||||
json_add_string "localaddr" "${listen_addr}:${listen_port}"
|
||||
|
||||
add_configs() {
|
||||
local type="$1"; shift
|
||||
local k v
|
||||
|
||||
for k in "$@"; do
|
||||
v="$(eval echo "\$$k")"
|
||||
|
||||
if [ -n "$v" ]; then
|
||||
if [ "$type" = "string" ]; then
|
||||
json_add_string "$k" "$v"
|
||||
elif [ "$type" = "int" ]; then
|
||||
json_add_int "$k" "$v"
|
||||
elif [ "$type" = "boolean" ]; then
|
||||
if [ "$v" = "true" ]; then
|
||||
json_add_boolean "$k" "1"
|
||||
else
|
||||
json_add_boolean "$k" "0"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
add_configs "string" key crypt mode
|
||||
add_configs "int" conn autoexpire mtu sndwnd rcvwnd datashard parityshard dscp \
|
||||
nodelay interval resend nc sockbuf keepalive scavengettl snmpperiod
|
||||
add_configs "boolean" nocomp acknodelay
|
||||
|
||||
if [ -n "$log_file" ]; then
|
||||
json_add_string "log" "$log_file"
|
||||
fi
|
||||
|
||||
json_close_object
|
||||
|
||||
json_dump -i >"$config_file"
|
||||
}
|
||||
|
||||
setup_iptables_chain() {
|
||||
if ! ( iptables -nL "$KCPTUN" >/dev/null 2>&1 ); then
|
||||
iptables -N "$KCPTUN" 2>/dev/null
|
||||
fi
|
||||
|
||||
iptables -C OUTPUT -j "$KCPTUN" 2>/dev/null || \
|
||||
iptables -A OUTPUT -j "$KCPTUN" 2>/dev/null
|
||||
iptables -C INPUT -j "$KCPTUN" 2>/dev/null || \
|
||||
iptables -A INPUT -j "$KCPTUN" 2>/dev/null
|
||||
}
|
||||
|
||||
clear_iptables_chain() {
|
||||
iptables -F "$KCPTUN" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
add_iptables_rule() {
|
||||
local port="$1"
|
||||
local type="$2"
|
||||
|
||||
if [ "$type" = "client" ]; then
|
||||
( iptables -C "$KCPTUN" -p tcp --dport "$port" -m comment \
|
||||
--comment "$type" -j ACCEPT 2>/dev/null ) && return 0
|
||||
|
||||
iptables -A "$KCPTUN" -p tcp --dport "$port" -m comment \
|
||||
--comment "$type" -j ACCEPT 2>/dev/null
|
||||
elif [ "$type" = "server" ]; then
|
||||
( iptables -C "$KCPTUN" -p udp --dport "$port" -m comment \
|
||||
--comment "$type" -j ACCEPT 2>/dev/null ) && return 0
|
||||
|
||||
iptables -A "$KCPTUN" -p udp --dport "$port" -m comment \
|
||||
--comment "$type" -j ACCEPT 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
validate_config_section() {
|
||||
uci_validate_section "$KCPTUN" general "$1" \
|
||||
'server:uciname' \
|
||||
'client_file:string' \
|
||||
'daemon_user:string:root' \
|
||||
'enable_logging:bool:0' \
|
||||
'log_folder:directory:/var/log/kcptun'
|
||||
}
|
||||
|
||||
validate_server_section() {
|
||||
uci_validate_section "$KCPTUN" servers "$1" \
|
||||
'server_addr:host' \
|
||||
'server_port:port:29900' \
|
||||
'listen_addr:host:0.0.0.0' \
|
||||
'listen_port:port:12948' \
|
||||
'key:string' \
|
||||
'crypt:string:aes' \
|
||||
'mode:or("normal","fast","fast2","fast3","manual"):fast' \
|
||||
'conn:min(1)' \
|
||||
'autoexpire:uinteger' \
|
||||
'scavengettl:min(-1)' \
|
||||
'mtu:range(64,9200)' \
|
||||
'sndwnd:min(1)' \
|
||||
'rcvwnd:min(1)' \
|
||||
'datashard:uinteger' \
|
||||
'parityshard:uinteger' \
|
||||
'dscp:uinteger' \
|
||||
'nocomp:or("true", "false")' \
|
||||
'nodelay:bool' \
|
||||
'interval:uinteger' \
|
||||
'resend:range(0,2)' \
|
||||
'nc:bool' \
|
||||
'acknodelay:or("true", "false")' \
|
||||
'sockbuf:uinteger' \
|
||||
'keepalive:uinteger' \
|
||||
'snmpperiod:min(1)'
|
||||
}
|
||||
|
||||
validate_client_file() {
|
||||
local file="$1"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
[ -x "$file" ] || chmod 755 "$file"
|
||||
|
||||
( $file -v 2>/dev/null | grep -q "$KCPTUN" )
|
||||
}
|
||||
|
||||
start_kcptun_instance() {
|
||||
local section="$1"
|
||||
|
||||
if ! validate_config_section "$section" ; then
|
||||
_log "err" "Config validate failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$server" ] || [ "$server" = "nil" ]; then
|
||||
_log "info" "No server selected, Client will stop."
|
||||
return 0
|
||||
elif ! validate_server_section "$server"; then
|
||||
_log "err" "Server config validation failed."
|
||||
return 1
|
||||
elif [ -z "$server_addr" ] || [ -z "$listen_port" ]; then
|
||||
_log "err" "Server config validation failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$client_file" ]; then
|
||||
_log "err" "Please set client file path, or use auto download."
|
||||
return 1;
|
||||
elif ! validate_client_file "$client_file"; then
|
||||
_log "err" "Client file validation failed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
is_ipv6_address() {
|
||||
echo "$1" | grep -q ":"
|
||||
}
|
||||
|
||||
is_ipv6_address "$server_addr" && server_addr="[${server_addr}]"
|
||||
is_ipv6_address "$listen_addr" && listen_addr="[${listen_addr}]"
|
||||
|
||||
[ -d "$CONFIG_FOLDER" ] || mkdir -p "$CONFIG_FOLDER"
|
||||
|
||||
log_file=""
|
||||
if [ "$enable_logging" = "1" ]; then
|
||||
mkdir -p "$log_folder"
|
||||
chown -R "$daemon_user" "$log_folder"
|
||||
log_file="${log_folder}/client.${section}.log"
|
||||
fi
|
||||
|
||||
local config_file=${CONFIG_FOLDER}/client.${section}.json
|
||||
|
||||
if ! ( gen_client_config_file "$config_file" ); then
|
||||
_log "err" "Can't create config file".
|
||||
return 1
|
||||
fi
|
||||
|
||||
add_iptables_rule "$listen_port" "client"
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$client_file"
|
||||
procd_append_param command -c "$config_file"
|
||||
procd_set_param respawn
|
||||
procd_set_param user "$daemon_user"
|
||||
procd_set_param file "$config_file"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$KCPTUN"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
clear_iptables_chain
|
||||
setup_iptables_chain
|
||||
|
||||
config_load "$KCPTUN"
|
||||
config_foreach start_kcptun_instance "general"
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
clear_iptables_chain
|
||||
}
|
25
package/lean/luci-app-kcptun/root/etc/uci-defaults/40_luci-kcptun
Executable file
25
package/lean/luci-app-kcptun/root/etc/uci-defaults/40_luci-kcptun
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@kcptun[-1]
|
||||
add ucitrack kcptun
|
||||
set ucitrack.@kcptun[-1].init=kcptun
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
general=$(uci -q get kcptun.@general[-1])
|
||||
|
||||
if [ -z "$general" ]; then
|
||||
uci -q add kcptun general
|
||||
fi
|
||||
|
||||
if [ ."$general" != ."general" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
rename kcptun.@general[-1]="general"
|
||||
set kcptun.general.server=""
|
||||
commit kcptun
|
||||
EOF
|
||||
fi
|
||||
|
||||
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache
|
||||
exit 0
|
17
package/lean/luci-app-kuainiao/Makefile
Normal file
17
package/lean/luci-app-kuainiao/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Kuainiao
|
||||
LUCI_DEPENDS:=+kmod-ppp +openssl-util +wget +kmod-mppe
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
@ -0,0 +1,34 @@
|
||||
module("luci.controller.kuainiao", package.seeall)
|
||||
|
||||
function index()
|
||||
local fs = luci.fs or nixio.fs
|
||||
if not fs.access("/etc/config/kuainiao") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "kuainiao"}, cbi("kuainiao"), _("Kuai Niao"),201)
|
||||
page.dependent = true
|
||||
entry({"admin","services","kuainiao","status"},call("kuainiao_status")).leaf=true
|
||||
entry({"admin","services","kuainiao","dwonstatus"},call("down_status")).leaf=true
|
||||
entry({"admin","services","kuainiao","upstatus"},call("up_status")).leaf=true
|
||||
end
|
||||
|
||||
function kuainiao_status()
|
||||
local e={}
|
||||
e.running=luci.sys.exec("ps |grep -v grep |grep -w '/usr/bin/kuainiao' ")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function up_status()
|
||||
local e={}
|
||||
e.upstatus=luci.sys.exec("cat /usr/share/kuainiao/kuainiao_up_state")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
function down_status()
|
||||
local e={}
|
||||
e.dwonstatus=luci.sys.exec("cat /usr/share/kuainiao/kuainiao_down_state")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
59
package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua
Normal file
59
package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua
Normal file
@ -0,0 +1,59 @@
|
||||
#fork from https://github.com/zz090923610/thunder-fastNiao,thanks to zz090923610
|
||||
require("luci.sys")
|
||||
require("luci.sys.zoneinfo")
|
||||
require("luci.config")
|
||||
local fs = require "nixio.fs"
|
||||
local ut = require "luci.util"
|
||||
local o=require"luci.model.network".init()
|
||||
local sys = require "luci.sys"
|
||||
local m,t,e
|
||||
m = Map("kuainiao", translate("迅雷快鸟"),translate("迅雷快鸟是迅雷联合宽带运营商推出的一款致力于帮助用户解决宽带低、网速慢、上网体验差的专业级宽带加速软件。"))
|
||||
m:section(SimpleSection).template = "kuainiao/kuainiao_status"
|
||||
s = m:section(NamedSection, "base", "kuainiao", translate("首次使用请填写完帐号密码保存提交一次,之后再启用。"))
|
||||
s.addremove = false
|
||||
s:tab("base",translate("Basic Settings"))
|
||||
s:tab("log",translate("快鸟日志"))
|
||||
enabled = s:taboption("base",Flag, "enabled", translate("Enable"))
|
||||
enabled.default=0
|
||||
enabled.rmempty = false
|
||||
enable_down = s:taboption("base",Flag, "enable_down", translate("开启下行加速"))
|
||||
enable_down.default=1
|
||||
enabled.rmempty = false
|
||||
enable_down:depends("enabled",1)
|
||||
|
||||
enable_up = s:taboption("base",Flag, "enable_up", translate("开启上行加速"))
|
||||
enable_up.default=0
|
||||
enabled.rmempty = false
|
||||
enable_up:depends("enabled",1)
|
||||
local a
|
||||
speed_wan=s:taboption("base",ListValue,"speed_wan",translate("指定加速的接口"))
|
||||
for a,s in ipairs(o:get_networks())do
|
||||
if s:name()~="loopback" and s:name()~="lan" then speed_wan:value(s:name())end
|
||||
end
|
||||
username = s:taboption("base",Value, "kuainiao_name", translate("迅雷快鸟帐号"))
|
||||
username.datatype = "minlength(1)"
|
||||
username.rmempty = false
|
||||
password = s:taboption("base",Value, "kuainiao_passwd", translate("迅雷快鸟密码"))
|
||||
password.password = true
|
||||
password.datatype = "minlength(1)"
|
||||
password.rmempty = false
|
||||
kuainiao_config_pwd = s:taboption("base",Value, "kuainiao_config_pwd", translate("加密后密码(自动生成,勿修改)"))
|
||||
kuainiao_config_pwd.password = true
|
||||
kuainiao_config_pwd.datatype = "minlength(1)"
|
||||
kuainiao_config_pwd.rmempty = true
|
||||
--kuainiao_config_pwd.readonly=true
|
||||
log=s:taboption("log",TextValue,"log")
|
||||
log.rows=26
|
||||
log.wrap="off"
|
||||
log.readonly=true
|
||||
log.cfgvalue=function(t,t)
|
||||
return nixio.fs.readfile("/var/log/kuainiao.log")or""
|
||||
end
|
||||
log.write=function(log,log,log)
|
||||
end
|
||||
m:section(SimpleSection).template = "kuainiao/kuainiao_rsa"
|
||||
local apply = luci.http.formvalue("cbi.apply")
|
||||
if apply then
|
||||
io.popen("luci_kuainiao_apply")
|
||||
end
|
||||
return m
|
@ -0,0 +1,25 @@
|
||||
<%#
|
||||
Copyright (C) 2017 Jian Chang <aa65535@live.com>
|
||||
Licensed to the public under the GNU General Public License v3.
|
||||
-%>
|
||||
<script type="text/javascript" src="<%=resource%>/md5.js"></script>
|
||||
<script type="text/javascript" src="<%=resource%>/sha1.js"></script>
|
||||
<script type="text/javascript" src="<%=resource%>/rsa.js"></script>
|
||||
<script type="text/javascript">
|
||||
var kn = 'AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD';
|
||||
var ke = '010001';
|
||||
var rsa = new RSAKey();
|
||||
rsa.setPublic(kn, ke);
|
||||
</script>
|
||||
<% include("cbi/map") %>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!-- var mac = document.getElementById('cbid.kuainiao.base.wanmac').value;-->
|
||||
<!--var fake_device_id = md5(mac);-->
|
||||
<!--var device_sign = "div100."+fake_device_id+md5(hex_sha1(fake_device_id+"com.xunlei.vip.swjsq68700d1872b772946a6940e4b51827e8af")); -->
|
||||
var password = document.getElementById('cbid.kuainiao.base.kuainiao_passwd').value;
|
||||
var encrypted_pwd = rsa.encrypt(md5(password));
|
||||
var kuainiao_conf_pwd=encrypted_pwd.toUpperCase();
|
||||
document.getElementById('cbid.kuainiao.base.kuainiao_config_pwd').value = kuainiao_conf_pwd;
|
||||
<!-- document.getElementById('cbid.kuainiao.base.device_sign').value = device_sign; -->
|
||||
</script>
|
@ -0,0 +1,38 @@
|
||||
<%#
|
||||
Copyright 2017 Lede by stones
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementById('kuainiao_status');
|
||||
status.innerHTML = result.running?'<font color=green><%=translate("RUNNING")%></font>':'<font color=red><%=translate("NOT RUNNING")%></font>';
|
||||
}
|
||||
);
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "dwonstatus")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var dwonstatus = document.getElementById('dwon_status');
|
||||
dwonstatus.innerHTML = (result.dwonstatus?result.dwonstatus:"--");
|
||||
}
|
||||
);
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "kuainiao", "upstatus")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var upstatus = document.getElementById('up_status');
|
||||
upstatus.innerHTML = (result.upstatus?result.upstatus:"--");
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<%:快鸟运行状态:%><em id="kuainiao_status"><%:Collecting data...%></em>
|
||||
<legend></legend>
|
||||
<legend></legend>
|
||||
<%:下行提速状态:%><em id="dwon_status"><%:Collecting data...%></em>
|
||||
<legend></legend>
|
||||
<%:上行提速状态:%><em id="up_status"><%:Collecting data...%></em>
|
||||
</fieldset>
|
4
package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po
Normal file
4
package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po
Normal file
@ -0,0 +1,4 @@
|
||||
msgid "Kuai Niao"
|
||||
msgstr "迅雷快鸟"
|
||||
|
||||
|
8
package/lean/luci-app-kuainiao/root/etc/config/kuainiao
Normal file
8
package/lean/luci-app-kuainiao/root/etc/config/kuainiao
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
config kuainiao 'base'
|
||||
option kuainiao_name ''
|
||||
option kuainiao_passwd ''
|
||||
option speed_wan 'wan'
|
||||
option enabled '0'
|
||||
option enable_down '1'
|
||||
option enable_up '0'
|
15
package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao
Executable file
15
package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
enabled=`uci -q get kuainiao.base.enabled`
|
||||
[ "enabled" -eq 1 ] || exit 0
|
||||
[ "$ACTION" = ifup ] && {
|
||||
logger -t Thunder kuainiao has reloaded due to Device: $DEVICE Action: $ACTION ;
|
||||
/etc/init.d/kuainiao stop && sleep 2;
|
||||
/etc/init.d/kuainiao start;
|
||||
}
|
||||
|
||||
[ "$ACTION" = ifdown ] && {
|
||||
logger -t Thunder KuaiNiao has stoped due to Device: $DEVICE Action: $ACTION ;
|
||||
/etc/init.d/kuainiao stop;
|
||||
}
|
45
package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao
Executable file
45
package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
STOP=15
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
LOGFILE=/var/log/kuainiao.log
|
||||
|
||||
start_service()
|
||||
{
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/bin/kuainiao
|
||||
procd_set_param respawn ${respawn_threshold:-5} ${respawn_timeout:-300} ${respawn_retry:-10}
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service(){
|
||||
clean_log
|
||||
pid_kuainiao=`ps | grep -v grep | grep -w "/usr/bin/kuainiao" |awk '{print $1}' 2>/dev/null`
|
||||
[ -n "$pid_kuainiao" ] && {
|
||||
for pid in $pid_kuainiao
|
||||
do
|
||||
echo "Stop service kuainiao PID: $pid"
|
||||
kill $pid 2>/dev/null
|
||||
for spid in `pgrep sleep`
|
||||
do
|
||||
ppid=`cat /proc/$spid/status | grep -w "PPid" | awk '{print $2}'`
|
||||
[ "$ppid" -eq "$pid" ] && kill $spid 2>/dev/null && echo "Stop service kuainiao SPID: $spid"
|
||||
done
|
||||
done
|
||||
}
|
||||
echo "<font color=red>暂无加速信息</font>" > /usr/share/kuainiao/kuainiao_down_state
|
||||
echo "<font color=red>暂无加速信息</font>" > /usr/share/kuainiao/kuainiao_up_state
|
||||
}
|
||||
|
||||
clean_log() {
|
||||
[ -f "$LOGFILE" ] && {
|
||||
logsnum=$(cat $LOGFILE | grep -c .)
|
||||
if [ $logsnum -gt 300 ];then
|
||||
rm -f $LOGFILE >/dev/null 2>&1 &
|
||||
echo "$(date): 日志文件过长,清空处理!" >> $LOGFILE
|
||||
fi
|
||||
}
|
||||
}
|
9
package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao
Executable file
9
package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@kuainiao[-1]
|
||||
add ucitrack kuainiao
|
||||
set ucitrack.@kuainiao[-1].init=kuainiao
|
||||
commit ucitrack
|
||||
EOF
|
||||
exit 0
|
606
package/lean/luci-app-kuainiao/root/usr/bin/kuainiao
Executable file
606
package/lean/luci-app-kuainiao/root/usr/bin/kuainiao
Executable file
@ -0,0 +1,606 @@
|
||||
#!/bin/sh
|
||||
#2017/05/01 by kenney
|
||||
#2017/07/19 update for lede by stones
|
||||
. /lib/functions.sh
|
||||
|
||||
LOGFILE=/var/log/kuainiao.log
|
||||
down_state_file=/usr/share/kuainiao/kuainiao_down_state
|
||||
up_state_file=/usr/share/kuainiao/kuainiao_up_state
|
||||
version="0.4"
|
||||
app_version="2.0.3.4"
|
||||
protocolVersion=108
|
||||
sdkVersion=17550
|
||||
logmore=0 #打印更详细日志排查
|
||||
|
||||
|
||||
logmore(){
|
||||
data=$1
|
||||
[ "$logmore" -eq 1 ] && {
|
||||
echo $(date): $data >> $LOGFILE
|
||||
}
|
||||
}
|
||||
|
||||
log_down(){
|
||||
kuainiao_down_state=$1
|
||||
status=$2
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "<font color=green>$kuainiao_down_state</font>" > $down_state_file
|
||||
else
|
||||
echo "<font color=red>$kuainiao_down_state</font>" > $down_state_file
|
||||
fi
|
||||
}
|
||||
|
||||
log_up(){
|
||||
kuainiao_up_state=$1
|
||||
status=$2
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "<font color=green>$kuainiao_up_state</font>" > $up_state_file
|
||||
else
|
||||
echo "<font color=red>$kuainiao_up_state</font>" > $up_state_file
|
||||
fi
|
||||
}
|
||||
|
||||
#WAN接口IP判断
|
||||
get_bind_address(){
|
||||
ifname=$(uci -P /var/state get network.$kuainiao_config_wan.ifname 2>/dev/null)
|
||||
[ $? -eq 1 ] && echo $(date): "获取网络 $kuainiao_config_wan 信息出错" >>$LOGFILE && echo >>$LOGFILE && return
|
||||
logmore "ifname is $ifname"
|
||||
##wan_selected 所选接口IP
|
||||
wan_selected=$(ifconfig $ifname 2>/dev/null | grep 'inet addr' | awk '{print $2}' | cut -d: -f2 2>/dev/null)
|
||||
[ -z "$wan_selected" ] && echo $(date): "获取网络 $kuainiao_config_wan 接口 $ifname 信息出错" >>$LOGFILE && echo >>$LOGFILE && return
|
||||
if [ "$wan_selected" != "0.0.0.0" ]; then
|
||||
bind_address=$wan_selected
|
||||
else
|
||||
bind_address=""
|
||||
fi
|
||||
}
|
||||
|
||||
#定义请求函数
|
||||
#bind_address='113.248.3.11'
|
||||
get_http_req(){
|
||||
if [ -n "$bind_address" ]; then
|
||||
HTTP_REQ="wget --bind-address=$bind_address --no-check-certificate -O - "
|
||||
POST_ARG="--post-data="
|
||||
else
|
||||
HTTP_REQ="wget --no-check-certificate -O - "
|
||||
POST_ARG="--post-data="
|
||||
fi
|
||||
kuainiao_HTTP_REQ=$HTTP_REQ
|
||||
kuainiao_POST_ARG=$POST_ARG
|
||||
}
|
||||
|
||||
#数据mock
|
||||
|
||||
generate_pwd_rsa_hex()
|
||||
{
|
||||
# calculate passwd_md5
|
||||
logmore "Generating passwd md5"
|
||||
passwd_md5=`echo -n "$kuainiao_config_pwd" | md5sum | tr -d " -"`
|
||||
|
||||
if [ `echo -n "$passwd_md5" | wc -c` -ne 32 ]; then
|
||||
logmore "md5sum should be 32 chars, exit."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logmore "Generating PWD RSA HEX"
|
||||
#first, encoding passwd using rsa
|
||||
a=`echo "$passwd_md5" | openssl rsautl -raw -pubin -inkey /etc/thunder.key -hexdump | tr [a-z] [A-Z]`
|
||||
a=`echo $a | grep -o '00[0-9]0 \- \([A-Z0-9]\{2\}[- ]\)\{16\}' | sed 's/00[0-9]0 - //g' | tr -d " \-\n"`
|
||||
echo -n "$a"
|
||||
|
||||
}
|
||||
|
||||
#pwd='702CFAF5824E4306516F488DEAFC2D24F76C82FA53BA3396F5615FDD32E4430E45B254E136056ED5F3C5B404A08E2178B51330999A4EC3C2D2989D554D7863BDE8F058F44808E6B65F4D071B5D5C7210210DA9ED8D729312CECA39E0F4516143E33C089F616ABE93E14D3224BEB311D3D6EF65A6CE265D3E4ABA285523F14320'
|
||||
|
||||
get_device_sign(){
|
||||
ifname=$(uci get network.$kuainiao_config_wan.ifname 2>/dev/null)
|
||||
wan_mac=$(ifconfig $ifname | grep 'HWaddr' | awk '{print $5}')
|
||||
fake_device_id=$(echo -n "$wan_mac" | md5sum | cut -d ' ' -f1)
|
||||
fake_device_id_tmp1=$(echo -n "$fake_device_id"com.xunlei.vip.swjsq68700d1872b772946a6940e4b51827e8af"" | openssl sha1 -hmac | awk '{print $2}')
|
||||
devicesign="div100."${fake_device_id}$(echo -n "$fake_device_id_tmp1" | md5sum | cut -d ' ' -f1)
|
||||
}
|
||||
|
||||
|
||||
#verifyCode=$kuainiao_config_verifyCode
|
||||
#verifyKey=$kuainiao_verifyKey
|
||||
|
||||
#获取用户真实MAC地址
|
||||
get_mac_addr(){
|
||||
if [ -n "$bind_address" ]; then
|
||||
ifname=$(uci get network.$kuainiao_config_wan.ifname 2>/dev/null)
|
||||
peerid=$(ifconfig $ifname | grep 'HWaddr' | awk '{print $5}' | awk 'gsub(/:/, "")')004V
|
||||
fi
|
||||
#peerid='000C29212478004V'
|
||||
}
|
||||
|
||||
|
||||
#获取迅雷用户uid
|
||||
get_xunlei_uid(){
|
||||
get_http_req
|
||||
logmore "HTTP_REQ is $HTTP_REQ"
|
||||
logmore "POST_ARG is $POST_ARG"
|
||||
uname=$kuainiao_config_uname
|
||||
#get_mac_addr
|
||||
logmore "peerid is $peerid"
|
||||
[ -z "$peerid" ] && exit 0
|
||||
#pwd=$generate_pwd_rsa_hex
|
||||
pwd=$kuainiao_config_pwd
|
||||
get_device_sign
|
||||
logmore "devicesign is $devicesign"
|
||||
ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.6.1.177600" https://login.mobile.reg2t.sandai.net:443/ $POST_ARG"{\"userName\":\""$uname"\",\"businessType\":68,\"clientVersion\":\"$app_version\",\"appName\":\"ANDROID-com.xunlei.vip.swjsq\",\"isCompressed\":0,\"sequenceNo\":1000001,\"sessionID\":\"\",\"loginType\":0,\"rsaKey\":{\"e\":\"010001\",\"n\":\"AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD\"},\"cmdID\":1,\"verifyCode\":\"$verifyCode\",\"peerID\":\""$peerid"\",\"protocolVersion\":$protocolVersion,\"platformVersion\":1,\"passWord\":\""$pwd"\",\"extensionList\":\"\",\"verifyKey\":\"$verifyKey\",\"sdkVersion\":$sdkVersion,\"devicesign\":\""$devicesign"\"}"`
|
||||
#判断是否登陆成功
|
||||
#echo $ret >>test.txt
|
||||
logmore "........................"
|
||||
logmore "ret is $ret"
|
||||
logmore "........................"
|
||||
session=`echo $ret|awk -F '"sessionID":' '{print $2}'|awk -F '[,}]' '{print $1}'|grep -oE "[A-F,0-9]{32}"`
|
||||
logmore "session is $session"
|
||||
#vcode=`echo $ret|awk -F '"errorDescUrl":' '{print $2}'|awk -F '}' '{print $1}'`
|
||||
#vcode=`echo $vcode|sed 's/\\//g'`
|
||||
errcode=`echo $ret|awk -F '"errorCode":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
logmore "errcode is $errcode"
|
||||
if [ -z "$session" ]; then
|
||||
if [ $errcode == 6 ];then
|
||||
#kuainiao_vcodeimg_url="$vcode"
|
||||
#kuainiao_verifyKey='F9F6FBE928911784D809EBF046ABE0A6A467583F3944507099EA54BC9B5DA7BD'
|
||||
kuainiao_last_act="您的账号不安全,需要输入验证码! $(date "+%Y-%m-%d %H:%M:%S")"
|
||||
|
||||
elif [ $errcode == 12 ];then
|
||||
#kuainiao_vcodeimg_url=""
|
||||
#kuainiao_verifyKey=''
|
||||
kuainiao_last_act="登陆协议无效,请更新!$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
|
||||
elif [ $errcode == 3 ];then
|
||||
#kuainiao_vcodeimg_url=""
|
||||
#kuainiao_verifyKey=''
|
||||
kuainiao_last_act="用户名密码错误,请检查!$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
|
||||
else
|
||||
#kuainiao_vcodeimg_url=""
|
||||
#kuainiao_verifyKey=''
|
||||
kuainiao_last_act="迅雷账号登陆失败,请检查输入的用户名密码! $(date "+%Y-%m-%d %H:%M:%S")"
|
||||
|
||||
fi
|
||||
#echo "迅雷账号登陆失败,请检查输入的用户名密码!"
|
||||
log_down "$kuainiao_last_act" 0
|
||||
|
||||
else
|
||||
uid=`echo $ret|awk -F '"userID":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
kuainiao_config_uid=$uid
|
||||
kuainiao_config_session=$session
|
||||
kuainiao_last_act="迅雷快鸟已登陆成功!"
|
||||
log_down "$kuainiao_last_act" 1
|
||||
fi
|
||||
echo $(date): "$kuainiao_last_act" >> $LOGFILE
|
||||
}
|
||||
|
||||
#获取加速API
|
||||
get_kuainiao_api(){
|
||||
portal=`$HTTP_REQ http://api.portal.swjsq.vip.xunlei.com:81/v2/queryportal`
|
||||
portal_ip=`echo $portal|grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}'`
|
||||
portal_port_temp=`echo $portal|grep -oE "port...[0-9]{1,5}"`
|
||||
portal_port=`echo $portal_port_temp|grep -oE '[0-9]{1,5}'`
|
||||
|
||||
logmore "portal is $portal" >> $LOGFILE
|
||||
logmore "portal_ip is $portal_ip" >> $LOGFILE
|
||||
logmore "portal_port_temp is $portal_port_temp" >> $LOGFILE
|
||||
logmore "portal_port is $portal_port" >> $LOGFILE
|
||||
|
||||
if [ -z "$portal_ip" ]; then
|
||||
kuainiao_down_state="迅雷快鸟下行API获取失败,请检查网络环境,或稍后再试!"
|
||||
echo $(date): "$kuainiao_down_state" >> $LOGFILE
|
||||
log_down "$kuainiao_down_state" 0
|
||||
else
|
||||
api_url="http://$portal_ip:$portal_port/v2"
|
||||
kuainiao_config_api=$api_url
|
||||
fi
|
||||
}
|
||||
|
||||
#获取上行加速API
|
||||
get_kuainiao_upapi(){
|
||||
upportal=`$HTTP_REQ http://api.upportal.swjsq.vip.xunlei.com/v2/queryportal`
|
||||
upportal_ip=`echo $upportal|grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}'`
|
||||
upportal_port_temp=`echo $upportal|grep -oE "port...[0-9]{1,5}"`
|
||||
upportal_port=`echo $upportal_port_temp|grep -oE '[0-9]{1,5}'`
|
||||
|
||||
logmore "upportal is $upportal"
|
||||
logmore "upportal_ip is $upportal_ip"
|
||||
logmore "upportal_port_temp is $upportal_port_temp"
|
||||
logmore "upportal_port is $upportal_port"
|
||||
|
||||
if [ -z "$upportal_ip" ]; then
|
||||
kuainiao_up_state="迅雷快鸟上行API获取失败,请检查网络环境,或稍后再试!"
|
||||
#echo "迅雷快鸟服务API获取失败,请检查网络环境,或稍后再试!"
|
||||
echo $(date): "$kuainiao_up_state" >> $LOGFILE
|
||||
log_up "$kuainiao_up_state" 0
|
||||
else
|
||||
upapi_url="http://$upportal_ip:$upportal_port/v2"
|
||||
kuainiao_config_upapi=$upapi_url
|
||||
fi
|
||||
logmore "$(date): upapi_url is $upapi_url"
|
||||
}
|
||||
|
||||
|
||||
#检测快鸟加速信息
|
||||
get_bandwidth(){
|
||||
|
||||
logmore "api_url is $api_url"
|
||||
logmore "peerid is $peerid"
|
||||
if [ -n "$api_url" ]; then
|
||||
[ -n "$portal_port_temp" ] && [ -n "$portal_port" ] && bandwidth
|
||||
band=$width
|
||||
logmore "band is $band"
|
||||
can_upgrade=`echo $band|awk -F '"can_upgrade":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
logmore "can_upgrade is $can_upgrade"
|
||||
kuainiao_can_upgrade=$can_upgrade
|
||||
logmore "kuainiao_can_upgrade is $kuainiao_can_upgrade"
|
||||
dial_account=`echo $band|awk -F '"dial_account":"' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
kuainiao_dial_account=$dial_account
|
||||
logmore "kuainiao_dial_account is $kuainiao_dial_account"
|
||||
#判断是否满足加速条件
|
||||
if [ "$can_upgrade" -eq 1 ]; then
|
||||
#echo "迅雷快鸟可以加速~~~愉快的开始加速吧~~"
|
||||
#获取加速详细信息
|
||||
old_downstream=`echo $band|awk -F '"bandwidth":' '{print $2}'|awk -F '"downstream":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
max_downstream=`echo $band|awk -F '"max_bandwidth":' '{print $2}'|awk -F '"downstream":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
down_state="下行可以加速"
|
||||
kuainiao_old_downstream=$(expr $old_downstream / 1024)
|
||||
kuainiao_max_downstream=$(expr $max_downstream / 1024)
|
||||
logmore "kuainiao_old_downstream is $kuainiao_old_downstream"
|
||||
logmore "kuainiao_max_downstream is $kuainiao_max_downstream"
|
||||
else
|
||||
down_state="下行不满足加速条件"
|
||||
#echo "T_T 不能加速啊,不满足加速条件哦~~"
|
||||
log_down "$down_state" 0
|
||||
fi
|
||||
echo $(date): "$down_state" >> $LOGFILE
|
||||
# kuainiao_down_state=$down_state
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
#检测快鸟上行加速信息
|
||||
get_upbandwidth(){
|
||||
logmore "upapi_url is $upapi_url"
|
||||
if [ -n "$upapi_url" ]; then
|
||||
[ -n "$upportal_port_temp" ] && [ -n "$upportal_port" ] && upbandwidth
|
||||
band=$upwidth
|
||||
logmore "upwidth is $upwidth"
|
||||
can_upgrade=`echo $band|awk -F '"can_upgrade":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
kuainiao_can_upupgrade=$can_upgrade
|
||||
updial_account=`echo $band|awk -F '"dial_account":"' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
kuainiao_dial_upaccount=$updial_account
|
||||
logmore "can_upgrade is $can_upgrade"
|
||||
logmore "kuainiao_can_upupgrade is $kuainiao_can_upupgrade"
|
||||
logmore "updial_account is $updial_account"
|
||||
logmore "kuainiao_dial_upaccount is $kuainiao_dial_upaccount"
|
||||
#判断是否满足加速条件
|
||||
if [ "$can_upgrade" -eq 1 ]; then
|
||||
#echo "迅雷快鸟可以加速~~~愉快的开始加速吧~~"
|
||||
#获取加速详细信息
|
||||
old_upstream=`echo $band|awk -F '"bandwidth":' '{print $2}'|awk -F '"upstream":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
max_upstream=`echo $band|awk -F '"max_bandwidth":' '{print $2}'|awk -F '"upstream":' '{print $2}'|awk -F '[,}]' '{print $1}'`
|
||||
up_state="上行可以加速"
|
||||
kuainiao_old_upstream=$(expr $old_upstream / 1024)
|
||||
kuainiao_max_upstream=$(expr $max_upstream / 1024)
|
||||
logmore "kuainiao_old_upstream is $kuainiao_old_upstream"
|
||||
logmore "kuainiao_max_upstream is $kuainiao_max_upstream"
|
||||
else
|
||||
up_state="上行不满足加速条件"
|
||||
log_up "$up_state" 0
|
||||
fi
|
||||
echo "$(date): $up_state" >> $LOGFILE
|
||||
kuainiao_up_state=$up_state
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#检测试用加速信息
|
||||
query_try_info(){
|
||||
info=`$HTTP_REQ "$api_url/query_try_info?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session"`
|
||||
echo $info
|
||||
}
|
||||
##{"errno":0,"message":"","number_of_try":0,"richmessage":"","sequence":0,"timestamp":1455936922,"try_duration":10}
|
||||
|
||||
query_try_upinfo(){
|
||||
info=`$HTTP_REQ "$upapi_url/query_try_info?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session"`
|
||||
echo $info
|
||||
}
|
||||
##{"errno":0,"exp_day_len":0,"is_exp_day":0,"message":"","number_of_try":1,"richmessage":"","sequence":268435461,"timestamp":1493469390,"try_duration":10}
|
||||
|
||||
get_upgrade_down(){
|
||||
_ts=`date +%s`000
|
||||
ret=`$HTTP_REQ "$api_url/upgrade?peerid=$peerid&userid=$uid&user_type=1&sessionid=$kuainiao_config_session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"`
|
||||
errcode=`echo $ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
if [ "$errcode" == "0" ]; then
|
||||
down_state="$down_state (您的下行带宽已从$kuainiao_old_downstream M提升到$kuainiao_max_downstream M)"
|
||||
log_down "$down_state" 1
|
||||
else
|
||||
down_state="$down_state 下行带宽提升失败,请检查宽带账号是否绑定正确"
|
||||
log_down "$down_state" 0
|
||||
fi
|
||||
echo $(date): "$down_state" >> $LOGFILE
|
||||
# kuainiao_down_state=$down_state
|
||||
}
|
||||
|
||||
get_upgrade_up(){
|
||||
_ts=`date +%s`000
|
||||
up_ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.0.0.1" "$upapi_url/upgrade?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$updial_account"`
|
||||
errcode=`echo $up_ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
if [ "$errcode" == "0" ] || [ "$errcode" == "812" ];then
|
||||
up_state="$up_state (您的上行带宽已从$kuainiao_old_upstream M提升到$kuainiao_max_upstream M)"
|
||||
log_up "$up_state" 1
|
||||
else
|
||||
up_state="$up_state 上行带宽提升失败,请检查宽带账号是否绑定正确"
|
||||
log_up "$up_state" 0
|
||||
fi
|
||||
echo $(date): "$up_state" >> $LOGFILE
|
||||
# kuainiao_up_state=$up_state
|
||||
# echo "$kuainiao_up_state" > $up_state_file
|
||||
}
|
||||
|
||||
#迅雷快鸟上行加速心跳包
|
||||
keepalive_up(){
|
||||
_ts=`date +%s`000
|
||||
up_ret=`$HTTP_REQ --header "User-Agent:android-async-http/xl-acc-sdk/version-1.0.0.1" "$upapi_url/keepalive?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$kuainiao_dial_upaccount"`
|
||||
errcode=`echo $up_ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
if [ "$errcode" != "0" ];then
|
||||
#kuainiao_run_upid=0
|
||||
kuainiao_up_state="迅雷上行提速失效!$(date '+%Y-%m-%d %H:%M:%S')"
|
||||
kuainiao_run_upstatus=0
|
||||
log_up "$kuainiao_up_state" 0
|
||||
else
|
||||
#kuainiao_run_upid=$(expr $kuainiao_run_upid + 1)
|
||||
kuainiao_up_state="您的上行带宽已从${kuainiao_old_upstream}M提升到${kuainiao_max_upstream}M $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
kuainiao_run_upstatus=1
|
||||
log_up "$kuainiao_up_state" 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#检测提速带宽
|
||||
bandwidth(){
|
||||
[ "$logmore" -eq 1 ] && {
|
||||
echo $(date): "bandwidth start" >> $LOGFILE
|
||||
echo $(date): "peerid is $peerid" >> $LOGFILE
|
||||
echo $(date): "uid is $uid" >> $LOGFILE
|
||||
echo $(date): "session is $session" >> $LOGFILE
|
||||
}
|
||||
_ts=`date +%s`000
|
||||
width=`$HTTP_REQ "$api_url/bandwidth?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"`
|
||||
#echo $width
|
||||
}
|
||||
##{"bandwidth":{"downstream":51200,"upstream":0},"can_upgrade":1,"dial_account":"100001318645","errno":0,"max_bandwidth":{"downstream":102400,"upstream":0},"message":"","province":"bei_jing","province_name":"北京","richmessage":"","sequence":0,"sp":"cnc","sp_name":"联通","timestamp":1455936922}
|
||||
|
||||
upbandwidth(){
|
||||
_ts=`date +%s`000
|
||||
upwidth=`$HTTP_REQ "$upapi_url/bandwidth?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"`
|
||||
#echo $upwidth
|
||||
}
|
||||
|
||||
|
||||
#迅雷快鸟下行加速心跳包
|
||||
keepalive_down(){
|
||||
_ts=`date +%s`000
|
||||
ret=`$HTTP_REQ "$api_url/keepalive?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"`
|
||||
errcode=`echo $ret|awk -F '"errno":' '{print $2}'|awk -F '[,}"]' '{print $1}'`
|
||||
if [ "$errcode" != "0" ];then
|
||||
#kuainiao_run_upid=0
|
||||
kuainiao_down_state="迅雷下行提速失效!"$(date "+%Y-%m-%d %H:%M:%S")
|
||||
log_down "$kuainiao_down_state" 0
|
||||
kuainiao_run_status=0
|
||||
else
|
||||
#kuainiao_run_upid=$(expr $kuainiao_run_upid + 1)
|
||||
kuainiao_down_state="您的下行带宽已从${kuainiao_old_downstream}M提升到${kuainiao_max_downstream}M $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
log_down "$kuainiao_down_state" 1
|
||||
kuainiao_run_status=1
|
||||
|
||||
fi
|
||||
echo $(date): "$kuainiao_down_state" >> $LOGFILE
|
||||
}
|
||||
|
||||
sigterm(){
|
||||
|
||||
[ "$kuainiao_can_upgrade" -eq 1 ] && kuainiao_recover
|
||||
[ "$kuainiao_can_upupgrade" -eq 1 ] && kuainiao_uprecover
|
||||
logmore "trap sigterm exit"
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
#快鸟加速注销
|
||||
kuainiao_recover(){
|
||||
_ts=`date +%s`000
|
||||
recover=`$HTTP_REQ "$api_url/recover?peerid=$peerid&userid=$uid&user_type=1&sessionid=$session&dial_account=$dial_account&client_type=android-swjsq-$app_version&client_version=androidswjsq-$app_version&os=android-5.0.1.24SmallRice&time_and=$_ts"`
|
||||
#echo $recover
|
||||
echo $(date): "快鸟下行带宽加速已注销" >> $LOGFILE
|
||||
}
|
||||
|
||||
kuainiao_uprecover(){
|
||||
_ts=`date +%s`000
|
||||
recover=`$HTTP_REQ "$upapi_url/recover?peerid=$peerid&userid=$uid&client_type=android-uplink-2.3.3.9&client_version=andrioduplink-2.3.3.9&os=android-7.0.24DUK-AL20&sessionid=$session&user_type=1&dial_account=$updial_account"`
|
||||
#echo $recover
|
||||
echo $(date): "快鸟上行带宽加速已注销" >> $LOGFILE
|
||||
}
|
||||
|
||||
#执行初始化
|
||||
kuainiao_init(){
|
||||
local kuainiao_last_act=""
|
||||
local kuainiao_can_upgrade=0
|
||||
local kuainiao_can_upupgrade=0
|
||||
local kuainiao_down_state=""
|
||||
local kuainiao_up_state=""
|
||||
}
|
||||
|
||||
##主逻辑
|
||||
trap 'sigterm' TERM
|
||||
trap 'sigterm' INT
|
||||
|
||||
kuainiao_init
|
||||
config_load kuainiao
|
||||
config_get_bool enabled base enabled 0
|
||||
config_get_bool kuainiao_downenable base enable_down 0
|
||||
config_get_bool kuainiao_upenable base enable_up 0
|
||||
config_get kuainiao_config_wan base speed_wan
|
||||
config_get kuainiao_config_uname base kuainiao_name
|
||||
config_get kuainiao_config_pwd base kuainiao_config_pwd
|
||||
|
||||
[ "$enabled" -eq 0 ] || [ -z "$kuainiao_config_pwd" ] && exit 0
|
||||
[ "$kuainiao_downenable" -eq 0 ] && [ "$kuainiao_upenable" -eq 0 ] && exit 0
|
||||
[ -z "$kuainiao_config_uname" ] && exit 0
|
||||
|
||||
logmore "enabled is $enabled"
|
||||
logmore "kuainiao_downenable is $kuainiao_downenable"
|
||||
logmore "kuainiao_upenable is $kuainiao_upenable"
|
||||
logmore "kuainiao_config_wan is $kuainiao_config_wan"
|
||||
logmore "kuainiao_config_uname is $kuainiao_config_uname"
|
||||
logmore "kuainiao_config_pwd is $kuainiao_config_pwd"
|
||||
|
||||
if [ "$kuainiao_downenable" -eq 1 ] || [ "$kuainiao_upenable" -eq 1 ]; then
|
||||
|
||||
logmore "启动延时 7s"
|
||||
sleep 7s
|
||||
|
||||
#登陆迅雷获取uid
|
||||
logmore "get_bind_address start"
|
||||
get_bind_address
|
||||
logmore "bind_address is $bind_address"
|
||||
logmore "get_mac_addr start"
|
||||
get_mac_addr
|
||||
logmore "peerid is $peerid"
|
||||
logmore "get_xunlei_uid start"
|
||||
get_xunlei_uid
|
||||
logmore "get_xunlei_uid is done"
|
||||
logmore "id is $uid"
|
||||
#判断是否登陆成功
|
||||
if [ -n "$uid" ]; then
|
||||
if [ "$kuainiao_downenable" -eq 1 ]; then
|
||||
logmore "get_kuainiao_api is started......."
|
||||
get_kuainiao_api
|
||||
logmore "get_bandwidth is started......."
|
||||
get_bandwidth
|
||||
kuainiao_config_downstream=$(expr $old_downstream / 1024)
|
||||
kuainiao_config_max_downstream=$(expr $max_downstream / 1024)
|
||||
logmore "kuainiao_config_downstream is $kuainiao_config_downstream"
|
||||
logmore "kuainiao_config_max_downstream is $kuainiao_config_max_downstream"
|
||||
logmore "kuainiao_can_upgrade is $kuainiao_can_upgrade"
|
||||
|
||||
if [ "$kuainiao_can_upgrade" -eq 1 ]; then
|
||||
logmore "get_upgrade_down is started......."
|
||||
get_upgrade_down
|
||||
logmore "get_upgrade_down is done......."
|
||||
sleep 1s
|
||||
#keepalive_down
|
||||
fi
|
||||
fi
|
||||
if [ "$kuainiao_upenable" -eq 1 ]; then
|
||||
logmore "get_kuainiao_upapi start"
|
||||
get_kuainiao_upapi
|
||||
logmore "get_upbandwidth start"
|
||||
get_upbandwidth
|
||||
kuainiao_config_upstream=$(expr $old_upstream / 1024)
|
||||
kuainiao_config_max_upstream=$(expr $max_upstream / 1024)
|
||||
logmore "kuainiao_config_upstream is $kuainiao_config_upstream"
|
||||
logmore "kuainiao_config_max_upstream is $kuainiao_config_max_upstream"
|
||||
logmore "kuainiao_can_upupgrade is $kuainiao_can_upupgrade"
|
||||
|
||||
if [ "$kuainiao_can_upupgrade" -eq 1 ]; then
|
||||
logmore "get_upgrade_up start"
|
||||
get_upgrade_up
|
||||
sleep 1s
|
||||
#keepalive_up
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# [ -z "$kuainiao_can_upgrade" ] && [ -z "$kuainiao_can_upupgrade" ] && {
|
||||
# logmore "exit kuainiao...."
|
||||
# sleep 7s
|
||||
# echo "<font color=red>暂无加速信息</font>" > $down_state_file
|
||||
# echo "<font color=red>暂无加速信息</font>" > $up_state_file
|
||||
# exit 0
|
||||
|
||||
# }
|
||||
while true;
|
||||
do
|
||||
sleep 295s
|
||||
if [ "$kuainiao_downenable" -eq 1 ] && [ "$kuainiao_can_upgrade" -eq 1 ];then
|
||||
keepalive_down
|
||||
[ "$kuainiao_run_status" -eq 0 ] && restart_kuainiao
|
||||
fi
|
||||
if [ "$kuainiao_upenable" -eq 1 ] && [ "$kuainiao_can_upupgrade" -eq 1 ];then
|
||||
keepalive_up
|
||||
[ "$kuainiao_run_upstatus" -eq 0 ] && restart_kuainiao
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
restart_kuainiao(){
|
||||
kuainiao_init
|
||||
config_load kuainiao
|
||||
config_get_bool enabled base enabled 0
|
||||
config_get_bool kuainiao_downenable base enable_down 0
|
||||
config_get_bool kuainiao_upenable base enable_up 0
|
||||
config_get kuainiao_config_wan base speed_wan
|
||||
config_get kuainiao_config_uname base kuainiao_name
|
||||
config_get kuainiao_config_pwd base kuainiao_config_pwd
|
||||
|
||||
if [ "$kuainiao_downenable" -eq 1 ] || [ "$kuainiao_upenable" -eq 1 ]; then
|
||||
logmore "启动延时 7s"
|
||||
sleep 7s
|
||||
|
||||
#登陆迅雷获取uid
|
||||
logmore "get_bind_address start"
|
||||
get_bind_address
|
||||
logmore "bind_address is $bind_address"
|
||||
logmore "get_mac_addr start"
|
||||
get_mac_addr
|
||||
logmore "peerid is $peerid"
|
||||
logmore "get_xunlei_uid start"
|
||||
get_xunlei_uid
|
||||
logmore "get_xunlei_uid is done"
|
||||
logmore "id is $uid"
|
||||
#判断是否登陆成功
|
||||
if [ -n "$uid" ]; then
|
||||
if [ "$kuainiao_downenable" -eq 1 ]; then
|
||||
logmore "get_kuainiao_api is started......."
|
||||
get_kuainiao_api
|
||||
logmore "get_bandwidth is started......."
|
||||
get_bandwidth
|
||||
kuainiao_config_downstream=$(expr $old_downstream / 1024)
|
||||
kuainiao_config_max_downstream=$(expr $max_downstream / 1024)
|
||||
if [ "$kuainiao_can_upgrade" -eq 1 ]; then
|
||||
[ "$logmore" -eq 1 ] && logmore "get_upgrade_down is started......."
|
||||
get_upgrade_down
|
||||
logmore "get_upgrade_down is done......."
|
||||
sleep 1s
|
||||
#keepalive_down
|
||||
fi
|
||||
fi
|
||||
if [ "$kuainiao_upenable" -eq 1 ]; then
|
||||
logmore "get_kuainiao_upapi start"
|
||||
get_kuainiao_upapi
|
||||
logmore "get_upbandwidth start"
|
||||
get_upbandwidth
|
||||
kuainiao_config_upstream=$(expr $old_upstream / 1024)
|
||||
kuainiao_config_max_upstream=$(expr $max_upstream / 1024)
|
||||
if [ "$kuainiao_can_upupgrade" -eq 1 ]; then
|
||||
logmore "get_upgrade_up start"
|
||||
get_upgrade_up
|
||||
sleep 1s
|
||||
#keepalive_up
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#add_kuainiao_cru
|
||||
fi
|
||||
[ -z "$kuainiao_can_upgrade" ] && [ -z "$kuainiao_can_upupgrade" ] && {
|
||||
logmore "exit kuainiao...."
|
||||
sleep 7s
|
||||
echo "<font color=red>暂无加速信息</font>" > $down_state_file
|
||||
echo "<font color=red>暂无加速信息</font>" > $up_state_file
|
||||
exit 0
|
||||
}
|
||||
}
|
12
package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply
Executable file
12
package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
enabled=`uci get kuainiao.base.enabled`
|
||||
|
||||
if [ "$enabled" -eq 0 ]; then
|
||||
/etc/init.d/kuainiao stop
|
||||
/etc/init.d/kuainiao disable
|
||||
else
|
||||
/etc/init.d/kuainiao stop
|
||||
/etc/init.d/kuainiao start
|
||||
/etc/init.d/kuainiao enable
|
||||
fi
|
@ -0,0 +1 @@
|
||||
暂无加速信息
|
@ -0,0 +1 @@
|
||||
暂无加速信息
|
@ -0,0 +1 @@
|
||||
var md5; md5 || (md5 = function(){function i(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;a.length>g;g+=16){var h=c,i=d,j=e,o=f;c=k(c,d,e,f,a[g+0],7,-680876936),f=k(f,c,d,e,a[g+1],12,-389564586),e=k(e,f,c,d,a[g+2],17,606105819),d=k(d,e,f,c,a[g+3],22,-1044525330),c=k(c,d,e,f,a[g+4],7,-176418897),f=k(f,c,d,e,a[g+5],12,1200080426),e=k(e,f,c,d,a[g+6],17,-1473231341),d=k(d,e,f,c,a[g+7],22,-45705983),c=k(c,d,e,f,a[g+8],7,1770035416),f=k(f,c,d,e,a[g+9],12,-1958414417),e=k(e,f,c,d,a[g+10],17,-42063),d=k(d,e,f,c,a[g+11],22,-1990404162),c=k(c,d,e,f,a[g+12],7,1804603682),f=k(f,c,d,e,a[g+13],12,-40341101),e=k(e,f,c,d,a[g+14],17,-1502002290),d=k(d,e,f,c,a[g+15],22,1236535329),c=l(c,d,e,f,a[g+1],5,-165796510),f=l(f,c,d,e,a[g+6],9,-1069501632),e=l(e,f,c,d,a[g+11],14,643717713),d=l(d,e,f,c,a[g+0],20,-373897302),c=l(c,d,e,f,a[g+5],5,-701558691),f=l(f,c,d,e,a[g+10],9,38016083),e=l(e,f,c,d,a[g+15],14,-660478335),d=l(d,e,f,c,a[g+4],20,-405537848),c=l(c,d,e,f,a[g+9],5,568446438),f=l(f,c,d,e,a[g+14],9,-1019803690),e=l(e,f,c,d,a[g+3],14,-187363961),d=l(d,e,f,c,a[g+8],20,1163531501),c=l(c,d,e,f,a[g+13],5,-1444681467),f=l(f,c,d,e,a[g+2],9,-51403784),e=l(e,f,c,d,a[g+7],14,1735328473),d=l(d,e,f,c,a[g+12],20,-1926607734),c=m(c,d,e,f,a[g+5],4,-378558),f=m(f,c,d,e,a[g+8],11,-2022574463),e=m(e,f,c,d,a[g+11],16,1839030562),d=m(d,e,f,c,a[g+14],23,-35309556),c=m(c,d,e,f,a[g+1],4,-1530992060),f=m(f,c,d,e,a[g+4],11,1272893353),e=m(e,f,c,d,a[g+7],16,-155497632),d=m(d,e,f,c,a[g+10],23,-1094730640),c=m(c,d,e,f,a[g+13],4,681279174),f=m(f,c,d,e,a[g+0],11,-358537222),e=m(e,f,c,d,a[g+3],16,-722521979),d=m(d,e,f,c,a[g+6],23,76029189),c=m(c,d,e,f,a[g+9],4,-640364487),f=m(f,c,d,e,a[g+12],11,-421815835),e=m(e,f,c,d,a[g+15],16,530742520),d=m(d,e,f,c,a[g+2],23,-995338651),c=n(c,d,e,f,a[g+0],6,-198630844),f=n(f,c,d,e,a[g+7],10,1126891415),e=n(e,f,c,d,a[g+14],15,-1416354905),d=n(d,e,f,c,a[g+5],21,-57434055),c=n(c,d,e,f,a[g+12],6,1700485571),f=n(f,c,d,e,a[g+3],10,-1894986606),e=n(e,f,c,d,a[g+10],15,-1051523),d=n(d,e,f,c,a[g+1],21,-2054922799),c=n(c,d,e,f,a[g+8],6,1873313359),f=n(f,c,d,e,a[g+15],10,-30611744),e=n(e,f,c,d,a[g+6],15,-1560198380),d=n(d,e,f,c,a[g+13],21,1309151649),c=n(c,d,e,f,a[g+4],6,-145523070),f=n(f,c,d,e,a[g+11],10,-1120210379),e=n(e,f,c,d,a[g+2],15,718787259),d=n(d,e,f,c,a[g+9],21,-343485551),c=p(c,h),d=p(d,i),e=p(e,j),f=p(f,o)}return[c,d,e,f]}function j(a,b,c,d,e,f){return p(q(p(p(b,a),p(d,f)),e),c)}function k(a,b,c,d,e,f,g){return j(b&c|~b&d,a,b,e,f,g)}function l(a,b,c,d,e,f,g){return j(b&d|c&~d,a,b,e,f,g)}function m(a,b,c,d,e,f,g){return j(b^c^d,a,b,e,f,g)}function n(a,b,c,d,e,f,g){return j(c^(b|~d),a,b,e,f,g)}function p(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function q(a,b){return a<<b|a>>>32-b}function r(a){for(var b=[],d=(1<<c)-1,e=0;a.length*c>e;e+=c)b[e>>5]|=(a.charCodeAt(e/c)&d)<<e%32;return b}function t(b){for(var c=a?"0123456789ABCDEF":"0123456789abcdef",d="",e=0;b.length*4>e;e++)d+=c.charAt(b[e>>2]>>e%4*8+4&15)+c.charAt(b[e>>2]>>e%4*8&15);return d}var a=0,c=8;return function(a){return t(i(r(a),a.length*c))}}());
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
|
||||
* in FIPS PUB 180-1
|
||||
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
|
||||
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
|
||||
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
|
||||
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
|
||||
|
||||
/*
|
||||
* Perform a simple self-test to see if the VM is working
|
||||
*/
|
||||
function sha1_vm_test()
|
||||
{
|
||||
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the SHA-1 of an array of big-endian words, and a bit length
|
||||
*/
|
||||
function core_sha1(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (24 - len % 32);
|
||||
x[((len + 64 >> 9) << 4) + 15] = len;
|
||||
|
||||
var w = Array(80);
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
var e = -1009589776;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
var olde = e;
|
||||
|
||||
for(var j = 0; j < 80; j++)
|
||||
{
|
||||
if(j < 16) w[j] = x[i + j];
|
||||
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
|
||||
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
|
||||
safe_add(safe_add(e, w[j]), sha1_kt(j)));
|
||||
e = d;
|
||||
d = c;
|
||||
c = rol(b, 30);
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
e = safe_add(e, olde);
|
||||
}
|
||||
return Array(a, b, c, d, e);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform the appropriate triplet combination function for the current
|
||||
* iteration
|
||||
*/
|
||||
function sha1_ft(t, b, c, d)
|
||||
{
|
||||
if(t < 20) return (b & c) | ((~b) & d);
|
||||
if(t < 40) return b ^ c ^ d;
|
||||
if(t < 60) return (b & c) | (b & d) | (c & d);
|
||||
return b ^ c ^ d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the appropriate additive constant for the current iteration
|
||||
*/
|
||||
function sha1_kt(t)
|
||||
{
|
||||
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
|
||||
(t < 60) ? -1894007588 : -899497514;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-SHA1 of a key and some data
|
||||
*/
|
||||
function core_hmac_sha1(key, data)
|
||||
{
|
||||
var bkey = str2binb(key);
|
||||
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
|
||||
return core_sha1(opad.concat(hash), 512 + 160);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an 8-bit or 16-bit string to an array of big-endian words
|
||||
* In 8-bit function, characters >255 have their hi-byte silently ignored.
|
||||
*/
|
||||
function str2binb(str)
|
||||
{
|
||||
var bin = Array();
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < str.length * chrsz; i += chrsz)
|
||||
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
|
||||
return bin;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a string
|
||||
*/
|
||||
function binb2str(bin)
|
||||
{
|
||||
var str = "";
|
||||
var mask = (1 << chrsz) - 1;
|
||||
for(var i = 0; i < bin.length * 32; i += chrsz)
|
||||
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a hex string.
|
||||
*/
|
||||
function binb2hex(binarray)
|
||||
{
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i++)
|
||||
{
|
||||
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
|
||||
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a base-64 string
|
||||
*/
|
||||
function binb2b64(binarray)
|
||||
{
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var str = "";
|
||||
for(var i = 0; i < binarray.length * 4; i += 3)
|
||||
{
|
||||
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
|
||||
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
|
||||
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
|
||||
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
@ -71,7 +71,7 @@ Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de>
|
||||
|
||||
--- a/mm/page_alloc.c
|
||||
+++ b/mm/page_alloc.c
|
||||
@@ -5909,7 +5909,7 @@ static void __ref alloc_node_mem_map(str
|
||||
@@ -5921,7 +5921,7 @@ static void __ref alloc_node_mem_map(str
|
||||
mem_map = NODE_DATA(0)->node_mem_map;
|
||||
#if defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) || defined(CONFIG_FLATMEM)
|
||||
if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
|
||||
|
Loading…
Reference in New Issue
Block a user