电信带宽稳定提速工具

资源分享电信带宽提速

电信带宽稳定提速工具

工具下载:电信带宽提速

脚本:Sh27_speedup.sh

可提速到500M带宽。

1、获取token。

获取方法:打开软件,输入手机号获取验证码,然后登录账号,启动提速。

这时应用根目录下会生成一个文件token,使用文本方式打开

2、以K2P子固件为例。用winscp登录路由器,导入speedup代码
导入目录:etc/storage/script下。文件名命名为:Sh27_speedup.sh

3、重启路由器,然后再登录路由器。进入扩展功能-搭建web环境-家庭云提速
再填入第一步获取的token。保存应用。

4、再重启路由进日志查看,提速成功有显示。理论永久可提速,第一小时自动运行一次代码。

 

 

speedup代码

#!/bin/sh
#copyright by hiboy
source /etc/storage/script/init.sh

speedup_path="/opt/app/speedup/speedup"
speedup_enable=`nvram get app_10`
[ -z $speedup_enable ] && speedup_enable=0 && nvram set app_10=0
if [ "$speedup_enable" != "0" ] ; then
speedup_enable=`nvram get app_10`
[ -z $speedup_enable ] && speedup_enable=0 && nvram set app_10=0
speedup_Info=`nvram get app_11`
[ -z "$speedup_Info" ] && speedup_Info=1 && nvram set app_11=1
AccessToken=`nvram get app_12`
[ -z "$AccessToken" ] && AccessToken="" && nvram set app_12=""
Start_Qos=`nvram get app_13`
[ -z "$Start_Qos" ] && Start_Qos="" && nvram set app_13=""
Heart_Qos=`nvram get app_17`
[ -z "$Heart_Qos" ] && Heart_Qos="" && nvram set app_17=""
Info="$speedup_Info"
[ -z "$Info" ] && Info=1

qosClientSn="$(cat /proc/sys/kernel/random/uuid)"
ln -sf /etc/storage/script/Sh27_speedup.sh /opt/app/speedup/speedup
chmod 777 /opt/app/speedup/speedup
speedup_renum=`nvram get speedup_renum`
STATUS="N"
SN=""
fi

if [ ! -z "$(echo $scriptfilepath | grep -v "/tmp/script/" | grep speedup)" ]  && [ ! -s /tmp/script/_app4 ]; then
        mkdir -p /tmp/script
        { echo '#!/bin/sh' ; echo $scriptfilepath '"$@"' '&' ; } > /tmp/script/_app4
        chmod 777 /tmp/script/_app4
fi


speedup_restart () {
relock="/var/lock/speedup_restart.lock"
if [ "$1" = "o" ] ; then
        nvram set speedup_renum="0"
        [ -f $relock ] && rm -f $relock
        return 0
fi
if [ "$1" = "x" ] ; then
        if [ -f $relock ] ; then
                logger -t "【speedup】" "多次尝试启动失败,等待【"`cat $relock`"分钟】后自动尝试重新启动"
                exit 0
        fi
        speedup_renum=${speedup_renum:-"0"}
        speedup_renum=`expr $speedup_renum + 1`
        nvram set speedup_renum="$speedup_renum"
        if [ "$speedup_renum" -gt "2" ] ; then
                I=19
                echo $I > $relock
                logger -t "【speedup】" "多次尝试启动失败,等待【"`cat $relock`"分钟】后自动尝试重新启动"
                while [ $I -gt 0 ]; do
                        I=$(($I - 1))
                        echo $I > $relock
                        sleep 60
                        [ "$(nvram get speedup_renum)" = "0" ] && exit 0
                        [ $I -lt 0 ] && break
                done
                nvram set speedup_renum="0"
        fi
        [ -f $relock ] && rm -f $relock
fi
nvram set speedup_status=0
eval "$scriptfilepath &"
exit 0
}

speedup_get_status () {

A_restart=`nvram get speedup_status`
B_restart="$speedup_enable$speedup_Info$AccessToken"
B_restart=`echo -n "$B_restart" | md5sum | sed s/[[:space:]]//g | sed s/-//g`
if [ "$A_restart" != "$B_restart" ] ; then
        nvram set speedup_status=$B_restart
        needed_restart=1
else
        needed_restart=0
fi
}

