Merge branch 'master' of github.com:shell-script/lede
This commit is contained in:
commit
117c5ce163
@ -6,13 +6,13 @@ ifdef CONFIG_TESTING_KERNEL
|
||||
KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
|
||||
endif
|
||||
|
||||
LINUX_VERSION-4.9 = .177
|
||||
LINUX_VERSION-4.14 = .120
|
||||
LINUX_VERSION-4.19 = .44
|
||||
LINUX_VERSION-4.9 = .178
|
||||
LINUX_VERSION-4.14 = .121
|
||||
LINUX_VERSION-4.19 = .45
|
||||
|
||||
LINUX_KERNEL_HASH-4.9.177 = c73b1e3ebcc35b653f7b673ca151fc67b814bdb27269799fa7cda251827887ee
|
||||
LINUX_KERNEL_HASH-4.14.120 = ddb8e86cf65e6f53f782bc46f026823b6b3fc472aa1385b601f22dce2dbccb4c
|
||||
LINUX_KERNEL_HASH-4.19.44 = 707642e993775618a5afa039b1058fa49f1c0faada46e8cdcb976241bca6b288
|
||||
LINUX_KERNEL_HASH-4.9.178 = 13ffd8b0725d9ce9f9e927f4748ef640b049d7c69f21b28ca0d976cc23072566
|
||||
LINUX_KERNEL_HASH-4.14.121 = 2eecd6825a0998c8b6dd686cd4cd76e9f0d195bbace89f0b82495cc11ddb2884
|
||||
LINUX_KERNEL_HASH-4.19.45 = eb31e62fbb30aaeedb892cecdd8ac9746d42cbbef2ef2356f9ca8e13514b9d2b
|
||||
|
||||
remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
|
||||
sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=default-settings
|
||||
PKG_VERSION:=1.0
|
||||
PKG_VERSION:=1.1
|
||||
PKG_RELEASE:=39
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
@ -55,7 +55,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='R9.5.6'" >> /etc/openwrt_release
|
||||
echo "DISTRIB_REVISION='R9.6.1'" >> /etc/openwrt_release
|
||||
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
|
||||
echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ LUCI_DEPENDS:=
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-accesscontrol
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=9
|
||||
PKG_RELEASE:=11
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
@ -6,7 +6,13 @@ function index()
|
||||
end
|
||||
|
||||
entry({"admin","services","mia"},cbi("mia"),_("Internet Access Schedule Control"),30).dependent=true
|
||||
entry({"admin","services","mia","status"},call("act_status")).leaf=true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("iptables -L INPUT |grep MIA >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
a=Map("mia",translate("Internet Access Schedule Control"),translate("Access Schedule Control Settins"))
|
||||
a:section(SimpleSection).template = "mia/mia_status"
|
||||
|
||||
t=a:section(TypedSection,"basic")
|
||||
t.anonymous=true
|
||||
@ -7,6 +8,10 @@ t.anonymous=true
|
||||
e=t:option(Flag,"enable",translate("Enabled"))
|
||||
e.rmempty=false
|
||||
|
||||
e=t:option(Flag,"strict",translate("Strict Mode"))
|
||||
e.rmempty=false
|
||||
e.description = translate("Strict Mode will degrade CPU performance, but it can achieve better results")
|
||||
|
||||
t=a:section(TypedSection,"macbind",translate("Client Rules"))
|
||||
t.template="cbi/tblsection"
|
||||
t.anonymous=true
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[mia]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('mia_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green><%:Internet Access Schedule Control%> <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red><%:Internet Access Schedule Control%> <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="mia_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@ -7,6 +7,12 @@ msgstr "设置客户端禁止访问互联网的时间"
|
||||
msgid "General switch"
|
||||
msgstr "开启/关闭"
|
||||
|
||||
msgid "Strict Mode"
|
||||
msgstr "严格模式"
|
||||
|
||||
msgid "Strict Mode will degrade CPU performance, but it can achieve better results"
|
||||
msgstr "严格模式会损耗部分CPU资源,但可以按照时间规则立即拦截数据包,效果更好"
|
||||
|
||||
msgid "Client Rules"
|
||||
msgstr "客户端规则"
|
||||
|
||||
|
||||
@ -73,9 +73,12 @@ start(){
|
||||
iptables -I INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIA
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
|
||||
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
|
||||
strict=$(uci get mia.@basic[0].strict)
|
||||
[ $strict -eq 1 ] && iptables -t filter -I FORWARD -m comment --comment "Rule For Control" -j MIA
|
||||
add_rule
|
||||
}
|
||||
stop(){
|
||||
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j MIA 2>/dev/null
|
||||
iptables -D INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIA 2>/dev/null
|
||||
iptables -D INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIA 2>/dev/null
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null
|
||||
|
||||
18
package/lean/luci-app-familycloud/Makefile
Normal file
18
package/lean/luci-app-familycloud/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
# 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 FamilyCloudSpeeder
|
||||
LUCI_DEPENDS:=+coreutils +coreutils-nohup +libreadline +libcurl +libopenssl +bash +curl +wget +openssl-util +ca-certificates +ca-bundle
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-familycloud
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=5
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
|
||||
module("luci.controller.familycloud", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/familycloud") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "familycloud"},firstchild(), _("天翼家庭云/云盘提速"), 80).dependent = false
|
||||
|
||||
entry({"admin", "services", "familycloud", "general"},cbi("familycloud"), _("Base Setting"), 1)
|
||||
entry({"admin", "services", "familycloud", "log"},form("familycloudlog"), _("Log"), 2)
|
||||
|
||||
entry({"admin","services","familycloud","status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("ps | grep speedup.sh | grep -v grep >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
|
||||
mp = Map("familycloud", translate("天翼家庭云/天翼云盘提速"))
|
||||
mp.description = translate("天翼家庭云/天翼云盘提速 (最高可达500Mbps)")
|
||||
|
||||
mp:section(SimpleSection).template = "familycloud/familycloud_status"
|
||||
|
||||
s = mp:section(TypedSection, "familycloud")
|
||||
s.anonymous=true
|
||||
s.addremove=false
|
||||
|
||||
enabled = s:option(Flag, "enabled", translate("启用提速"))
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
|
||||
speedtype = s:option(ListValue, "speedertype", translate("天翼提速包类型"))
|
||||
speedtype:value("CloudDisk", translate("天翼云盘提速"))
|
||||
speedtype:value("FamilyCloud", translate("天翼家庭云提速"))
|
||||
|
||||
account = s:option(Value, "token", translate("AccessToken"))
|
||||
account.datatype = "string"
|
||||
|
||||
return mp
|
||||
@ -0,0 +1,14 @@
|
||||
local fs = require "nixio.fs"
|
||||
local conffile = "/tmp/familycloud.log"
|
||||
|
||||
f = SimpleForm("logview")
|
||||
|
||||
t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 15
|
||||
function t.cfgvalue()
|
||||
return fs.readfile(conffile) or ""
|
||||
end
|
||||
t.readonly="readonly"
|
||||
|
||||
return f
|
||||
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[familycloud]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('familycloud_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>Family cloud <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>Family cloud <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="familycloud_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@ -0,0 +1,6 @@
|
||||
|
||||
config familycloud
|
||||
option token 'f18a1952289c4659b3722ad54d3d92fb'
|
||||
option speedertype 'CloudDisk'
|
||||
option enabled '0'
|
||||
|
||||
25
package/lean/luci-app-familycloud/root/etc/init.d/familycloud
Executable file
25
package/lean/luci-app-familycloud/root/etc/init.d/familycloud
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
TYPE=$(uci get familycloud.@familycloud[0].speedertype)
|
||||
TOKEN=$(uci get familycloud.@familycloud[0].token)
|
||||
|
||||
|
||||
start()
|
||||
{
|
||||
stop
|
||||
enable=$(uci get familycloud.@familycloud[0].enabled)
|
||||
[ $enable -eq 0 ] && exit 0
|
||||
sed "s/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/$TOKEN/" /usr/share/familycloud/$TYPE/config.ini > /tmp/config.json
|
||||
bash /usr/share/familycloud/$TYPE/speedup.sh > /tmp/familycloud.log &
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
kill -9 $(ps | grep speedup.sh | grep -v grep | awk '{print $1}') >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
|
||||
3
package/lean/luci-app-familycloud/root/etc/ppp/ip-up.d/familycloud.sh
Executable file
3
package/lean/luci-app-familycloud/root/etc/ppp/ip-up.d/familycloud.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
sleep 60 && /etc/init.d/familycloud restart
|
||||
11
package/lean/luci-app-familycloud/root/etc/uci-defaults/familycloud
Executable file
11
package/lean/luci-app-familycloud/root/etc/uci-defaults/familycloud
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@familycloud[-1]
|
||||
add ucitrack familycloud
|
||||
set ucitrack.@familycloud[-1].init=familycloud
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -0,0 +1,10 @@
|
||||
{
|
||||
"accessToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||
"setting": {
|
||||
"method": "GET",
|
||||
"rate": 600
|
||||
},
|
||||
"extra_header": {
|
||||
"User-Agent": "Apache-HttpClient/UNAVAILABLE (java 1.4)"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
/tmp/config.json
|
||||
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base_dir=`dirname $0`
|
||||
source "$base_dir/utils.sh"
|
||||
config="$base_dir/config.json"
|
||||
|
||||
|
||||
accessToken=`getSingleJsonValue "$config" "accessToken"`
|
||||
method=`getSingleJsonValue "$config" "method"`
|
||||
rate=`getSingleJsonValue "$config" "rate"`
|
||||
UA=`getSingleJsonValue "$config" "User-Agent"`
|
||||
extra_header="User-Agent:$UA"
|
||||
|
||||
|
||||
HOST="http://api.cloud.189.cn"
|
||||
LOGIN_URL="/loginByOpen189AccessToken.action"
|
||||
ACCESS_URL="/speed/startSpeedV2.action"
|
||||
count=0
|
||||
echo "*******************************************"
|
||||
while :
|
||||
do
|
||||
count=$((count+1))
|
||||
echo "Sending heart_beat package <$count>"
|
||||
split="~"
|
||||
headers_string="$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
result=`get "$HOST$LOGIN_URL?accessToken=$accessToken" "$headers"`
|
||||
session_key=`echo "$result" | grep -Eo "sessionKey>.*</sessionKey" | sed 's/<\/sessionKey//' | sed 's/sessionKey>//'`
|
||||
session_secret=`echo "$result" | grep -Eo "sessionSecret>.*</sessionSecret" | sed 's/sessionSecret>//' | sed 's/<\/sessionSecret//'`
|
||||
date=`env LANG=C.UTF-8 date -u '+%a, %d %b %Y %T GMT'`
|
||||
data="SessionKey=$session_key&Operate=$method&RequestURI=$ACCESS_URL&Date=$date"
|
||||
key="$session_secret"
|
||||
signature=`hashHmac "sha1" "$data" "$key"`
|
||||
headers_string="SessionKey:$session_key"${split}"Signature:$signature"${split}"Date:$date"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
qosClientSn="$session_key"
|
||||
result=`get "$HOST$ACCESS_URL?qosClientSn=$qosClientSn" "$headers"`
|
||||
echo "heart_beat:<signature:$signature>"
|
||||
echo "date:<$date>"
|
||||
echo -e "response:\n$result"
|
||||
[[ "`echo ${result} | grep dialAcc`" != "" ]] && hint="succeeded" || hint="failed"
|
||||
echo "Sending heart_beat package <$count> $hint"
|
||||
echo "*******************************************"
|
||||
sleep ${rate}
|
||||
done
|
||||
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base_dir=`dirname $0`
|
||||
source "$base_dir/utils.sh"
|
||||
config="$base_dir/config.json"
|
||||
|
||||
echoToLogreader() {
|
||||
logger -t CloudDisk "${1}"
|
||||
}
|
||||
|
||||
accessToken=`getSingleJsonValue "$config" "accessToken"`
|
||||
method=`getSingleJsonValue "$config" "method"`
|
||||
UA=`getSingleJsonValue "$config" "User-Agent"`
|
||||
extra_header="User-Agent:$UA"
|
||||
|
||||
|
||||
HOST="http://api.cloud.189.cn"
|
||||
LOGIN_URL="/loginByOpen189AccessToken.action"
|
||||
ACCESS_URL="/speed/startSpeedV2.action"
|
||||
echoToLogreader "*******************************************"
|
||||
echoToLogreader "Sending Heartbeat Package ..."
|
||||
split="~"
|
||||
headers_string="$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
result=`get "$HOST$LOGIN_URL?accessToken=$accessToken" "$headers"`
|
||||
session_key=`echo "$result" | grep -Eo "sessionKey>.*</sessionKey" | sed 's/<\/sessionKey//' | sed 's/sessionKey>//'`
|
||||
session_secret=`echo "$result" | grep -Eo "sessionSecret>.*</sessionSecret" | sed 's/sessionSecret>//' | sed 's/<\/sessionSecret//'`
|
||||
date=`env LANG=C.UTF-8 date -u '+%a, %d %b %Y %T GMT'`
|
||||
data="SessionKey=$session_key&Operate=$method&RequestURI=$ACCESS_URL&Date=$date"
|
||||
key="$session_secret"
|
||||
signature=`hashHmac "sha1" "$data" "$key"`
|
||||
headers_string="SessionKey:$session_key"${split}"Signature:$signature"${split}"Date:$date"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
qosClientSn=`cat /proc/sys/kernel/random/uuid`
|
||||
result=`get "$HOST$ACCESS_URL?qosClientSn=$qosClientSn" "$headers"`
|
||||
echoToLogreader "Heartbeat Signature: $signature"
|
||||
echoToLogreader "Date: $date"
|
||||
echoToLogreader "Response: $result"
|
||||
[[ "`echo ${result} | grep dialAcc`" != "" ]] && hint="succeeded" || hint="failed"
|
||||
echoToLogreader "Heartbeating $hint."
|
||||
echoToLogreader "*******************************************"
|
||||
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CONNECTION_TIME="15"
|
||||
TRANSMISSION_TIME="15"
|
||||
|
||||
formatHeaderString() {
|
||||
OLD_IFS=$IFS
|
||||
IFS="$1"
|
||||
STR="$2"
|
||||
ARRAY=(${STR})
|
||||
for i in "${!ARRAY[@]}"
|
||||
do
|
||||
HEADERS="$HEADERS -H '${ARRAY[$i]}'"
|
||||
done
|
||||
echo ${HEADERS} | sed 's/^ //'
|
||||
IFS=${OLD_IFS}
|
||||
}
|
||||
|
||||
get() {
|
||||
HEADER="$1"
|
||||
URL="$2"
|
||||
eval curl -s --connect-timeout "${CONNECTION_TIME}" -m "${TRANSMISSION_TIME}" "${HEADER}" "${URL}"
|
||||
}
|
||||
|
||||
post() {
|
||||
HEADER="$1"
|
||||
URL="$2"
|
||||
PAYLOAD="$3"
|
||||
eval curl -s --connect-timeout "${CONNECTION_TIME}" -m "${TRANSMISSION_TIME}" -X POST "${URL}" "${HEADER}" -w %{http_code} -d "'$PAYLOAD'"
|
||||
}
|
||||
|
||||
getSingleJsonValue() {
|
||||
FILE="$1"
|
||||
KEY="$2"
|
||||
cat ${FILE} | grep "$KEY" | sed 's/,$//' | awk -F "[:]" '{ print $2 }' | sed 's/ //g' | sed 's/"//g'
|
||||
}
|
||||
|
||||
hashHmac() {
|
||||
digest="$1"
|
||||
data="$2"
|
||||
key="$3"
|
||||
echo -n "$data" | openssl dgst "-$digest" -hmac "$key" | sed -e 's/^.* //' | tr 'a-z' 'A-Z'
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
{
|
||||
"accessToken": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||
"AppKey": "600100885",
|
||||
"setting": {
|
||||
"method": "POST",
|
||||
"rate": 600
|
||||
},
|
||||
"send_data": {
|
||||
"prodCode": "76"
|
||||
},
|
||||
"extra_header": {
|
||||
"User-Agent": "Apache-HttpClient/UNAVAILABLE (java 1.4)"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
/tmp/config.json
|
||||
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base_dir=`dirname $0`
|
||||
source "$base_dir/utils.sh"
|
||||
config="$base_dir/config.json"
|
||||
|
||||
|
||||
accessToken=`getSingleJsonValue "$config" "accessToken"`
|
||||
AppKey=`getSingleJsonValue "$config" "AppKey"`
|
||||
method=`getSingleJsonValue "$config" "method"`
|
||||
rate=`getSingleJsonValue "$config" "rate"`
|
||||
prodCode=`getSingleJsonValue "$config" "prodCode"`
|
||||
UA=`getSingleJsonValue "$config" "User-Agent"`
|
||||
extra_header="User-Agent:$UA"
|
||||
|
||||
|
||||
HOST="http://api.cloud.189.cn"
|
||||
LOGIN_URL="/login4MergedClient.action"
|
||||
ACCESS_URL="/family/qos/startQos.action"
|
||||
count=0
|
||||
echo "*******************************************"
|
||||
while :
|
||||
do
|
||||
count=$((count+1))
|
||||
echo "Sending heart_beat package <$count>"
|
||||
split="~"
|
||||
headers_string="AppKey:$AppKey"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
result=`post "$headers" "$HOST$LOGIN_URL?accessToken=$accessToken"`
|
||||
session_key=`echo "$result" | grep -Eo "familySessionKey>.+</familySessionKey" | sed 's/familySessionKey>//' | sed 's/<\/familySessionKey//'`
|
||||
session_secret=`echo "$result" | grep -Eo "familySessionSecret>.+</familySessionSecret" | sed 's/familySessionSecret>//' | sed 's/<\/familySessionSecret//'`
|
||||
date=`env LANG=C.UTF-8 date -u '+%a, %d %b %Y %T GMT'`
|
||||
data="SessionKey=$session_key&Operate=$method&RequestURI=$ACCESS_URL&Date=$date"
|
||||
key="$session_secret"
|
||||
signature=`hashHmac "sha1" "$data" "$key"`
|
||||
headers_string="SessionKey:$session_key"${split}"Signature:$signature"${split}"Date:$date"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
send_data="prodCode=$prodCode"
|
||||
result=`post "$headers" "$HOST$ACCESS_URL" "$send_data"`
|
||||
echo "heart_beat:<signature:$signature>"
|
||||
echo "date:<$date>"
|
||||
echo "status_code:${result: -3}"
|
||||
echo -e "response:\n`echo ${result} | sed "s^[0-9]\{3\}$^^"`"
|
||||
[[ "`echo ${result} | grep dialAcc`" != "" ]] && hint="succeeded" || hint="failed"
|
||||
echo "Sending heart_beat package <$count> $hint"
|
||||
echo "*******************************************"
|
||||
sleep ${rate}
|
||||
done
|
||||
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base_dir=`dirname $0`
|
||||
source "$base_dir/utils.sh"
|
||||
config="$base_dir/config.json"
|
||||
|
||||
echoToLogreader() {
|
||||
logger -t FamilyCloud "${1}"
|
||||
}
|
||||
|
||||
accessToken=`getSingleJsonValue "$config" "accessToken"`
|
||||
AppKey=`getSingleJsonValue "$config" "AppKey"`
|
||||
method=`getSingleJsonValue "$config" "method"`
|
||||
prodCode=`getSingleJsonValue "$config" "prodCode"`
|
||||
UA=`getSingleJsonValue "$config" "User-Agent"`
|
||||
extra_header="User-Agent:$UA"
|
||||
|
||||
|
||||
HOST="http://api.cloud.189.cn"
|
||||
LOGIN_URL="/login4MergedClient.action"
|
||||
ACCESS_URL="/family/qos/startQos.action"
|
||||
echoToLogreader "*******************************************"
|
||||
echoToLogreader "Sending Heartbeat Package ..."
|
||||
split="~"
|
||||
headers_string="AppKey:$AppKey"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
result=`post "$headers" "$HOST$LOGIN_URL?accessToken=$accessToken"`
|
||||
session_key=`echo "$result" | grep -Eo "familySessionKey>.+</familySessionKey" | sed 's/familySessionKey>//' | sed 's/<\/familySessionKey//'`
|
||||
session_secret=`echo "$result" | grep -Eo "familySessionSecret>.+</familySessionSecret" | sed 's/familySessionSecret>//' | sed 's/<\/familySessionSecret//'`
|
||||
date=`env LANG=C.UTF-8 date -u '+%a, %d %b %Y %T GMT'`
|
||||
data="SessionKey=$session_key&Operate=$method&RequestURI=$ACCESS_URL&Date=$date"
|
||||
key="$session_secret"
|
||||
signature=`hashHmac "sha1" "$data" "$key"`
|
||||
headers_string="SessionKey:$session_key"${split}"Signature:$signature"${split}"Date:$date"${split}"$extra_header"
|
||||
headers=`formatHeaderString "$split" "$headers_string"`
|
||||
send_data="prodCode=$prodCode"
|
||||
result=`post "$headers" "$HOST$ACCESS_URL" "$send_data"`
|
||||
echoToLogreader "Heartbeat Signature: $signature"
|
||||
echoToLogreader "Date: $date"
|
||||
echoToLogreader "Response: ${result}"
|
||||
[[ "`echo ${result} | grep dialAcc`" != "" ]] && hint="succeeded" || hint="failed"
|
||||
echoToLogreader "Heartbeating $hint."
|
||||
echoToLogreader "*******************************************"
|
||||
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CONNECTION_TIME="15"
|
||||
TRANSMISSION_TIME="15"
|
||||
|
||||
formatHeaderString() {
|
||||
OLD_IFS=$IFS
|
||||
IFS="$1"
|
||||
STR="$2"
|
||||
ARRAY=(${STR})
|
||||
for i in "${!ARRAY[@]}"
|
||||
do
|
||||
HEADERS="$HEADERS -H '${ARRAY[$i]}'"
|
||||
done
|
||||
echo ${HEADERS} | sed 's/^ //'
|
||||
IFS=${OLD_IFS}
|
||||
}
|
||||
|
||||
get() {
|
||||
HEADER="$1"
|
||||
URL="$2"
|
||||
eval curl -s --connect-timeout "${CONNECTION_TIME}" -m "${TRANSMISSION_TIME}" "${HEADER}" "${URL}"
|
||||
}
|
||||
|
||||
post() {
|
||||
HEADER="$1"
|
||||
URL="$2"
|
||||
PAYLOAD="$3"
|
||||
eval curl -s --connect-timeout "${CONNECTION_TIME}" -m "${TRANSMISSION_TIME}" -X POST "${URL}" "${HEADER}" -w %{http_code} -d "'$PAYLOAD'"
|
||||
}
|
||||
|
||||
getSingleJsonValue() {
|
||||
FILE="$1"
|
||||
KEY="$2"
|
||||
cat ${FILE} | grep "$KEY" | sed 's/,$//' | awk -F "[:]" '{ print $2 }' | sed 's/ //g' | sed 's/"//g'
|
||||
}
|
||||
|
||||
hashHmac() {
|
||||
digest="$1"
|
||||
data="$2"
|
||||
key="$3"
|
||||
echo -n "$data" | openssl dgst "-$digest" -hmac "$key" | sed -e 's/^.* //' | tr 'a-z' 'A-Z'
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=netifd
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
|
||||
PKG_SOURCE_DATE:=2019-04-15
|
||||
PKG_SOURCE_VERSION:=666c14f95d372d8ccee39049e65caa49368aec09
|
||||
PKG_MIRROR_HASH:=c075d163bae475022523229997564850e449963940e4fcf196215a1ae85fbd0f
|
||||
PKG_SOURCE_DATE:=2019-05-28
|
||||
PKG_SOURCE_VERSION:=beb810dbccee098add0347d551eb5362e404fbdc
|
||||
PKG_MIRROR_HASH:=f7c0057e7a7c4741d19027e7b67087e8ce8cb835ff5b34c594a24bf167c7873e
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
@ -115,7 +115,9 @@ validate_switch_section()
|
||||
'name:string' \
|
||||
'enable:bool' \
|
||||
'enable_vlan:bool' \
|
||||
'reset:bool'
|
||||
'reset:bool' \
|
||||
'ar8xxx_mib_poll_interval:uinteger' \
|
||||
'ar8xxx_mib_type:range(0,1)'
|
||||
}
|
||||
|
||||
validate_switch_vlan()
|
||||
|
||||
@ -4,7 +4,7 @@ comment "SSL support"
|
||||
|
||||
choice
|
||||
prompt "Selected SSL library"
|
||||
default LIBCURL_MBEDTLS
|
||||
default LIBCURL_OPENSSL
|
||||
|
||||
config LIBCURL_MBEDTLS
|
||||
bool "mbed TLS"
|
||||
|
||||
@ -12,9 +12,9 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
|
||||
PKG_SOURCE_DATE:=2018-11-23
|
||||
PKG_SOURCE_VERSION:=d6673547adc3768ce674799fa35952351866c9d0
|
||||
PKG_MIRROR_HASH:=ee11e1f652e9268e21dfd7835d26993c682ed33f6ba474c283cb9ef04f71e626
|
||||
PKG_SOURCE_DATE:=2019-05-30
|
||||
PKG_SOURCE_VERSION:=ade00ca585a49c8478bf60eb24ce385676be37a4
|
||||
PKG_MIRROR_HASH:=1417727ae6fcda01017e1bec3ec66e3e78116f9343cfe0256e40af54c52f2acc
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
@ -45,6 +45,7 @@ define Package/procd
|
||||
CATEGORY:=Base system
|
||||
DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus
|
||||
TITLE:=OpenWrt system process manager
|
||||
USERID:=:dialout=20 :audio=29
|
||||
endef
|
||||
|
||||
define Package/procd-ujail
|
||||
@ -57,7 +58,7 @@ endef
|
||||
define Package/procd-seccomp
|
||||
SECTION:=base
|
||||
CATEGORY:=Base system
|
||||
DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json
|
||||
DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@powerpc||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json
|
||||
TITLE:=OpenWrt process seccomp helper + utrace
|
||||
endef
|
||||
|
||||
|
||||
@ -20,6 +20,10 @@
|
||||
[ "regex", "DEVNAME", "^snd" ],
|
||||
[ "makedev", "/dev/%DEVNAME%", "0660", "audio" ]
|
||||
],
|
||||
[ "if",
|
||||
[ "regex", "DEVNAME", "^tty" ],
|
||||
[ "makedev", "/dev/%DEVNAME%", "0660", "dialout" ]
|
||||
],
|
||||
[ "if",
|
||||
[ "has", "DEVNAME" ],
|
||||
[ "makedev", "/dev/%DEVNAME%", "0600" ]
|
||||
|
||||
@ -18,14 +18,21 @@
|
||||
# file: configuration files (array)
|
||||
# netdev: bound network device (detects ifindex changes)
|
||||
# limits: resource limits (passed to the process)
|
||||
# user info: array with 1 values $username
|
||||
# user: $username to run service as
|
||||
# group: $groupname to run service as
|
||||
# pidfile: file name to write pid into
|
||||
# stdout: boolean whether to redirect commands stdout to syslog (default: 0)
|
||||
# stderr: boolean whether to redirect commands stderr to syslog (default: 0)
|
||||
# facility: syslog facility used when logging to syslog (default: daemon)
|
||||
#
|
||||
# No space separation is done for arrays/tables - use one function argument per command line argument
|
||||
#
|
||||
# procd_close_instance():
|
||||
# Complete the instance being prepared
|
||||
#
|
||||
# procd_running(service, [instance]):
|
||||
# Checks if service/instance is currently running
|
||||
#
|
||||
# procd_kill(service, [instance]):
|
||||
# Kill a service instance (or all instances)
|
||||
#
|
||||
@ -41,6 +48,7 @@ _PROCD_SERVICE=
|
||||
procd_lock() {
|
||||
local basescript=$(readlink "$initscript")
|
||||
local service_name="$(basename ${basescript:-$initscript})"
|
||||
|
||||
}
|
||||
|
||||
_procd_call() {
|
||||
@ -240,7 +248,7 @@ _procd_set_param() {
|
||||
reload_signal)
|
||||
json_add_int "$type" $(kill -l "$1")
|
||||
;;
|
||||
pidfile|user|seccomp|capabilities)
|
||||
pidfile|user|group|seccomp|capabilities|facility)
|
||||
json_add_string "$type" "$1"
|
||||
;;
|
||||
stdout|stderr|no_new_privs)
|
||||
@ -389,6 +397,18 @@ _procd_add_instance() {
|
||||
_procd_close_instance
|
||||
}
|
||||
|
||||
procd_running() {
|
||||
local service="$1"
|
||||
local instance="${2:-instance1}"
|
||||
local running
|
||||
|
||||
json_init
|
||||
json_add_string name "$service"
|
||||
running=$(_procd_ubus_call list | jsonfilter -e "@.$service.instances.${instance}.running")
|
||||
|
||||
[ "$running" = "true" ]
|
||||
}
|
||||
|
||||
_procd_kill() {
|
||||
local service="$1"
|
||||
local instance="$2"
|
||||
@ -477,6 +497,23 @@ uci_validate_section()
|
||||
return $_error
|
||||
}
|
||||
|
||||
uci_load_validate() {
|
||||
local _package="$1"
|
||||
local _type="$2"
|
||||
local _name="$3"
|
||||
local _function="$4"
|
||||
local _option
|
||||
local _result
|
||||
shift; shift; shift; shift
|
||||
for _option in "$@"; do
|
||||
eval "local ${_option%%:*}"
|
||||
done
|
||||
uci_validate_section "$_package" "$_type" "$_name" "$@"
|
||||
_result=$?
|
||||
[ -n "$_function" ] || return $_result
|
||||
eval "$_function \"\$_name\" \"\$_result\""
|
||||
}
|
||||
|
||||
_procd_wrapper \
|
||||
procd_open_service \
|
||||
procd_close_service \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user