From 8e2184a58d1b951317813f8257376f499973bf73 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Fri, 12 Jan 2018 15:43:10 +0800 Subject: [PATCH] replace kuainiao with xlnetacc from sensel --- package/lean/luci-app-kuainiao/Makefile | 17 - .../luasrc/controller/kuainiao.lua | 34 - .../luasrc/model/cbi/kuainiao.lua | 59 -- .../luasrc/view/kuainiao/kuainiao_rsa.htm | 25 - .../luasrc/view/kuainiao/kuainiao_status.htm | 38 -- .../luci-app-kuainiao/po/zh-cn/kuainiao.po | 4 - .../root/etc/config/kuainiao | 8 - .../root/etc/hotplug.d/iface/99-kuainiao | 15 - .../root/etc/init.d/kuainiao | 45 -- .../root/etc/uci-defaults/luci-kuainiao | 9 - .../luci-app-kuainiao/root/usr/bin/kuainiao | 606 ------------------ .../root/usr/bin/luci_kuainiao_apply | 12 - .../usr/share/kuainiao/kuainiao_down_state | 1 - .../root/usr/share/kuainiao/kuainiao_up_state | 1 - .../root/www/luci-static/resources/md5.js | 1 - .../root/www/luci-static/resources/sha1.js | 202 ------ package/lean/luci-app-xlnetacc/Makefile | 71 ++ .../files/luci/controller/xlnetacc.lua | 47 ++ .../files/luci/i18n/xlnetacc.zh-cn.lmo | Bin 0 -> 1188 bytes .../files/luci/i18n/xlnetacc.zh-cn.po | 92 +++ .../luci-static/resources/xlnetacc/md5-min.js | 9 + .../luci-static/resources/xlnetacc}/rsa.js | 0 .../resources/xlnetacc/sha1-min.js | 9 + .../files/luci/model/cbi/xlnetacc.lua | 40 ++ .../files/luci/view/xlnetacc/logview.htm | 49 ++ .../files/luci/view/xlnetacc/rsa.htm | 41 ++ .../files/luci/view/xlnetacc/status.htm | 21 + .../files/root/etc/config/xlnetacc | 5 + .../files/root/etc/init.d/xlnetacc | 44 ++ .../files/root/etc/uci-defaults/luci-xlnetacc | 22 + .../files/root/usr/bin/xlnetacc.sh | 512 +++++++++++++++ .../luci-app-xlnetacc/tools/po2lmo/Makefile | 12 + .../tools/po2lmo/src/po2lmo.c | 247 +++++++ .../tools/po2lmo/src/template_lmo.c | 328 ++++++++++ .../tools/po2lmo/src/template_lmo.h | 92 +++ 35 files changed, 1641 insertions(+), 1077 deletions(-) delete mode 100644 package/lean/luci-app-kuainiao/Makefile delete mode 100644 package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua delete mode 100644 package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua delete mode 100644 package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm delete mode 100644 package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm delete mode 100644 package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po delete mode 100644 package/lean/luci-app-kuainiao/root/etc/config/kuainiao delete mode 100755 package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao delete mode 100755 package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao delete mode 100755 package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao delete mode 100755 package/lean/luci-app-kuainiao/root/usr/bin/kuainiao delete mode 100755 package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply delete mode 100644 package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state delete mode 100644 package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state delete mode 100644 package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js delete mode 100644 package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js create mode 100644 package/lean/luci-app-xlnetacc/Makefile create mode 100644 package/lean/luci-app-xlnetacc/files/luci/controller/xlnetacc.lua create mode 100644 package/lean/luci-app-xlnetacc/files/luci/i18n/xlnetacc.zh-cn.lmo create mode 100644 package/lean/luci-app-xlnetacc/files/luci/i18n/xlnetacc.zh-cn.po create mode 100644 package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/md5-min.js rename package/lean/{luci-app-kuainiao/root/www/luci-static/resources => luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc}/rsa.js (100%) create mode 100644 package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/sha1-min.js create mode 100644 package/lean/luci-app-xlnetacc/files/luci/model/cbi/xlnetacc.lua create mode 100644 package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/logview.htm create mode 100644 package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/rsa.htm create mode 100644 package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/status.htm create mode 100644 package/lean/luci-app-xlnetacc/files/root/etc/config/xlnetacc create mode 100755 package/lean/luci-app-xlnetacc/files/root/etc/init.d/xlnetacc create mode 100755 package/lean/luci-app-xlnetacc/files/root/etc/uci-defaults/luci-xlnetacc create mode 100644 package/lean/luci-app-xlnetacc/files/root/usr/bin/xlnetacc.sh create mode 100644 package/lean/luci-app-xlnetacc/tools/po2lmo/Makefile create mode 100644 package/lean/luci-app-xlnetacc/tools/po2lmo/src/po2lmo.c create mode 100644 package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.c create mode 100644 package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.h diff --git a/package/lean/luci-app-kuainiao/Makefile b/package/lean/luci-app-kuainiao/Makefile deleted file mode 100644 index 6e8319b3f..000000000 --- a/package/lean/luci-app-kuainiao/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# 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 - diff --git a/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua b/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua deleted file mode 100644 index 378517c42..000000000 --- a/package/lean/luci-app-kuainiao/luasrc/controller/kuainiao.lua +++ /dev/null @@ -1,34 +0,0 @@ -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 diff --git a/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua b/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua deleted file mode 100644 index 3fec7cd00..000000000 --- a/package/lean/luci-app-kuainiao/luasrc/model/cbi/kuainiao.lua +++ /dev/null @@ -1,59 +0,0 @@ -#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 diff --git a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm deleted file mode 100644 index 9d8c45871..000000000 --- a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_rsa.htm +++ /dev/null @@ -1,25 +0,0 @@ -<%# - Copyright (C) 2017 Jian Chang - Licensed to the public under the GNU General Public License v3. --%> - - - - -<% include("cbi/map") %> - - diff --git a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm b/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm deleted file mode 100644 index 93c28e579..000000000 --- a/package/lean/luci-app-kuainiao/luasrc/view/kuainiao/kuainiao_status.htm +++ /dev/null @@ -1,38 +0,0 @@ -<%# - Copyright 2017 Lede by stones --%> - -<% include("cbi/map") %> - - -
- <%:快鸟运行状态:%><%:Collecting data...%> - - - <%:下行提速状态:%><%:Collecting data...%> - - <%:上行提速状态:%><%:Collecting data...%> -
\ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po b/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po deleted file mode 100644 index fc29d8849..000000000 --- a/package/lean/luci-app-kuainiao/po/zh-cn/kuainiao.po +++ /dev/null @@ -1,4 +0,0 @@ -msgid "Kuai Niao" -msgstr "迅雷快鸟" - - diff --git a/package/lean/luci-app-kuainiao/root/etc/config/kuainiao b/package/lean/luci-app-kuainiao/root/etc/config/kuainiao deleted file mode 100644 index 0c4db8d66..000000000 --- a/package/lean/luci-app-kuainiao/root/etc/config/kuainiao +++ /dev/null @@ -1,8 +0,0 @@ - -config kuainiao 'base' - option kuainiao_name '' - option kuainiao_passwd '' - option speed_wan 'wan' - option enabled '0' - option enable_down '1' - option enable_up '0' diff --git a/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao b/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao deleted file mode 100755 index 2f42f3093..000000000 --- a/package/lean/luci-app-kuainiao/root/etc/hotplug.d/iface/99-kuainiao +++ /dev/null @@ -1,15 +0,0 @@ -#!/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; -} \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao b/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao deleted file mode 100755 index 29f7c8adb..000000000 --- a/package/lean/luci-app-kuainiao/root/etc/init.d/kuainiao +++ /dev/null @@ -1,45 +0,0 @@ -#!/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 "暂无加速信息" > /usr/share/kuainiao/kuainiao_down_state - echo "暂无加速信息" > /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 - } -} diff --git a/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao b/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao deleted file mode 100755 index b8b12cac8..000000000 --- a/package/lean/luci-app-kuainiao/root/etc/uci-defaults/luci-kuainiao +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao b/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao deleted file mode 100755 index f5e520540..000000000 --- a/package/lean/luci-app-kuainiao/root/usr/bin/kuainiao +++ /dev/null @@ -1,606 +0,0 @@ -#!/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 "$kuainiao_down_state" > $down_state_file - else - echo "$kuainiao_down_state" > $down_state_file - fi -} - -log_up(){ - kuainiao_up_state=$1 - status=$2 - if [ "$status" -eq 1 ]; then - echo "$kuainiao_up_state" > $up_state_file - else - echo "$kuainiao_up_state" > $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 "暂无加速信息" > $down_state_file - # echo "暂无加速信息" > $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 "暂无加速信息" > $down_state_file - echo "暂无加速信息" > $up_state_file - exit 0 - } -} diff --git a/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply b/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply deleted file mode 100755 index ce48ef893..000000000 --- a/package/lean/luci-app-kuainiao/root/usr/bin/luci_kuainiao_apply +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state deleted file mode 100644 index f01ccd0f0..000000000 --- a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_down_state +++ /dev/null @@ -1 +0,0 @@ -暂无加速信息 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state b/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state deleted file mode 100644 index f01ccd0f0..000000000 --- a/package/lean/luci-app-kuainiao/root/usr/share/kuainiao/kuainiao_up_state +++ /dev/null @@ -1 +0,0 @@ -暂无加速信息 \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js deleted file mode 100644 index c1d09a94d..000000000 --- a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/md5.js +++ /dev/null @@ -1 +0,0 @@ -var md5; md5 || (md5 = function(){function i(a,b){a[b>>5]|=128<>>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<>>32-b}function r(a){for(var b=[],d=(1<e;e+=c)b[e>>5]|=(a.charCodeAt(e/c)&d)<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))}}()); \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js b/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js deleted file mode 100644 index 11014f81d..000000000 --- a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/sha1.js +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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; -} diff --git a/package/lean/luci-app-xlnetacc/Makefile b/package/lean/luci-app-xlnetacc/Makefile new file mode 100644 index 000000000..95626f913 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/Makefile @@ -0,0 +1,71 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-xlnetacc +PKG_VERSION:=1.0.0 +PKG_RELEASE:=3 + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Sense + +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=luci + CATEGORY:=LuCI + SUBMENU:=3. Applications + TITLE:=LuCI Support for XLNetAcc + PKGARCH:=all + DEPENDS:=+wget +openssl-util +endef + +define Package/$(PKG_NAME)/description + LuCI Support for XLNetAcc. +endef + +define Build/Prepare + $(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \ + po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/$(PKG_NAME)/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + ( . /etc/uci-defaults/luci-xlnetacc ) && rm -f /etc/uci-defaults/luci-xlnetacc +fi +exit 0 +endef + +define Package/$(PKG_NAME)/conffiles + /etc/config/xlnetacc +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n + $(INSTALL_DATA) $(PKG_BUILD_DIR)/xlnetacc.*.lmo $(1)/usr/lib/lua/luci/i18n/ + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller + $(INSTALL_DATA) ./files/luci/controller/*.lua $(1)/usr/lib/lua/luci/controller/ + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi + $(INSTALL_DATA) ./files/luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/ + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/xlnetacc + $(INSTALL_DATA) ./files/luci/view/xlnetacc/*.htm $(1)/usr/lib/lua/luci/view/xlnetacc/ + $(INSTALL_DIR) $(1)/www/luci-static/resources/xlnetacc + $(INSTALL_DATA) ./files/luci/luci-static/resources/xlnetacc/*.js $(1)/www/luci-static/resources/xlnetacc/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/root/etc/config/xlnetacc $(1)/etc/config/xlnetacc + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/root/etc/init.d/xlnetacc $(1)/etc/init.d/xlnetacc + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-xlnetacc $(1)/etc/uci-defaults/luci-xlnetacc + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) ./files/root/usr/bin/xlnetacc.sh $(1)/usr/bin/xlnetacc.sh +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/luci-app-xlnetacc/files/luci/controller/xlnetacc.lua b/package/lean/luci-app-xlnetacc/files/luci/controller/xlnetacc.lua new file mode 100644 index 000000000..65fbcb921 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/controller/xlnetacc.lua @@ -0,0 +1,47 @@ +module("luci.controller.xlnetacc", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/xlnetacc") then + return + end + + entry({"admin", "services", "xlnetacc"}, + firstchild(), _("XLNetAcc")).dependent = false + + entry({"admin", "services", "xlnetacc", "general"}, + cbi("xlnetacc"), _("Settings"), 1) + + entry({"admin", "services", "xlnetacc", "log"}, + template("xlnetacc/logview"), _("Log"), 2) + + entry({"admin", "services", "xlnetacc", "status"}, call("action_status")) + entry({"admin", "services", "xlnetacc", "logdata"}, call("action_log")) +end + +local function is_running(name) + return luci.sys.call("pidof %s >/dev/null" %{name}) == 0 +end + +function action_status() + luci.http.prepare_content("application/json") + luci.http.write_json({ + run_state = is_running("xlnetacc.sh"), + down_state = nixio.fs.readfile("/var/state/xlnetacc_down_state") or "", + up_state = nixio.fs.readfile("/var/state/xlnetacc_up_state") or "" + }) +end + +function action_log() + local uci = require "luci.model.uci".cursor() + local util = require "luci.util" + local log_data = { } + + log_data.syslog = util.trim(util.exec("logread | grep xlnetacc")) + if uci:get("xlnetacc", "general", "logging") ~= "0" then + log_data.client = nixio.fs.readfile("/var/log/xlnetacc.log") or "" + end + uci:unload("xlnetacc") + + luci.http.prepare_content("application/json") + luci.http.write_json(log_data) +end diff --git a/package/lean/luci-app-xlnetacc/files/luci/i18n/xlnetacc.zh-cn.lmo b/package/lean/luci-app-xlnetacc/files/luci/i18n/xlnetacc.zh-cn.lmo new file mode 100644 index 0000000000000000000000000000000000000000..b0598e96332e5d7e96c38bcafdeae3497e9f721e GIT binary patch literal 1188 zcmZWnZ)j6j9KG2johD3)jEUkXqLe|cewmIcwF<6oY)tH?So=W{w4#VqP{D2{#U|Nn zn>?2^?b1S0W7=5ld+Bt|GtD!_Rj{^9LV&q}gCY#i71*zzzl1h~>BP$wWoVK``FF`$NJ$zbIob2LN!*iJm z?ONJL6^RPx^1@)4e&%$|Og|eTL{l1}n?+0)j|uO^ z%sQIVOHjL`$D|yG>sf2m%-6D=%q0^-BWc!g(VT>eGS);a;{?p_HXEDmhFH#TPH#v_ zs^y>+Bm*MWp`JJ2Ba0E>l3Wa$3h;O z3r}a7(3=VgD*6mh4**jd^z&)lDHWpdAdcHN&DcA7g*8k01F4gY+&nh?t(JeyOx*dG(0;bxQ{yVe>`nTZo9R-2!j}88|3;H?kU--w` zbX{hu0J@XwD@y0M`iD2Khh7YBFM1I@sTM3R1OF1-T5KI(^;O-=I{3@M?ca%A`{OG@ zpMZmH`iO9$QlOq)}S$h5kd1uiID} z_|emec@}`Lj@^4x-u`**7U;S8r0Q4K_l#5)LgV+-F;X-(T%6d#?{k#<{~B{I6DA*g z27DjKare`&PZX}XRs16){e=binl_md5(e,c.length*8)}var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}var g=binl_md5(a.concat(rstr2binl(f)),512+f.length*8);return binl2rstr(binl_md5(d.concat(g),512+128))}function rstr2hex(c){try{hexcase}catch(g){hexcase=0}var f=hexcase?"0123456789ABCDEF":"0123456789abcdef";var b="";var a;for(var d=0;d>>4)&15)+f.charAt(a&15)}return b}function str2rstr_utf8(c){var b="";var d=-1;var a,e;while(++d>>6)&31),128|(a&63))}else{if(a<=65535){b+=String.fromCharCode(224|((a>>>12)&15),128|((a>>>6)&63),128|(a&63))}else{if(a<=2097151){b+=String.fromCharCode(240|((a>>>18)&7),128|((a>>>12)&63),128|((a>>>6)&63),128|(a&63))}}}}}return b}function rstr2binl(b){var a=Array(b.length>>2);for(var c=0;c>5]|=(b.charCodeAt(c/8)&255)<<(c%32)}return a}function binl2rstr(b){var a="";for(var c=0;c>5]>>>(c%32))&255)}return a}function binl_md5(p,k){p[k>>5]|=128<<((k)%32);p[(((k+64)>>>9)<<4)+14]=k;var o=1732584193;var n=-271733879;var m=-1732584194;var l=271733878;for(var g=0;g>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}function bit_rol(a,b){return(a<>>(32-b))}; \ No newline at end of file diff --git a/package/lean/luci-app-kuainiao/root/www/luci-static/resources/rsa.js b/package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/rsa.js similarity index 100% rename from package/lean/luci-app-kuainiao/root/www/luci-static/resources/rsa.js rename to package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/rsa.js diff --git a/package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/sha1-min.js b/package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/sha1-min.js new file mode 100644 index 000000000..cb5544618 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/luci-static/resources/xlnetacc/sha1-min.js @@ -0,0 +1,9 @@ +/* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined + * in FIPS 180-1 + * Version 2.2 Copyright Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + */ +var hexcase=0;var b64pad="";function hex_sha1(a){return rstr2hex(rstr_sha1(str2rstr_utf8(a)))}function hex_hmac_sha1(a,b){return rstr2hex(rstr_hmac_sha1(str2rstr_utf8(a),str2rstr_utf8(b)))}function sha1_vm_test(){return hex_sha1("abc").toLowerCase()=="a9993e364706816aba3e25717850c26c9cd0d89d"}function rstr_sha1(a){return binb2rstr(binb_sha1(rstr2binb(a),a.length*8))}function rstr_hmac_sha1(c,f){var e=rstr2binb(c);if(e.length>16){e=binb_sha1(e,c.length*8)}var a=Array(16),d=Array(16);for(var b=0;b<16;b++){a[b]=e[b]^909522486;d[b]=e[b]^1549556828}var g=binb_sha1(a.concat(rstr2binb(f)),512+f.length*8);return binb2rstr(binb_sha1(d.concat(g),512+160))}function rstr2hex(c){try{hexcase}catch(g){hexcase=0}var f=hexcase?"0123456789ABCDEF":"0123456789abcdef";var b="";var a;for(var d=0;d>>4)&15)+f.charAt(a&15)}return b}function str2rstr_utf8(c){var b="";var d=-1;var a,e;while(++d>>6)&31),128|(a&63))}else{if(a<=65535){b+=String.fromCharCode(224|((a>>>12)&15),128|((a>>>6)&63),128|(a&63))}else{if(a<=2097151){b+=String.fromCharCode(240|((a>>>18)&7),128|((a>>>12)&63),128|((a>>>6)&63),128|(a&63))}}}}}return b}function rstr2binb(b){var a=Array(b.length>>2);for(var c=0;c>5]|=(b.charCodeAt(c/8)&255)<<(24-c%32)}return a}function binb2rstr(b){var a="";for(var c=0;c>5]>>>(24-c%32))&255)}return a}function binb_sha1(v,o){v[o>>5]|=128<<(24-o%32);v[((o+64>>9)<<4)+15]=o;var y=Array(80);var u=1732584193;var s=-271733879;var r=-1732584194;var q=271733878;var p=-1009589776;for(var l=0;l>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)}function bit_rol(a,b){return(a<>>(32-b))}; \ No newline at end of file diff --git a/package/lean/luci-app-xlnetacc/files/luci/model/cbi/xlnetacc.lua b/package/lean/luci-app-xlnetacc/files/luci/model/cbi/xlnetacc.lua new file mode 100644 index 000000000..3408a1ff9 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/model/cbi/xlnetacc.lua @@ -0,0 +1,40 @@ +local m, s, o +local uci = luci.model.uci.cursor() + +m = Map("xlnetacc", "%s - %s" %{translate("XLNetAcc"), translate("Settings")}, translate("XLNetAcc is a Thunder joint broadband operators launched a commitment to help users solve the low broadband, slow Internet access, poor Internet experience of professional-grade broadband upgrade software.")) +m:append(Template("xlnetacc/status")) + +s = m:section(NamedSection, "general", "general", translate("General Settings")) +s.anonymous = true +s.addremove = false + +o = s:option(Flag, "enabled", translate("Enabled")) +o.rmempty = false + +o = s:option(Flag, "down_acc", translate("Enable DownLink Upgrade")) + +o = s:option(Flag, "up_acc", translate("Enable UpLink Upgrade")) + +o = s:option(Flag, "logging", translate("Enable Logging")) +o.default = "1" + +o = s:option(Flag, "verbose", translate("Enable verbose logging")) +o:depends("logging", "1") + +o = s:option(ListValue, "network", translate("Upgrade interface")) +uci:foreach("network", "interface", function(section) + if section[".name"] ~= "loopback" and section[".name"] ~= "lan" then + o:value(section[".name"]) + end +end) + +o = s:option(Value, "account", translate("XLNetAcc account")) + +o = s:option(Value, "password", translate("XLNetAcc password"), translate("Does not store the plaintext password, automatically emptied after start.")) +o.password = true +o.template = "xlnetacc/rsa" + +o = s:option(Value, "encrypt", translate("Encrypted password"), translate("Auto-generate in accordance with the plaintext password, do not modify it!")) +--o.readonly = true + +return m diff --git a/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/logview.htm b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/logview.htm new file mode 100644 index 000000000..a07a27112 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/logview.htm @@ -0,0 +1,49 @@ +<% css = [[ + #log_text { + padding: 10px; + text-align: left; + height: 500px; + overflow: auto; + } + #log_text pre { + word-break: break-all; + margin: 0; + } + .description { + color: #ffffff; + background-color: #0099ff; + } +]] +%> + +<%+header%> + +
+