speedup_check () {

speedup_get_status
if [ "$speedup_enable" != "1" ] && [ "$needed_restart" = "1" ] ; then
        [ ! -z "$(ps -w | grep "$speedup_path" | grep -v grep )" ] && logger -t "【speedup】" "停止 speedup" && speedup_close
        { eval $(ps -w | grep "$scriptname" | grep -v grep | awk '{print "kill "$1";";}'); exit 0; }
fi
if [ "$speedup_enable" = "1" ] ; then
        if [ "$needed_restart" = "1" ] ; then
                speedup_close
                speedup_start
        else
                [ -z "$(ps -w | grep "$speedup_path" | grep -v grep )" ] && speedup_restart
        fi
fi
}

speedup_keep () {
logger -t "【speedup】" "守护进程启动"
sleep 60
speedup_enable=`nvram get app_10` #speedup_enable
i=1
while [ "$speedup_enable" = "1" ]; do
        NUM=`ps -w | grep "$speedup_path" | grep -v grep |wc -l`
        if [ "$NUM" -lt "1" ] || [ ! -s "$speedup_path" ] || [ "$i" -ge 369 ] ; then
                logger -t "【speedup】" "重新启动$NUM"
                speedup_restart
        fi
sleep 69
i=$((i+1))
speedup_enable=`nvram get speedup_enable` #speedup_enable
done
}

speedup_close () {
sed -Ei '/【speedup】|^$/d' /tmp/script/_opt_script_check
killall speedup
killall -9 speedup
kill_ps "speedup start_path"
kill_ps "/tmp/script/_app4"
kill_ps "_speedup.sh"
kill_ps "$scriptname"
}

speedup_start () {
curltest=`which curl`
if [ -z "$curltest" ] || [ ! -s "`which curl`" ] ; then
        logger -t "【speedup】" "找不到 curl ,安装 opt 程序"
        /tmp/script/_mountopt optwget
        #initopt
        curltest=`which curl`
        if [ -z "$curltest" ] || [ ! -s "`which curl`" ] ; then
                logger -t "【speedup】" "找不到 curl ,需要手动安装 opt 后输入[opkg install curl]安装"
                logger -t "【speedup】" "启动失败, 10 秒后自动尝试重新启动" && sleep 10 && speedup_restart x
        else
                speedup_restart o
        fi
fi

update_app
speedup_vv=2019-05-25
speedup_v=$(grep 'speedup_vv=' /etc/storage/script/Sh27_speedup.sh | grep -v 'speedup_v=' | awk -F '=' '{print $2;}')
nvram set speedup_v="$speedup_v"
logger -t "【speedup】" "AccessToken $AccessToken"
ln -sf /etc/storage/script/Sh27_speedup.sh /opt/app/speedup/speedup
chmod 777 /opt/app/speedup/speedup
eval "$speedup_path" start_path &
sleep 2
[ -z "$(ps -w | grep "/opt/app/speedup/speedup" | grep -v grep )" ] && logger -t "【speedup】" "启动成功 $speedup_v " && speedup_restart o

speedup_get_status
eval "$scriptfilepath keep &"
exit 0
}

speedup_start_path () {

[ -z "$SN" ] && SN=0
speedup_enable=`nvram get app_10`

[ -z $speedup_enable ] && speedup_enable=0 && nvram set speedup_enable=0
while [[ "$speedup_enable" != 0 ]] 
do
        if [ "$SN"x == "0"x ] || [ -z "$SN"  ]; then
                logger -t "【speedup】" "Start_SN is $SN, need to Speedup now"
                get_session && QOS_Check && QOS_Start
                if [[ -z "$SN" ]]; then
                        logger -t "【speedup】" "Start_ERROR!!!"
                else
                        logger -t "【speedup】" "Start Speedup, SN: $SN"
                        sleep 597
                fi
        fi
        if [[ ! -z "$SN" ]]; then
                QOS_Start
                logger -t "【speedup】" "Keep  Speedup, SN: $SN"
                sleep 597
        fi
        speedup_enable=`nvram get speedup_enable`
        [ -z $speedup_enable ] && speedup_enable=0 && nvram set speedup_enable=0
done

}

hashHmac() {
    digest="$1"
    data="$2"
    key="$3"
    echo -n "$data" | openssl dgst "-$digest" -hmac "$key" | sed -e 's/^.* //' | tr 'a-z' 'A-Z'
}

