mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
Revert "luci-app-leigod-acc: add scheduled pause (#12378)"
This reverts commit 33188e1cc5
.
This commit is contained in:
parent
bb839963b1
commit
1640f5708e
@ -1,51 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# https://github.com/isecret/leigod-helper/blob/main/leigod-helper.sh
|
|
||||||
|
|
||||||
USERNAME="${USERNAME:-phone}"
|
|
||||||
PASSWORD="${PASSWORD:-password}"
|
|
||||||
|
|
||||||
if ! command -v "jq" > /dev/null; then
|
|
||||||
echo "缺失 jq 依赖";
|
|
||||||
exit;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v md5sum > /dev/null; then
|
|
||||||
password_hash=$(echo -n "$PASSWORD" | md5sum | awk '{print $1}')
|
|
||||||
elif command -v md5 > /dev/null; then
|
|
||||||
password_hash=$(echo -n "$PASSWORD" | md5)
|
|
||||||
else
|
|
||||||
echo "缺失 md5 或 md5sum 依赖,请手动安装"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
login=$(curl -Lks -X POST https://webapi.leigod.com/api/auth/login \
|
|
||||||
-H 'content-type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"account_token\": null,
|
|
||||||
\"country_code\": 86,
|
|
||||||
\"lang\": \"zh_CN\",
|
|
||||||
\"password\": \"$password_hash\",
|
|
||||||
\"region_code\": 1,
|
|
||||||
\"src_channel\": \"guanwang\",
|
|
||||||
\"user_type\": \"0\",
|
|
||||||
\"username\": \"$USERNAME\"
|
|
||||||
}")
|
|
||||||
|
|
||||||
login_code=$(echo $login | jq -r ".code" 2>&1)
|
|
||||||
login_msg=$(echo $login | jq -r ".msg" 2>&1)
|
|
||||||
|
|
||||||
if [ "$login_code" -eq 0 ]; then
|
|
||||||
account_token=$(echo $login | jq -r ".data.login_info.account_token" 2>&1)
|
|
||||||
pause=$(curl -Lks -X POST https://webapi.leigod.com/api/user/pause \
|
|
||||||
-H 'content-type: application/json' \
|
|
||||||
-d "{
|
|
||||||
\"account_token\": \"$account_token\",
|
|
||||||
\"lang\": \"zh_CN\"
|
|
||||||
}")
|
|
||||||
pause_code=$(echo $pause | jq -r ".code" 2>&1)
|
|
||||||
pause_msg=$(echo $pause | jq -r ".msg" 2>&1)
|
|
||||||
|
|
||||||
echo "暂停结果: $pause_msg"
|
|
||||||
else
|
|
||||||
echo "登录失败...原因: $login_msg"
|
|
||||||
fi
|
|
@ -62,7 +62,7 @@ function start_acc_service()
|
|||||||
luci.http.write_json(resp)
|
luci.http.write_json(resp)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stop_acc_service
|
-- start_acc_service
|
||||||
function stop_acc_service()
|
function stop_acc_service()
|
||||||
-- util module
|
-- util module
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
@ -72,30 +72,4 @@ function stop_acc_service()
|
|||||||
resp.result = "OK"
|
resp.result = "OK"
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(resp)
|
luci.http.write_json(resp)
|
||||||
end
|
|
||||||
|
|
||||||
-- schedule_pause
|
|
||||||
function schedule_pause()
|
|
||||||
local util = require "luci.util"
|
|
||||||
local uci = require "luci.model.uci".cursor()
|
|
||||||
local schedule_enabled = uci:get("accelerator", "system", "schedule_enabled") or "0"
|
|
||||||
local pause_time = uci:get("accelerator", "system", "pause_time") or "01:00"
|
|
||||||
local username = uci:get("accelerator", "system", "username") or ""
|
|
||||||
local password = uci:get("accelerator", "system", "password") or ""
|
|
||||||
|
|
||||||
-- Remove existing cron jobs related to leigod_helper.sh
|
|
||||||
util.exec("sed -i '/usr/sbin/leigod/leigod_helper.sh/d' /etc/crontabs/root")
|
|
||||||
|
|
||||||
if schedule_enabled == "1" then
|
|
||||||
-- Set the new cron job
|
|
||||||
local hour, minute = pause_time:match("(%d+):(%d+)")
|
|
||||||
local cron_time = string.format("%d %d * * * USERNAME=%s PASSWORD=%s /usr/sbin/leigod/leigod_helper.sh", tonumber(minute), tonumber(hour), username, password)
|
|
||||||
util.exec(string.format('echo "%s" >> /etc/crontabs/root', cron_time))
|
|
||||||
util.exec("/etc/init.d/cron restart")
|
|
||||||
end
|
|
||||||
|
|
||||||
local resp = {}
|
|
||||||
resp.result = "OK"
|
|
||||||
luci.http.prepare_content("application/json")
|
|
||||||
luci.http.write_json(resp)
|
|
||||||
end
|
end
|
@ -16,31 +16,7 @@ enable.default = 0
|
|||||||
tun = s:option(Flag,"tun" ,translate("Tunnel Mode"))
|
tun = s:option(Flag,"tun" ,translate("Tunnel Mode"))
|
||||||
tun.rmempty = false
|
tun.rmempty = false
|
||||||
tun.default = 0
|
tun.default = 0
|
||||||
tun.description = translate("Turning Leigod into Tunnel mode can make some proxy plugins available")
|
|
||||||
|
|
||||||
schedule_enabled = s:option(Flag, "schedule_enabled", translate("Scheduled Pause"))
|
|
||||||
schedule_enabled.rmempty = false
|
|
||||||
schedule_enabled.default = 0
|
|
||||||
schedule_enabled.description = translate("夜猫子选项")
|
|
||||||
|
|
||||||
pause_time = s:option(ListValue, "pause_time", translate("Pause Time"))
|
|
||||||
pause_time:depends("schedule_enabled", 1)
|
|
||||||
for i = 0, 23 do
|
|
||||||
pause_time:value(string.format("%02d:00", i), string.format("%02d:00", i))
|
|
||||||
end
|
|
||||||
pause_time.rmempty = false
|
|
||||||
pause_time.description = translate("选择好时间雷神加速器会定时暂停,请避开你的游戏时间以免影响游戏体验")
|
|
||||||
|
|
||||||
|
|
||||||
username = s:option(Value, "username", translate("Phone Number"))
|
|
||||||
username:depends("schedule_enabled", 1)
|
|
||||||
username.rmempty = false
|
|
||||||
|
|
||||||
password = s:option(Value, "password", translate("Leigod Password"))
|
|
||||||
password:depends("schedule_enabled", 1)
|
|
||||||
password.password = true
|
|
||||||
password.rmempty = false
|
|
||||||
|
|
||||||
m:section(SimpleSection).template = "leigod/service"
|
m:section(SimpleSection).template = "leigod/service"
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -5,10 +5,6 @@ config system 'base'
|
|||||||
option base_url 'https://opapi.nn.com/speed'
|
option base_url 'https://opapi.nn.com/speed'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option tun '0'
|
option tun '0'
|
||||||
option schedule_enabled '0'
|
|
||||||
option pause_time '01:00'
|
|
||||||
option username ''
|
|
||||||
option password ''
|
|
||||||
|
|
||||||
config bind 'bind'
|
config bind 'bind'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user