<%:XLNetAcc%> - <%:Log Data%>

+
+
+
<%:Loading...%><%:Collecting data...%>
+
<%:Refresh every 5 seconds.%>
+
+
+
+ + + + +<%+footer%> diff --git a/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/rsa.htm b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/rsa.htm new file mode 100644 index 000000000..b79dbf11a --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/rsa.htm @@ -0,0 +1,41 @@ + + + + + + +<%+cbi/valueheader%> + 0, "data-choices", { self.keylist, self.vallist }) + %> onchange="onchange_rsa(this.id)" /> + <% if self.password then %><% end %> +<%+cbi/valuefooter%> diff --git a/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/status.htm b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/status.htm new file mode 100644 index 000000000..4af0731d0 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/luci/view/xlnetacc/status.htm @@ -0,0 +1,21 @@ +
+ <%:Running Status%> + + + + +
<%:XLNetAcc Running Status%><%:Collecting data...%>
<%:DownLink Upgrade Status%><%:Collecting data...%>
<%:UpLink Upgrade Status%><%:Collecting data...%>
+
+ + diff --git a/package/lean/luci-app-xlnetacc/files/root/etc/config/xlnetacc b/package/lean/luci-app-xlnetacc/files/root/etc/config/xlnetacc new file mode 100644 index 000000000..4345070c4 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/root/etc/config/xlnetacc @@ -0,0 +1,5 @@ + +config general 'general' + option enabled '0' + option network 'wan' + diff --git a/package/lean/luci-app-xlnetacc/files/root/etc/init.d/xlnetacc b/package/lean/luci-app-xlnetacc/files/root/etc/init.d/xlnetacc new file mode 100755 index 000000000..f4ffef0a2 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/root/etc/init.d/xlnetacc @@ -0,0 +1,44 @@ +#!/bin/sh /etc/rc.common + +START=95 +STOP=10 +SERVICE_DAEMONIZE=1 + +NAME=xlnetacc + +start() { + pidof "${NAME}.sh" >/dev/null 2>&1 && return + + config_load "$NAME" + config_get_bool enabled "general" "enabled" 0 + config_get_bool down_acc "general" "down_acc" 0 + config_get_bool up_acc "general" "up_acc" 0 + config_get network "general" "network" + config_get account "general" "account" + config_get encrypt "general" "encrypt" + ( [ $enabled -eq 0 ] || [ $down_acc -eq 0 -a $up_acc -eq 0 ] || [ -z "$account" -o -z "$encrypt" -o -z "$network" ] ) && return + + logger -p "daemon.notice" -t "$NAME" "XLNetAcc is starting ..." + service_start /usr/bin/${NAME}.sh --start +} + +stop() { + pidof "${NAME}.sh" >/dev/null 2>&1 || return + + local pid spid + for pid in $(pidof "${NAME}.sh"); do + kill $pid >/dev/null 2>&1 + echo "Stop XLNetAcc process PID: $pid" + for spid in $(pgrep -P $pid "sleep"); do + kill $spid >/dev/null 2>&1 + echo "Stop XLNetAcc process SPID: $spid" + done + done + logger -p "daemon.notice" -t "$NAME" "XLNetAcc has stoped." +} + +restart() { + stop + sleep 1 + start +} diff --git a/package/lean/luci-app-xlnetacc/files/root/etc/uci-defaults/luci-xlnetacc b/package/lean/luci-app-xlnetacc/files/root/etc/uci-defaults/luci-xlnetacc new file mode 100755 index 000000000..632c02678 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/root/etc/uci-defaults/luci-xlnetacc @@ -0,0 +1,22 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@xlnetacc[-1] + add ucitrack xlnetacc + set ucitrack.@xlnetacc[-1].init=xlnetacc + commit ucitrack +EOF + +general=$(uci -q get xlnetacc.@general[-1]) +if [ -z "$general" ]; then + uci -q add xlnetacc general +fi +if [ "$general"x != "general"x ]; then + uci -q batch <<-EOF >/dev/null + rename xlnetacc.@general[-1]="general" + commit xlnetacc + EOF +fi + +rm -rf /tmp/luci-indexcache /tmp/luci-modulecache +exit 0 diff --git a/package/lean/luci-app-xlnetacc/files/root/usr/bin/xlnetacc.sh b/package/lean/luci-app-xlnetacc/files/root/usr/bin/xlnetacc.sh new file mode 100644 index 000000000..61e938e9f --- /dev/null +++ b/package/lean/luci-app-xlnetacc/files/root/usr/bin/xlnetacc.sh @@ -0,0 +1,512 @@ +#!/bin/sh + +# 声明常量 +readonly appName='com.xunlei.vip.swjsq' +readonly protocolVersion=108 +readonly sdkVersion=17550 +readonly agentVersion='1.6.1.177600' +readonly client_type_down='android-swjsq' +readonly client_version_down='2.0.3.4' +readonly client_type_up='android-uplink' +readonly client_version_up='2.3.3.9' +readonly client_os='android-7.0.24DUK-AL20' + +# 声明全局变量 +_http_cmd= +_http_args= +_devicesign= +_peerid= +_userid= +_sessionid= +_api_url_down= +_api_url_up= +_dial_account_down= +_dial_account_up= +_cur_down= +_max_down= +_cur_up= +_max_up= +access_url= +msg_to_en= +msg_to_cn= + +# 包含用于解析 JSON 格式返回值的函数 +. /usr/share/libubox/jshn.sh + +# 读取 UCI 设置相关函数 +uci_get_by_name() { + local ret=$(uci get $NAME.$1.$2 2> /dev/null) + echo -n ${ret:=$3} +} +uci_get_by_type() { + local ret=$(uci get $NAME.@$1[-1].$2 2> /dev/null) + echo -n ${ret:=$3} +} +uci_get_by_bool() { + case $(uci_get_by_name "$1" "$2" "$3") in + 1|on|true|yes|enabled) echo -n 1;; + *) echo -n 0;; + esac +} + +# 日志和状态栏输出。1 日志文件, 2 系统日志, 4 详细模式, 8 下行状态栏, 16 上行状态栏, 32 失败状态 +_log() { + local msg=$1 + local flag=$2 + [ -z "$msg" ] && return + [ -z "$flag" ] && flag=1 + local timestamp=$(date +'%Y/%m/%d %H:%M:%S') + + [ $logging -eq 0 -a $(( $flag & 1 )) -ne 0 ] && flag=$(( $flag ^ 1 )) + if [ $verbose -eq 0 -a $(( $flag & 4 )) -ne 0 ]; then + [ $(( $flag & 1 )) -ne 0 ] && flag=$(( $flag ^ 1 )) + [ $(( $flag & 2 )) -ne 0 ] && flag=$(( $flag ^ 2 )) + fi + if [ $down_acc -eq 0 -a $(( $flag & 8 )) -ne 0 ]; then + flag=$(( $flag ^ 8 )) + [ $up_acc -ne 0 ] && flag=$(( $flag | 16 )) + fi + if [ $up_acc -eq 0 -a $(( $flag & 16 )) -ne 0 ]; then + flag=$(( $flag ^ 16 )) + [ $down_acc -ne 0 ] && flag=$(( $flag | 8 )) + fi + + [ $(( $flag & 1 )) -ne 0 ] && echo "$timestamp $msg" >> $LOGFILE 2> /dev/null + [ $(( $flag & 2 )) -ne 0 ] && logger -p "daemon.info" -t "$NAME" "$msg" + + [ $(( $flag & 32 )) -eq 0 ] && local color="green" || local color="red" + [ $(( $flag & 8 )) -ne 0 ] && echo -n "$timestamp $msg" > $down_state_file 2> /dev/null + [ $(( $flag & 16 )) -ne 0 ] && echo -n "$timestamp $msg" > $up_state_file 2> /dev/null +} + +# 清理日志 +clean_log() { + [ $logging -eq 1 -a -f "$LOGFILE" ] || return + if [ $(wc -l "$LOGFILE" | awk '{print $1}') -gt 500 ]; then + _log "清理日志文件" + local logdata=$(tail -n 300 "$LOGFILE") + echo "$logdata" > $LOGFILE 2> /dev/null + unset logdata + fi +} + +# 获取接口IP地址 +get_acc_ip() { + local acc_ipaddr + json_cleanup; json_load "$(ubus call network.interface.$network status 2> /dev/null)" >/dev/null 2>&1 + json_select "ipv4-address" >/dev/null 2>&1; json_select 1 >/dev/null 2>&1 + json_get_var acc_ipaddr "address" + [ -z "$acc_ipaddr" ] && { _log "获取网络 $network IP地址出错"; return; } + _log "acc_ipaddr is $acc_ipaddr" $(( 1 | 4 )) + + if [ "$acc_ipaddr" != "0.0.0.0" ]; then + _log "绑定IP地址: $acc_ipaddr" + echo -n "$acc_ipaddr" + fi +} + +# 定义基本 HTTP 命令和参数 +gen_http_cmd() { + _http_cmd="wget-ssl -nv -t 1 -O - --no-check-certificate" + _http_cmd="$_http_cmd --bind-address=$1" + _http_cmd="$_http_cmd --user-agent=android-async-http/xl-acc-sdk/version-$agentVersion" + _log "_http_cmd is $_http_cmd" $(( 1 | 4 )) +} + +# 生成设备签名 +gen_device_sign() { + local ifname macaddr + while : ; do + ifname=$(uci get "network.$network.ifname" 2> /dev/null) + [ "${ifname:0:1}" == "@" ] && network="${ifname:1}" || break + done + [ -z "$ifname" ] && { _log "获取网络 $network 信息出错"; return; } + json_cleanup; json_load "$(ubus call network.device status {\"name\":\"$ifname\"} 2> /dev/null)" >/dev/null 2>&1 + json_get_var macaddr "macaddr" + [ -z "$macaddr" ] && { _log "获取网络 $network MAC地址出错"; return; } + macaddr=$(echo -n "$macaddr" | awk '{print toupper($0)}') + + # 根据MAC地址生成peerid + readonly _peerid="${macaddr//:/}004V" + _log "_peerid is $_peerid" $(( 1 | 4 )) + + # 根据MAC地址生成devicesign + local xlnetacc_vip="${appName}68700d1872b772946a6940e4b51827e8af" + local fake_device_id_md5=$(echo -n "$macaddr" | md5sum | awk '{print $1}') + local fake_device_id_sha1=$(echo -n "$fake_device_id_md5$xlnetacc_vip" | openssl sha1 -hmac | awk '{print $2}') + readonly _devicesign="div100.$fake_device_id_md5"$(echo -n "$fake_device_id_sha1" | md5sum | awk '{print $1}') + _log "_devicesign is $_devicesign" $(( 1 | 4 )) +} + +# 帐号登录 +xlnetacc_login() { + # 生成POST数据 + json_init + json_add_string userName "$account" + json_add_int businessType 68 + json_add_string clientVersion "$client_version_down" + json_add_string appName "ANDROID-$appName" + json_add_int isCompressed 0 + json_add_int sequenceNo 1000001 + json_add_string sessionID + json_add_int loginType 0 + json_add_object rsaKey + json_add_string e '010001' + json_add_string n 'AC69F5CCC8BDE47CD3D371603748378C9CFAD2938A6B021E0E191013975AD683F5CBF9ADE8BD7D46B4D2EC2D78AF146F1DD2D50DC51446BB8880B8CE88D476694DFC60594393BEEFAA16F5DBCEBE22F89D640F5336E42F587DC4AFEDEFEAC36CF007009CCCE5C1ACB4FF06FBA69802A8085C2C54BADD0597FC83E6870F1E36FD' + json_close_object + json_add_int cmdID 1 + json_add_string verifyCode + json_add_string peerID "$_peerid" + json_add_int protocolVersion $protocolVersion + json_add_int platformVersion 1 + json_add_string passWord "$encrypt" + json_add_string extensionList + json_add_string verifyKey + json_add_int sdkVersion $sdkVersion + json_add_string devicesign "$_devicesign" + json_close_object + + local ret=$($_http_cmd 'https://login.mobile.reg2t.sandai.net:443/' --post-data="$(json_dump)") + _log "ret is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno + json_get_var errno "errorCode" + json_get_var _userid "userID" + _log "_userid is $_userid" $(( 1 | 4 )) + json_get_var _sessionid "sessionID" + _log "_sessionid is $_sessionid" $(( 1 | 4 )) + + if [ ${errno:=-1} -ne 0 ] || [ -z "$_userid" -o -z "$_sessionid" ]; then + local errorDesc + json_get_var errorDesc "errorDesc" + local outmsg="帐号登录失败。错误代码: ${errno}"; \ + [ -n "$errorDesc" ] && outmsg="${outmsg},原因: $errorDesc"; _log "$outmsg" $(( 1 | 8 | 16 | 32 )) + else + local outmsg="帐号登录成功"; _log "$outmsg" $(( 1 | 8 | 16 )) + fi + + return $errno +} + +# 获取提速API +xlnetacc_portal() { + xlnetacc_var $1 + + [ $1 -eq 1 ] && access_url='http://api.portal.swjsq.vip.xunlei.com:81/v2/queryportal' || \ + access_url='http://api.upportal.swjsq.vip.xunlei.com/v2/queryportal' + local ret=$($_http_cmd "$access_url") + _log "$msg_to_en portal is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno portal_ip portal_port + json_get_var errno "errno" + json_get_var portal_ip "interface_ip" + json_get_var portal_port "interface_port" + + if [ ${errno:=-1} -ne 0 ] || [ -z "$portal_ip" -o -z "$portal_port" ]; then + local message + json_get_var message "message" + local outmsg="获取${msg_to_cn}API失败。错误代码: ${errno}"; \ + [ -n "$message" ] && outmsg="${outmsg},原因: $message"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + else + local outmsg="获取${msg_to_cn}API成功"; _log "$outmsg" $(( 1 | $1 * 8 )) + if [ $1 -eq 1 ]; then + _api_url_down="http://$portal_ip:$portal_port/v2" + _log "_api_url_down is $_api_url_down" $(( 1 | 4 )) + else + _api_url_up="http://$portal_ip:$portal_port/v2" + _log "_api_url_up is $_api_url_up" $(( 1 | 4 )) + fi + fi + + return $errno +} + +# 获取网络带宽信息 +xlnetacc_bandwidth() { + xlnetacc_var $1 + + local ret=$($_http_cmd "$access_url/bandwidth?${_http_args}&time_and=$(date +%s)000") + _log "$msg_to_en bandwidth is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno can_upgrade dial_account richmessage + json_get_var errno "errno" + json_get_var can_upgrade "can_upgrade" + json_get_var dial_account "dial_account" + json_get_var richmessage "richmessage" + + # 获取带宽数据 + local cur_bandwidth max_bandwidth flag + [ $1 -eq 1 ] && flag="downstream" || flag="upstream" + json_select "bandwidth" >/dev/null 2>&1 + json_get_var cur_bandwidth "$flag" + json_select; json_select "max_bandwidth" >/dev/null 2>&1 + json_get_var max_bandwidth "$flag" + cur_bandwidth=$(expr $cur_bandwidth / 1024 2> /dev/null) + max_bandwidth=$(expr $max_bandwidth / 1024 2> /dev/null) + + if [ ${errno:=-1} -ne 0 ]; then + local outmsg="获取${msg_to_cn}带宽信息失败。错误代码: ${errno}"; \ + [ -n "$richmessage" ] && outmsg="${outmsg},原因: $richmessage"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + elif [ "$can_upgrade" -eq 0 ]; then + local outmsg="${msg_to_cn}无法提速"; \ + [ -n "$richmessage" ] && outmsg="${outmsg},原因: $richmessage"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + [ $1 -eq 1 ] && down_acc=0 || up_acc=0 + errno=-2 + elif [ "$cur_bandwidth" -ge "$max_bandwidth" ]; then + local outmsg="${msg_to_cn}无需提速。当前带宽 ${cur_bandwidth}M,超过最大可提升带宽 ${max_bandwidth}M"; \ + _log "$outmsg" $(( 1 | $1 * 8 )) + [ $1 -eq 1 ] && down_acc=0 || up_acc=0 + errno=-3 + else + local outmsg="${msg_to_cn}可以提速。当前带宽 ${cur_bandwidth}M,可提升至 ${max_bandwidth}M"; _log "$outmsg" $(( 1 | $1 * 8 )) + if [ $1 -eq 1 ]; then + _dial_account_down=$dial_account + _log "_dial_account_down is $_dial_account_down" $(( 1 | 4 )) + _cur_down=$cur_bandwidth + _log "_cur_down is $_cur_down" $(( 1 | 4 )) + _max_down=$max_bandwidth + _log "_max_down is $_max_down" $(( 1 | 4 )) + else + _dial_account_up=$dial_account + _log "_dial_account_up is $_dial_account_up" $(( 1 | 4 )) + _cur_up=$cur_bandwidth + _log "_cur_up is $_cur_up" $(( 1 | 4 )) + _max_up=$max_bandwidth + _log "_max_up is $_max_up" $(( 1 | 4 )) + fi + fi + + return $errno +} + +# 发送带宽提速信号 +xlnetacc_upgrade() { + xlnetacc_var $1 + + local ret=$($_http_cmd "$access_url/upgrade?${_http_args}&time_and=$(date +%s)000") + _log "$msg_to_en upgrade is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno + json_get_var errno "errno" + + if [ ${errno:=-1} -ne 0 ]; then + local richmessage + json_get_var richmessage "richmessage" + local outmsg="${msg_to_cn}提速失败。错误代码: ${errno}"; \ + [ -n "$richmessage" ] && outmsg="${outmsg},原因: $richmessage"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + [ $errno -ne -1 ] && { [ $1 -eq 1 ] && down_acc=0 || up_acc=0; } + else + [ $1 -eq 1 ] && local cur_bandwidth=$_cur_down || local cur_bandwidth=$_cur_up + [ $1 -eq 1 ] && local max_bandwidth=$_max_down || local max_bandwidth=$_max_up + local outmsg="${msg_to_cn}提速成功,带宽已从 ${cur_bandwidth}M 提升到 ${max_bandwidth}M"; _log "$outmsg" $(( 1 | $1 * 8 )) + [ $1 -eq 1 ] && down_acc=2 || up_acc=2 + fi + + return $errno +} + +# 发送提速心跳信号 +xlnetacc_keepalive() { + xlnetacc_var $1 + + local ret=$($_http_cmd "$access_url/keepalive?${_http_args}&time_and=$(date +%s)000") + _log "$msg_to_en keepalive is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno + json_get_var errno "errno" + + if [ ${errno:=-1} -ne 0 ]; then + local richmessage + json_get_var richmessage "richmessage" + local outmsg="${msg_to_cn}提速失效。错误代码: ${errno}"; \ + [ -n "$richmessage" ] && outmsg="${outmsg},原因: $richmessage"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + [ $1 -eq 1 ] && down_acc=1 || up_acc=1 + else + _log "${msg_to_cn}心跳信号返回正常" + fi + + return $errno +} + +# 发送带宽恢复信号 +xlnetacc_recover() { + xlnetacc_var $1 + + local ret=$($_http_cmd "$access_url/recover?${_http_args}&time_and=$(date +%s)000") + _log "$msg_to_en recover is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno + json_get_var errno "errno" + + if [ ${errno:=-1} -ne 0 ]; then + local richmessage + json_get_var richmessage "richmessage" + local outmsg="${msg_to_cn}带宽恢复失败。错误代码: ${errno}"; \ + [ -n "$richmessage" ] && outmsg="${outmsg},原因: $richmessage"; _log "$outmsg" $(( 1 | $1 * 8 | 32 )) + else + _log "${msg_to_cn}带宽已恢复" + [ $1 -eq 1 ] && down_acc=1 || up_acc=1 + fi + + return $errno +} + +# 查询提速信息,未使用 +xlnetacc_query() { + xlnetacc_var $1 + + local ret=$($_http_cmd "$access_url/query_try_info?${_http_args}&time_and=$(date +%s)000") + _log "$msg_to_en query_try_info is $ret" $(( 1 | 4 )) + json_cleanup; json_load "$ret" >/dev/null 2>&1 + local errno + json_get_var errno "errno" + + return $errno +} + +# 带宽提速处理 +xlnetacc_acc() { + _api_url_down=; _api_url_up= + _dial_account_down=; _dial_account_up= + _cur_down=0; _max_down=0; _cur_up=0; _max_up=0 + + xlnetacc_portal $1 || return + xlnetacc_bandwidth $1 || return + xlnetacc_upgrade $1 +} + +# 设置参数变量 +xlnetacc_var() { + if [ $1 -eq 1 ]; then + access_url=$_api_url_down + _http_args="peerid=${_peerid}&userid=${_userid}&user_type=1&sessionid=${_sessionid}&dial_account=${_dial_account_down}&client_type=${client_type_down}-${client_version_down}&client_version=${client_type_down//-/}-${client_version_down}&os=${client_os}" + msg_to_en="DownLink" + msg_to_cn="下行" + else + access_url=$_api_url_up + _http_args="peerid=${_peerid}&userid=${_userid}&user_type=1&sessionid=${_sessionid}&dial_account=${_dial_account_up}&client_type=${client_type_up}-${client_version_up}&client_version=${client_type_up//-/}-${client_version_up}&os=${client_os}" + msg_to_en="UpLink" + msg_to_cn="上行" + fi +} + +# 中止信号处理 +sigterm() { + _log "trap sigterm, exit" $(( 1 | 4 )) + [ $down_acc -eq 2 ] && xlnetacc_recover 1 + [ $up_acc -eq 2 ] && xlnetacc_recover 2 + rm -f "$down_state_file" "$up_state_file" + exit 0 +} + +# 初始化 +xlnetacc_init() { + [ "$1" != "--start" ] && return 1 + + # 防止重复启动 + local pid + for pid in $(pidof "${0##*/}"); do + [ $pid -ne $$ ] && return 1 + done + + # 读取设置 + readonly NAME=xlnetacc + readonly LOGFILE=/var/log/${NAME}.log + readonly down_state_file=/var/state/${NAME}_down_state + readonly up_state_file=/var/state/${NAME}_up_state + down_acc=$(uci_get_by_bool "general" "down_acc" 0) + up_acc=$(uci_get_by_bool "general" "up_acc" 0) + readonly logging=$(uci_get_by_bool "general" "logging" 1) + readonly verbose=$(uci_get_by_bool "general" "verbose" 0) + readonly network=$(uci_get_by_name "general" "network" "wan") + readonly account=$(uci_get_by_name "general" "account") + readonly encrypt=$(uci_get_by_name "general" "encrypt") + local enabled=$(uci_get_by_bool "general" "enabled" 0) + local password=$(uci_get_by_name "general" "password") + ( [ $enabled -eq 0 ] || [ $down_acc -eq 0 -a $up_acc -eq 0 ] || [ -z "$account" -o -z "$encrypt" -o -z "$network" ] ) && return 2 + + [ $logging -eq 1 ] && [ ! -d /var/log ] && mkdir -p /var/log + _log "------------------------------" + _log "迅雷快鸟正在启动..." + _log "down_acc is $down_acc" $(( 1 | 4 )) + _log "up_acc is $up_acc" $(( 1 | 4 )) + _log "network is $network" $(( 1 | 4 )) + _log "account is $account" $(( 1 | 4 )) + _log "encrypt is $encrypt" $(( 1 | 4 )) + + # 检查外部调用工具 + command -v wget-ssl >/dev/null || { _log "GNU Wget 工具不存在"; return 3; } + command -v md5sum >/dev/null || { _log "md5sum 工具不存在"; return 3; } + command -v openssl >/dev/null || { _log "openssl 工具不存在"; return 3; } + + # 检查明文密码 + if [ -n "$password" ]; then + _log "移除已保存的明文密码" + uci delete "${NAME}.general.password" + uci commit "$NAME" + fi + + # 捕获中止信号 + trap "sigterm" INT + trap "sigterm" TERM + + # 生成设备签名 + gen_device_sign + [ -z "$_peerid" -o -z "$_devicesign" ] && return 4 + + clean_log + [ -d /var/state ] || mkdir -p /var/state + return 0 +} + +# 程序主体 +xlnetacc_main() { + while : ; do + # 获取外网IP地址 + while : ; do + local bind_ip=$(get_acc_ip) + if [ -z "$bind_ip" ]; then + sleep 5s # 获取失败 + else + gen_http_cmd "$bind_ip" + break + fi + done + + # 帐号登录 + while : ; do + xlnetacc_login + case $? in + 0) break;; # 登录成功 + 6) sleep 30m;; # 需要输入验证码,等待30分钟后重试 + -1) sleep 3m;; # 未返回有效数据,等待3分钟后重试 + *) return 5;; # 登录失败 + esac + done + + # 10秒检查提速状态,300秒发送心跳包 + local timer_begin=$(date +%s); local timer_count= + while : ; do + [ $down_acc -eq 0 -a $up_acc -eq 0 ] && break 2 + [ $down_acc -eq 1 ] && xlnetacc_acc 1 + [ $up_acc -eq 1 ] && xlnetacc_acc 2 + + sleep 10s + timer_count=$(( $(date +%s) - $timer_begin )) + [ $timer_count -lt 300 ] && continue + timer_begin=$(date +%s) + clean_log # 清理日志 + + [ $down_acc -eq 2 ] && { xlnetacc_keepalive 1; [ $? -eq -1 ] && break; } + [ $up_acc -eq 2 ] && { xlnetacc_keepalive 2; [ $? -eq -1 ] && break; } + done + [ $down_acc -eq 2 ] && { xlnetacc_recover 1; down_acc=1; } + [ $up_acc -eq 2 ] && { xlnetacc_recover 2; up_acc=1; } + done + _log "程序异常,迅雷快鸟已停止。" +} + +# 程序入口 +xlnetacc_init $* +[ $? -eq 0 ] && xlnetacc_main +exit $? diff --git a/package/lean/luci-app-xlnetacc/tools/po2lmo/Makefile b/package/lean/luci-app-xlnetacc/tools/po2lmo/Makefile new file mode 100644 index 000000000..ad2c13320 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/tools/po2lmo/Makefile @@ -0,0 +1,12 @@ + +INSTALL = install +PREFIX = /usr/bin + +po2lmo: src/po2lmo.o src/template_lmo.o + $(CC) $(LDFLAGS) -o src/po2lmo src/po2lmo.o src/template_lmo.o + +install: + $(INSTALL) -m 755 src/po2lmo $(PREFIX) + +clean: + $(RM) src/po2lmo src/*.o diff --git a/package/lean/luci-app-xlnetacc/tools/po2lmo/src/po2lmo.c b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/po2lmo.c new file mode 100644 index 000000000..0da792b68 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/po2lmo.c @@ -0,0 +1,247 @@ +/* + * lmo - Lua Machine Objects - PO to LMO conversion tool + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * 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. + */ + +#include "template_lmo.h" + +static void die(const char *msg) +{ + fprintf(stderr, "Error: %s\n", msg); + exit(1); +} + +static void usage(const char *name) +{ + fprintf(stderr, "Usage: %s input.po output.lmo\n", name); + exit(1); +} + +static void print(const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + if( fwrite(ptr, size, nmemb, stream) == 0 ) + die("Failed to write stdout"); +} + +static int extract_string(const char *src, char *dest, int len) +{ + int pos = 0; + int esc = 0; + int off = -1; + + for( pos = 0; (pos < strlen(src)) && (pos < len); pos++ ) + { + if( (off == -1) && (src[pos] == '"') ) + { + off = pos + 1; + } + else if( off >= 0 ) + { + if( esc == 1 ) + { + switch (src[pos]) + { + case '"': + case '\\': + off++; + break; + } + dest[pos-off] = src[pos]; + esc = 0; + } + else if( src[pos] == '\\' ) + { + dest[pos-off] = src[pos]; + esc = 1; + } + else if( src[pos] != '"' ) + { + dest[pos-off] = src[pos]; + } + else + { + dest[pos-off] = '\0'; + break; + } + } + } + + return (off > -1) ? strlen(dest) : -1; +} + +static int cmp_index(const void *a, const void *b) +{ + uint32_t x = ((const lmo_entry_t *)a)->key_id; + uint32_t y = ((const lmo_entry_t *)b)->key_id; + + if (x < y) + return -1; + else if (x > y) + return 1; + + return 0; +} + +static void print_uint32(uint32_t x, FILE *out) +{ + uint32_t y = htonl(x); + print(&y, sizeof(uint32_t), 1, out); +} + +static void print_index(void *array, int n, FILE *out) +{ + lmo_entry_t *e; + + qsort(array, n, sizeof(*e), cmp_index); + + for (e = array; n > 0; n--, e++) + { + print_uint32(e->key_id, out); + print_uint32(e->val_id, out); + print_uint32(e->offset, out); + print_uint32(e->length, out); + } +} + +int main(int argc, char *argv[]) +{ + char line[4096]; + char key[4096]; + char val[4096]; + char tmp[4096]; + int state = 0; + int offset = 0; + int length = 0; + int n_entries = 0; + void *array = NULL; + lmo_entry_t *entry = NULL; + uint32_t key_id, val_id; + + FILE *in; + FILE *out; + + if( (argc != 3) || ((in = fopen(argv[1], "r")) == NULL) || ((out = fopen(argv[2], "w")) == NULL) ) + usage(argv[0]); + + memset(line, 0, sizeof(key)); + memset(key, 0, sizeof(val)); + memset(val, 0, sizeof(val)); + + while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) ) + { + if( state == 0 && strstr(line, "msgid \"") == line ) + { + switch(extract_string(line, key, sizeof(key))) + { + case -1: + die("Syntax error in msgid"); + case 0: + state = 1; + break; + default: + state = 2; + } + } + else if( state == 1 || state == 2 ) + { + if( strstr(line, "msgstr \"") == line || state == 2 ) + { + switch(extract_string(line, val, sizeof(val))) + { + case -1: + state = 4; + break; + default: + state = 3; + } + } + else + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 2; + break; + default: + strcat(key, tmp); + } + } + } + else if( state == 3 ) + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 4; + break; + default: + strcat(val, tmp); + } + } + + if( state == 4 ) + { + if( strlen(key) > 0 && strlen(val) > 0 ) + { + key_id = sfh_hash(key, strlen(key)); + val_id = sfh_hash(val, strlen(val)); + + if( key_id != val_id ) + { + n_entries++; + array = realloc(array, n_entries * sizeof(lmo_entry_t)); + entry = (lmo_entry_t *)array + n_entries - 1; + + if (!array) + die("Out of memory"); + + entry->key_id = key_id; + entry->val_id = val_id; + entry->offset = offset; + entry->length = strlen(val); + + length = strlen(val) + ((4 - (strlen(val) % 4)) % 4); + + print(val, length, 1, out); + offset += length; + } + } + + state = 0; + memset(key, 0, sizeof(key)); + memset(val, 0, sizeof(val)); + } + + memset(line, 0, sizeof(line)); + } + + print_index(array, n_entries, out); + + if( offset > 0 ) + { + print_uint32(offset, out); + fsync(fileno(out)); + fclose(out); + } + else + { + fclose(out); + unlink(argv[2]); + } + + fclose(in); + return(0); +} diff --git a/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.c b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.c new file mode 100644 index 000000000..27205a722 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.c @@ -0,0 +1,328 @@ +/* + * lmo - Lua Machine Objects - Base functions + * + * Copyright (C) 2009-2010 Jo-Philipp Wich + * + * 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. + */ + +#include "template_lmo.h" + +/* + * Hash function from http://www.azillionmonkeys.com/qed/hash.html + * Copyright (C) 2004-2008 by Paul Hsieh + */ + +uint32_t sfh_hash(const char *data, int len) +{ + uint32_t hash = len, tmp; + int rem; + + if (len <= 0 || data == NULL) return 0; + + rem = len & 3; + len >>= 2; + + /* Main loop */ + for (;len > 0; len--) { + hash += sfh_get16(data); + tmp = (sfh_get16(data+2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + data += 2*sizeof(uint16_t); + hash += hash >> 11; + } + + /* Handle end cases */ + switch (rem) { + case 3: hash += sfh_get16(data); + hash ^= hash << 16; + hash ^= data[sizeof(uint16_t)] << 18; + hash += hash >> 11; + break; + case 2: hash += sfh_get16(data); + hash ^= hash << 11; + hash += hash >> 17; + break; + case 1: hash += *data; + hash ^= hash << 10; + hash += hash >> 1; + } + + /* Force "avalanching" of final 127 bits */ + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; +} + +uint32_t lmo_canon_hash(const char *str, int len) +{ + char res[4096]; + char *ptr, prev; + int off; + + if (!str || len >= sizeof(res)) + return 0; + + for (prev = ' ', ptr = res, off = 0; off < len; prev = *str, off++, str++) + { + if (isspace(*str)) + { + if (!isspace(prev)) + *ptr++ = ' '; + } + else + { + *ptr++ = *str; + } + } + + if ((ptr > res) && isspace(*(ptr-1))) + ptr--; + + return sfh_hash(res, ptr - res); +} + +lmo_archive_t * lmo_open(const char *file) +{ + int in = -1; + uint32_t idx_offset = 0; + struct stat s; + + lmo_archive_t *ar = NULL; + + if (stat(file, &s) == -1) + goto err; + + if ((in = open(file, O_RDONLY)) == -1) + goto err; + + if ((ar = (lmo_archive_t *)malloc(sizeof(*ar))) != NULL) + { + memset(ar, 0, sizeof(*ar)); + + ar->fd = in; + ar->size = s.st_size; + + fcntl(ar->fd, F_SETFD, fcntl(ar->fd, F_GETFD) | FD_CLOEXEC); + + if ((ar->mmap = mmap(NULL, ar->size, PROT_READ, MAP_SHARED, ar->fd, 0)) == MAP_FAILED) + goto err; + + idx_offset = ntohl(*((const uint32_t *) + (ar->mmap + ar->size - sizeof(uint32_t)))); + + if (idx_offset >= ar->size) + goto err; + + ar->index = (lmo_entry_t *)(ar->mmap + idx_offset); + ar->length = (ar->size - idx_offset - sizeof(uint32_t)) / sizeof(lmo_entry_t); + ar->end = ar->mmap + ar->size; + + return ar; + } + +err: + if (in > -1) + close(in); + + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + free(ar); + } + + return NULL; +} + +void lmo_close(lmo_archive_t *ar) +{ + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + close(ar->fd); + free(ar); + + ar = NULL; + } +} + + +lmo_catalog_t *_lmo_catalogs = NULL; +lmo_catalog_t *_lmo_active_catalog = NULL; + +int lmo_load_catalog(const char *lang, const char *dir) +{ + DIR *dh = NULL; + char pattern[16]; + char path[PATH_MAX]; + struct dirent *de = NULL; + + lmo_archive_t *ar = NULL; + lmo_catalog_t *cat = NULL; + + if (!lmo_change_catalog(lang)) + return 0; + + if (!dir || !(dh = opendir(dir))) + goto err; + + if (!(cat = malloc(sizeof(*cat)))) + goto err; + + memset(cat, 0, sizeof(*cat)); + + snprintf(cat->lang, sizeof(cat->lang), "%s", lang); + snprintf(pattern, sizeof(pattern), "*.%s.lmo", lang); + + while ((de = readdir(dh)) != NULL) + { + if (!fnmatch(pattern, de->d_name, 0)) + { + snprintf(path, sizeof(path), "%s/%s", dir, de->d_name); + ar = lmo_open(path); + + if (ar) + { + ar->next = cat->archives; + cat->archives = ar; + } + } + } + + closedir(dh); + + cat->next = _lmo_catalogs; + _lmo_catalogs = cat; + + if (!_lmo_active_catalog) + _lmo_active_catalog = cat; + + return 0; + +err: + if (dh) closedir(dh); + if (cat) free(cat); + + return -1; +} + +int lmo_change_catalog(const char *lang) +{ + lmo_catalog_t *cat; + + for (cat = _lmo_catalogs; cat; cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + _lmo_active_catalog = cat; + return 0; + } + } + + return -1; +} + +static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash) +{ + unsigned int m, l, r; + uint32_t k; + + l = 0; + r = ar->length - 1; + + while (1) + { + m = l + ((r - l) / 2); + + if (r < l) + break; + + k = ntohl(ar->index[m].key_id); + + if (k == hash) + return &ar->index[m]; + + if (k > hash) + { + if (!m) + break; + + r = m - 1; + } + else + { + l = m + 1; + } + } + + return NULL; +} + +int lmo_translate(const char *key, int keylen, char **out, int *outlen) +{ + uint32_t hash; + lmo_entry_t *e; + lmo_archive_t *ar; + + if (!key || !_lmo_active_catalog) + return -2; + + hash = lmo_canon_hash(key, keylen); + + for (ar = _lmo_active_catalog->archives; ar; ar = ar->next) + { + if ((e = lmo_find_entry(ar, hash)) != NULL) + { + *out = ar->mmap + ntohl(e->offset); + *outlen = ntohl(e->length); + return 0; + } + } + + return -1; +} + +void lmo_close_catalog(const char *lang) +{ + lmo_archive_t *ar, *next; + lmo_catalog_t *cat, *prev; + + for (prev = NULL, cat = _lmo_catalogs; cat; prev = cat, cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + if (prev) + prev->next = cat->next; + else + _lmo_catalogs = cat->next; + + for (ar = cat->archives; ar; ar = next) + { + next = ar->next; + lmo_close(ar); + } + + free(cat); + break; + } + } +} diff --git a/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.h b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.h new file mode 100644 index 000000000..57f59aa56 --- /dev/null +++ b/package/lean/luci-app-xlnetacc/tools/po2lmo/src/template_lmo.h @@ -0,0 +1,92 @@ +/* + * lmo - Lua Machine Objects - General header + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * 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. + */ + +#ifndef _TEMPLATE_LMO_H_ +#define _TEMPLATE_LMO_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(__GNUC__) && defined(__i386__)) +#define sfh_get16(d) (*((const uint16_t *) (d))) +#else +#define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)(((const uint8_t *)(d))[0]) ) +#endif + + +struct lmo_entry { + uint32_t key_id; + uint32_t val_id; + uint32_t offset; + uint32_t length; +} __attribute__((packed)); + +typedef struct lmo_entry lmo_entry_t; + + +struct lmo_archive { + int fd; + int length; + uint32_t size; + lmo_entry_t *index; + char *mmap; + char *end; + struct lmo_archive *next; +}; + +typedef struct lmo_archive lmo_archive_t; + + +struct lmo_catalog { + char lang[6]; + struct lmo_archive *archives; + struct lmo_catalog *next; +}; + +typedef struct lmo_catalog lmo_catalog_t; + + +uint32_t sfh_hash(const char *data, int len); +uint32_t lmo_canon_hash(const char *data, int len); + +lmo_archive_t * lmo_open(const char *file); +void lmo_close(lmo_archive_t *ar); + + +extern lmo_catalog_t *_lmo_catalogs; +extern lmo_catalog_t *_lmo_active_catalog; + +int lmo_load_catalog(const char *lang, const char *dir); +int lmo_change_catalog(const char *lang); +int lmo_translate(const char *key, int keylen, char **out, int *outlen); +void lmo_close_catalog(const char *lang); + +#endif