get_session()
{

GMT_Date="$(date -u '+%a, %d %b %Y %T GMT')"

data="AppKey=600100885&Operate="GET"&RequestURI=/family/manage/loginFamily.action&Timestamp=$GMT_Date"

key="fe5734c74c2f96a38157f420b32dc995"

Check_Signature=`hashHmac "sha1" "$data" "$key"`

speedup_login="curl -s --connect-timeout 15 -m 15 http://api.cloud.189.cn/family/manage/loginFamily.action?e189AccessToken=""$AccessToken"" -H 'AppKey:600100885' -H 'AppSignature: ""$Check_Signature""' -H 'Timestamp: ""$GMT_Date""' -H 'User-Agent:Apache-HttpClient/UNAVAILABLE(java1.4)'"

re_STAT="$(eval "$speedup_login" | grep userSession)"

session_Key="$(echo "$re_STAT" | grep -Eo "sessionKey>.*</sessionKey" | sed 's/<\/sessionKey//' | sed 's/sessionKey>//' )"

session_Secret="$(echo "$re_STAT" | grep -Eo "sessionSecret>.*</sessionSecret" | sed 's/sessionSecret>//' | sed 's/<\/sessionSecret//' )"

}

get_info()
{

dial_Account="$(echo "$re_STAT" | awk -F"\<dialAccount\>|\<\/dialAccount\>" '{if($2!="") print $2}')"

target_DownRate="$(echo "$re_STAT" | awk -F"\<targetDownRate\>|\<\/targetDownRate\>" '{if($2!="") print $2}')"

DownRate=$(($target_DownRate/1024))

target_UpRate="$(echo "$re_STAT" | awk -F"\<targetUpRate\>|\<\/targetUpRate\>" '{if($2!="") print $2}')"

UpRate=$(($target_UpRate/1024))

logger -t "【speedup】" "宽带账号【$dial_Account】 下行速率【$DownRate"M"】 上行速率【$UpRate"M"】"

}

QOS_Check()
{
GMT_Date="$(date -u '+%a, %d %b %Y %T GMT')"

ACCESS_URL="/speed/checkSpeedAbilityV2.action"

data="SessionKey=$session_Key&Operate="GET"&RequestURI=$ACCESS_URL&Date=$GMT_Date"

key="$session_Secret"

Check_Signature=`hashHmac "sha1" "$data" "$key"`

Check_Qos="curl -s --connect-timeout 15 -m 15 http://api.cloud.189.cn/speed/checkSpeedAbilityV2.action?qosClientSn=""$qosClientSn"" -H 'SessionKey:""$session_Key""' -H 'Signature: ""$Check_Signature""' -H 'Date: ""$GMT_Date""' -H 'User-Agent:Apache-HttpClient/UNAVAILABLE(java1.4)'"             

re_STAT="$(eval "$Check_Qos" | grep qosCheckResponse)"

get_info

sleep 3
}

QOS_Start()
{
GMT_Date="$(date -u '+%a, %d %b %Y %T GMT')"

ACCESS_URL="/speed/startSpeedV2.action"

data="SessionKey=$session_Key&Operate="GET"&RequestURI=$ACCESS_URL&Date=$GMT_Date"

key="$session_Secret"

Start_Signature=`hashHmac "sha1" "$data" "$key"`

Start_Qos="curl -s --connect-timeout 15 -m 15 http://api.cloud.189.cn/speed/startSpeedV2.action?qosClientSn=""$qosClientSn"" -H 'SessionKey:""$session_Key""' -H 'Signature: ""$Start_Signature""' -H 'Date: ""$GMT_Date""' -H 'User-Agent:Apache-HttpClient/UNAVAILABLE(java1.4)'"

SN_STAT="$(eval "$Start_Qos" | grep qosInfoResponse)"

SN="$(echo "$SN_STAT" | awk -F"\<qosSn\>|\<\/qosSn\>" '{if($2!="") print $2}')"

sleep 3
}


case $ACTION in
start)
        nvram set speedup_status=0
        speedup_close
        speedup_check
        ;;
check)
        speedup_check
        ;;
stop)
        speedup_close
        ;;
keep)
        #speedup_check
        speedup_keep
        ;;
start_path)
        speedup_start_path
        ;;
*)
        speedup_check
        ;;
esac

 

Posted by 柴郡猫