mirror of
https://github.com/kenzok8/small-package
synced 2025-09-20 19:11:30 +08:00
update-03.06
This commit is contained in:
@ -8,9 +8,9 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=luci-app-cloudflarespeedtest
|
||||
|
||||
LUCI_TITLE:=LuCI support for Cloudflares Speed Test
|
||||
LUCI_DEPENDS:=+cdnspeedtest
|
||||
LUCI_DEPENDS:=+cdnspeedtest +openssl-util +curl
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.2.1
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=0
|
||||
PKG_LICENSE:=AGPL-3.0
|
||||
PKG_MAINTAINER:=mingxiaoyu <fengying0347@163.com>
|
||||
|
@ -36,7 +36,7 @@ end
|
||||
|
||||
function act_start()
|
||||
act_stop()
|
||||
luci.sys.call("/usr/bin/cloudflarespeedtest start")
|
||||
luci.sys.call("/usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start")
|
||||
luci.http.write('')
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ o:value("nil", translate("HOLD"))
|
||||
o.description = translate("during the speed testing, swith to which mode")
|
||||
o:value("gfw", translate("GFW List"))
|
||||
o:value("close", translate("CLOSE"))
|
||||
o.default = gfw
|
||||
o.default = "gfw"
|
||||
|
||||
o=s:option(Flag,"advanced",translate("Advanced"))
|
||||
o.description = translate("Not recommended")
|
||||
@ -55,7 +55,7 @@ o.rmempty=false
|
||||
|
||||
o = s:option(Value, "threads", translate("Threads"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 100
|
||||
o.default = 200
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
@ -144,6 +144,32 @@ if nixio.fs.access("/etc/config/passwall") then
|
||||
|
||||
end
|
||||
|
||||
s:tab("dnstab", translate("DNS"))
|
||||
|
||||
o=s:taboption("dnstab", Flag, "DNS_enabled",translate("DNS Enabled"))
|
||||
|
||||
o=s:taboption("dnstab", ListValue, "DNS_type", translate("DNS Type"))
|
||||
o:value("aliyu", translate("AliyuDNS"))
|
||||
o:depends("DNS_enabled", 1)
|
||||
|
||||
o=s:taboption("dnstab", Value,"app_key",translate("Access Key ID"))
|
||||
o.rmempty=false
|
||||
o:depends("DNS_enabled", 1)
|
||||
o=s:taboption("dnstab", Value,"app_secret",translate("Access Key Secret"))
|
||||
o.rmempty=false
|
||||
o:depends("DNS_enabled", 1)
|
||||
|
||||
o=s:taboption("dnstab", Value,"main_domain",translate("Main Domain"),translate("For example: test.github.com -> github.com"))
|
||||
o.rmempty=false
|
||||
o=s:taboption("dnstab", Value,"sub_domain",translate("Sub Domain"),translate("For example: test.github.com -> test"))
|
||||
o.rmempty=false
|
||||
|
||||
o=s:taboption("dnstab", ListValue, "line", translate("Lines"))
|
||||
o:value("telecom", translate("telecom"))
|
||||
o:value("unicom", translate("unicom"))
|
||||
o:value("mobile", translate("mobile"))
|
||||
o:depends("DNS_enabled", 1)
|
||||
o.default ="telecom"
|
||||
|
||||
e=m:section(TypedSection,"global",translate("Best IP"))
|
||||
e.anonymous=true
|
||||
|
@ -133,3 +133,45 @@ msgstr "关闭"
|
||||
|
||||
msgid "during the speed testing, swith to which mode"
|
||||
msgstr "在速度测试期间,切换到哪种模式"
|
||||
|
||||
msgid "DNS"
|
||||
msgstr "DNS"
|
||||
|
||||
msgid "DNS Enabled"
|
||||
msgstr "启用DNS"
|
||||
|
||||
msgid "DNS Type"
|
||||
msgstr "DNS类型"
|
||||
|
||||
msgid "AliyuDNS"
|
||||
msgstr "阿里云DNS"
|
||||
|
||||
msgid "Access Key ID"
|
||||
msgstr "Access Key ID"
|
||||
|
||||
msgid "Access Key Secret"
|
||||
msgstr "Access Key Secret"
|
||||
|
||||
msgid "Main Domain"
|
||||
msgstr "主域名"
|
||||
|
||||
msgid "Sub Domain"
|
||||
msgstr "子域名"
|
||||
|
||||
msgid "For example: test.github.com -> github.com"
|
||||
msgstr "例如: test.github.com 则填: github.com"
|
||||
|
||||
msgid "For example: test.github.com -> test"
|
||||
msgstr "例如: test.github.com, 则填: test"
|
||||
|
||||
msgid "Lines"
|
||||
msgstr "解析线路"
|
||||
|
||||
msgid "telecom"
|
||||
msgstr "电信"
|
||||
|
||||
msgid "unicom"
|
||||
msgstr "联通"
|
||||
|
||||
msgid "mobile"
|
||||
msgstr "移动"
|
@ -17,7 +17,7 @@ add_cron(){
|
||||
config_get minute $1 minute
|
||||
config_get hour $1 hour
|
||||
|
||||
echo "$minute $hour * * * /usr/bin/cloudflarespeedtest start" >> $CRON_FILE
|
||||
echo "$minute $hour * * * /usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start" >> $CRON_FILE
|
||||
crontab $CRON_FILE
|
||||
fi
|
||||
}
|
||||
|
81
luci-app-cloudflarespeedtest/root/usr/bin/cloudflarespeedtest/aliddns.sh
Executable file
81
luci-app-cloudflarespeedtest/root/usr/bin/cloudflarespeedtest/aliddns.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/bin/sh
|
||||
LOG_FILE='/var/log/cloudflarespeedtest.log'
|
||||
|
||||
echolog() {
|
||||
local d="$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
echo -e "$d: $*" >>$LOG_FILE
|
||||
}
|
||||
|
||||
urlencode() {
|
||||
# urlencode url<string>
|
||||
out=''
|
||||
for c in $(echo -n $1 | sed 's/[^\n]/&\n/g'); do
|
||||
case $c in
|
||||
[a-zA-Z0-9._-]) out="$out$c" ;;
|
||||
*) out="$out$(printf '%%%02X' "'$c")" ;;
|
||||
esac
|
||||
done
|
||||
echo -n $out
|
||||
}
|
||||
|
||||
send_request() {
|
||||
# send_request action<string> args<string>
|
||||
local args="AccessKeyId=$ak_id&Action=$1&Format=json&$2&Version=2015-01-09"
|
||||
local hash=$(urlencode $(echo -n "GET&%2F&$(urlencode $args)" | openssl dgst -sha1 -hmac "$ak_sec&" -binary | openssl base64))
|
||||
curl -sSL --connect-timeout 5 "http://alidns.aliyuncs.com/?$args&Signature=$hash"
|
||||
}
|
||||
|
||||
get_recordid() {
|
||||
sed 's/RR/\n/g' | sed -n 's/.*RecordId[^0-9]*\([0-9]*\).*/\1\n/p' | sort -ru | sed /^$/d
|
||||
}
|
||||
|
||||
query_recordid() {
|
||||
send_request "DescribeSubDomainRecords" "SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$sub_dm.$main_dm&Timestamp=$timestamp&Type=A"
|
||||
}
|
||||
|
||||
update_record() {
|
||||
send_request "UpdateDomainRecord" "Line=$line&RR=$sub_dm&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=$type&Value=$ip"
|
||||
}
|
||||
|
||||
add_record() {
|
||||
send_request "AddDomainRecord&DomainName=$main_dm" "Line=$line&RR=$sub_dm&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=$type&Value=$ip"
|
||||
}
|
||||
|
||||
del_record() {
|
||||
send_request "DeleteDomainRecord" "RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp"
|
||||
}
|
||||
|
||||
aliddns() {
|
||||
ak_id=$1
|
||||
ak_sec=$2
|
||||
main_dm=$3
|
||||
sub_dm=$4
|
||||
line=$5
|
||||
isIpv6=$6
|
||||
ip=$7
|
||||
type=A
|
||||
|
||||
if [ $isIpv6 -eq "1" ] ;then
|
||||
type=AAAA
|
||||
fi
|
||||
echo $ip
|
||||
echo $type
|
||||
rrid=`query_recordid | get_recordid`
|
||||
|
||||
if [ -z "$rrid" ]; then
|
||||
rrid=`add_record | get_recordid`
|
||||
echolog "ADD record $rrid"
|
||||
else
|
||||
update_record $rrid
|
||||
echolog "UPDATE record $rrid"
|
||||
fi
|
||||
if [ -z "$rrid" ]; then
|
||||
# failed
|
||||
echolog "# ERROR, Please Check Config/Time"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
timestamp=$(date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ")
|
||||
|
||||
aliddns "$@"
|
@ -26,7 +26,7 @@ echolog() {
|
||||
|
||||
function read_config(){
|
||||
get_global_config "enabled" "speed" "custome_url" "threads" "tl" "tll" "ipv6_enabled" "advanced" "proxy_mode"
|
||||
get_servers_config "ssr_services" "ssr_enabled" "passwall_enabled" "passwall_services"
|
||||
get_servers_config "ssr_services" "ssr_enabled" "passwall_enabled" "passwall_services" "DNS_enabled"
|
||||
}
|
||||
|
||||
function speed_test(){
|
||||
@ -83,6 +83,8 @@ function ip_replace(){
|
||||
bestip=$(sed -n "2,1p" $IP_FILE | awk -F, '{print $1}')
|
||||
[[ -z "${bestip}" ]] && echo "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..." && exit 0
|
||||
|
||||
alidns_ip
|
||||
|
||||
ssr_best_ip
|
||||
|
||||
passwall_best_ip
|
||||
@ -90,8 +92,8 @@ function ip_replace(){
|
||||
}
|
||||
|
||||
function passwall_best_ip(){
|
||||
|
||||
if [ $passwall_server_enabled -eq '1' ] ; then
|
||||
echolog "设置passwall代理模式"
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set passwall.@global[0].enabled="${passwall_server_enabled}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
@ -101,6 +103,7 @@ function passwall_best_ip(){
|
||||
fi
|
||||
|
||||
if [ $passwall_enabled -eq "1" ] ;then
|
||||
echolog "设置passwall IP"
|
||||
for ssrname in $passwall_services
|
||||
do
|
||||
echo $ssrname
|
||||
@ -109,6 +112,7 @@ function passwall_best_ip(){
|
||||
uci commit passwall
|
||||
if [ $passwall_server_enabled -eq "1" ] ;then
|
||||
/etc/init.d/passwall restart 2>/dev/null
|
||||
echolog "passwall重启完成"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -116,6 +120,7 @@ function passwall_best_ip(){
|
||||
function ssr_best_ip(){
|
||||
|
||||
if [ $ssr_enabled -eq "1" ] ;then
|
||||
echolog "设置ssr IP"
|
||||
for ssrname in $ssr_services
|
||||
do
|
||||
echo $ssrname
|
||||
@ -127,14 +132,27 @@ function ssr_best_ip(){
|
||||
fi
|
||||
|
||||
if [ $ssr_original_server != 'nil' ] ; then
|
||||
echolog "设置ssr代理模式"
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set shadowsocksr.@global[0].global_server="${ssr_original_server}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set shadowsocksr.@global[0].run_mode="${ssr_original_run_mode}"
|
||||
fi
|
||||
/etc/init.d/shadowsocksr restart 2>/dev/null
|
||||
/etc/init.d/shadowsocksr restart 2 >/dev/null
|
||||
echolog "ssr重启完成"
|
||||
fi
|
||||
}
|
||||
|
||||
function alidns_ip(){
|
||||
if [ $DNS_enabled -eq "1" ] ;then
|
||||
get_servers_config "DNS_type" "app_key" "app_secret" "main_domain" "sub_domain" "line"
|
||||
if [ $DNS_type == "aliyu" ] ;then
|
||||
/usr/bin/cloudflarespeedtest/aliddns.sh $app_key $app_secret $main_domain $sub_domain $line $ipv6_enabled $bestip
|
||||
echolog "更新阿里云DNS完成"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
read_config
|
||||
|
||||
# 启动参数
|
Reference in New Issue
Block a user