Merge Mainline
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
commit
bca6199163
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Luci for JD dailybonus Script
|
||||
LUCI_DEPENDS:=+libuci-lua +lua +node +node-request +wget-ssl
|
||||
LUCI_DEPENDS:=+curl +libuci-lua +lua +node +node-request +wget-ssl
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-jd-dailybonus
|
||||
PKG_VERSION:=1.0.3
|
||||
PKG_RELEASE:=20210125
|
||||
PKG_VERSION:=1.0.5
|
||||
PKG_RELEASE:=20210316
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
@ -96,7 +96,6 @@ end
|
||||
function check_login()
|
||||
local uci = luci.model.uci.cursor()
|
||||
local data = luci.http.formvalue()
|
||||
local id = data.id
|
||||
local post_data = 'lang=chs&appid=300&source=wq_passport&returnurl=https://wqlogin2.jd.com/passport/LoginRedirect?state=1100399130787&returnurl=//home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action'
|
||||
local referer='https://plogin.m.jd.com/login/login?appid=300&returnurl=https://wqlogin2.jd.com/passport/LoginRedirect?state='
|
||||
local response = luci.sys.exec("echo -n $(wget-ssl --post-data='"..post_data.."' --header='"..Accept.."' --header='"..Accept_Language.."' --header='"..Host.."' --referer='"..referer.."' --user-agent='"..User_Agent.."' --load-cookies="..cookie.." --save-cookies="..cookie.." --keep-session-cookies -q -O - '"..data.check_url.."')")
|
||||
@ -107,11 +106,7 @@ function check_login()
|
||||
if return_json.error == 0 then
|
||||
local pt_key = luci.sys.exec("echo -n $(cat "..cookie.." | grep pt_key | awk '{print $7}')")
|
||||
local pt_pin = luci.sys.exec("echo -n $(cat "..cookie.." | grep pt_pin | awk '{print $7}')")
|
||||
local cookieStr = 'pt_key=' .. pt_key .. ';pt_pin=' .. pt_pin .. ';'
|
||||
uci:set('jd-dailybonus', '@global[0]', id, cookieStr)
|
||||
uci:commit('jd-dailybonus')
|
||||
luci.sys.call('lua /usr/share/jd-dailybonus/gen_cookieset.lua')
|
||||
return_json.cookie = cookieStr
|
||||
return_json.cookie = 'pt_key=' .. pt_key .. ';pt_pin=' .. pt_pin .. ';'
|
||||
end
|
||||
|
||||
luci.http.prepare_content('application/json')
|
||||
@ -125,4 +120,4 @@ function get_log()
|
||||
e.log = fs.readfile("/var/log/jd_dailybonus.log") or ""
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,16 +8,14 @@ m = Map(jd)
|
||||
s = m:section(TypedSection, 'global', translate('基本设置'))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(DynamicList, "Cookies", translate("账号 Cookie 列表"))
|
||||
o.rmempty = false
|
||||
o.description = translate('双击输入框或点击添加图标即可调出二维码,扫码后自动填入。')
|
||||
|
||||
o = s:option(DummyValue, '', '')
|
||||
o.rawhtml = true
|
||||
o.template = 'jd-dailybonus/cookie_tools'
|
||||
|
||||
o = s:option(Value, 'cookie', translate('第一账号Cookie'))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, 'cookie2', translate('第二账号Cookie'))
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, 'stop', translate('延迟签到'))
|
||||
o.rmempty = false
|
||||
o.default = 0
|
||||
@ -42,6 +40,12 @@ o = s:option(Value, 'serverchan', translate('Server酱 SCKEY'))
|
||||
o.rmempty = true
|
||||
o.description = translate('微信推送,基于Server酱服务,请自行登录 http://sc.ftqq.com/ 绑定并获取 SCKEY。')
|
||||
|
||||
-- Dingding
|
||||
|
||||
o = s:option(Value, 'dd_token', translate('Dingding Bot Token'))
|
||||
o.rmempty = true
|
||||
o.description = translate('创建一个群机器人并获取API Token,设置安全关键字为:京东')
|
||||
|
||||
-- telegram
|
||||
|
||||
o = s:option(Value, 'tg_token', translate('Telegram Bot Token'))
|
||||
@ -87,8 +91,9 @@ o:depends('auto_update', '1')
|
||||
|
||||
o = s:option(Value, 'remote_url', translate('更新源地址'))
|
||||
o:value('https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js', translate('GitHub'))
|
||||
o:value('https://cdn.jsdelivr.net/gh/NobyDa/Script/JD-DailyBonus/JD_DailyBonus.js', translate('GitHub CDN'))
|
||||
o:value('https://gitee.com/jerrykuku/staff/raw/master/JD_DailyBonus.js', translate('Gitee'))
|
||||
o:value('https://raw.sevencdn.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js', translate('GitHub CDN 01'))
|
||||
o:value('https://cdn.jsdelivr.net/gh/NobyDa/Script/JD-DailyBonus/JD_DailyBonus.js', translate('GitHub CDN 02'))
|
||||
o:value('https://ghproxy.com/https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js', translate('韩国首尔'))
|
||||
o.default = 'nil'
|
||||
o.rmempty = false
|
||||
o.description = translate('当GitHub源无法更新时,可以选择使用国内Gitee源,GitHub CDN可能比原地址更晚更新,但速度快')
|
||||
|
||||
@ -1,153 +1,165 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script src="https://cdn.jsdelivr.net/npm/qrcode_js@1.0.0/qrcode.min.js"></script>
|
||||
<style>
|
||||
#qrcontainer {
|
||||
position: fixed;
|
||||
#mask-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 5000;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, .8);
|
||||
text-align: center;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
#qrcontainer.hidden{
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#qrcontainer .qframe {
|
||||
background-color: #ffffff;
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
border: #6D8A88 1px solid;
|
||||
-webkit-box-shadow: 0px 0px 7px 3px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0px 0px 7px 3px rgba(0, 0, 0, 0.2);
|
||||
position: relative;
|
||||
}
|
||||
#qrcontainer .qframe #refresh_qrcode{
|
||||
width: 256px;
|
||||
height: 256px;
|
||||
position: absolute;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
left: 1rem;
|
||||
top: 1rem;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
background: rgba(255, 255, 255, .8);
|
||||
}
|
||||
#qrcontainer .qframe #refresh_qrcode.hidden{
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
#mask-box #code-box {
|
||||
width: 288px;
|
||||
height: 315px;
|
||||
border: 1px solid #585858;
|
||||
padding: 15px;
|
||||
position: absolute;
|
||||
box-shadow: 0px 0px 7px 3px rgb(0 0 0 / 20%);
|
||||
background: #fff url('/luci-static/resources/icons/loading.gif') no-repeat center center;
|
||||
border-radius: 4px;
|
||||
}
|
||||
#qrcontainer .qframe #refresh_qrcode h3{
|
||||
font-weight: normal;
|
||||
#mask-box #code-box img {
|
||||
margin-top: 5px;
|
||||
}
|
||||
#qrcontainer .qframe #refresh_qrcode .refresh{
|
||||
display: block;
|
||||
background: #e4393c;
|
||||
width: 80px;
|
||||
height: 30px;
|
||||
margin: 0 auto;
|
||||
line-height: 30px;
|
||||
opacity: 1;
|
||||
z-index: 19;
|
||||
color: #fbfbfb;
|
||||
text-decoration: none;
|
||||
#mask-box #close-link {
|
||||
float: right;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin: -32px;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHhtbDpzcGFjZT0icHJlc2VydmUiIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiB5PSIwIiB4PSIwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSLlnJblsaRfMSIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iNDdweCIgaGVpZ2h0PSI0N3B4IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgc3R5bGU9IndpZHRoOjEwMCU7aGVpZ2h0OjEwMCU7YmFja2dyb3VuZC1zaXplOmluaXRpYWw7YmFja2dyb3VuZC1yZXBlYXQteTppbml0aWFsO2JhY2tncm91bmQtcmVwZWF0LXg6aW5pdGlhbDtiYWNrZ3JvdW5kLXBvc2l0aW9uLXk6aW5pdGlhbDtiYWNrZ3JvdW5kLXBvc2l0aW9uLXg6aW5pdGlhbDtiYWNrZ3JvdW5kLW9yaWdpbjppbml0aWFsO2JhY2tncm91bmQtY29sb3I6aW5pdGlhbDtiYWNrZ3JvdW5kLWNsaXA6aW5pdGlhbDtiYWNrZ3JvdW5kLWF0dGFjaG1lbnQ6aW5pdGlhbDthbmltYXRpb24tcGxheS1zdGF0ZTpwYXVzZWQiID48ZyBjbGFzcz0ibGRsLXNjYWxlIiBzdHlsZT0idHJhbnNmb3JtLW9yaWdpbjo1MCUgNTAlO3RyYW5zZm9ybTpyb3RhdGUoMGRlZykgc2NhbGUoMC44LCAwLjgpO2FuaW1hdGlvbi1wbGF5LXN0YXRlOnBhdXNlZCIgPjxjaXJjbGUgZmlsbD0iIzMzMyIgcj0iNDAiIGN5PSI1MCIgY3g9IjUwIiBzdHlsZT0iZmlsbDpyZ2IoODksIDg5LCA4OSk7YW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+PC9jaXJjbGU+CjxnIHN0eWxlPSJhbmltYXRpb24tcGxheS1zdGF0ZTpwYXVzZWQiID48cGF0aCBkPSJNMjUuMyA0NWg0OS41djEwSDI1LjN6IiBmaWxsPSIjZTE1YjY0IiB0cmFuc2Zvcm09InJvdGF0ZSgtNDQuOTk2IDQ5Ljk5NyA0OS45OTcpIiBzdHlsZT0iZmlsbDpyZ2IoMjU1LCAyNTUsIDI1NSk7YW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+PC9wYXRoPjwvZz4KPGcgc3R5bGU9ImFuaW1hdGlvbi1wbGF5LXN0YXRlOnBhdXNlZCIgPjxwYXRoIGQ9Ik00NSAyNS4zaDEwdjQ5LjVINDV6IiBmaWxsPSIjZTE1YjY0IiB0cmFuc2Zvcm09InJvdGF0ZSgtNDUuMDAxIDUwIDUwKSIgc3R5bGU9ImZpbGw6cmdiKDI1NSwgMjU1LCAyNTUpO2FuaW1hdGlvbi1wbGF5LXN0YXRlOnBhdXNlZCIgPjwvcGF0aD48L2c+CjxtZXRhZGF0YSB4bWxuczpkPSJodHRwczovL2xvYWRpbmcuaW8vc3RvY2svIiBzdHlsZT0iYW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+PGQ6bmFtZSBzdHlsZT0iYW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+Y2xvc2U8L2Q6bmFtZT4KPGQ6dGFncyBzdHlsZT0iYW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+Y2xvc2UscmVqZWN0LG9mZixkaXNhYmxlLHJlbW92ZSxkZWxldGUsY2FuY2VsLGRyb3AsY29sbGFwc2U8L2Q6dGFncz4KPGQ6bGljZW5zZSBzdHlsZT0iYW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+Ynk8L2Q6bGljZW5zZT4KPGQ6c2x1ZyBzdHlsZT0iYW5pbWF0aW9uLXBsYXktc3RhdGU6cGF1c2VkIiA+bmVmM2Q0PC9kOnNsdWc+PC9tZXRhZGF0YT48L2c+PCEtLSBnZW5lcmF0ZWQgYnkgaHR0cHM6Ly9sb2FkaW5nLmlvLyAtLT48L3N2Zz4=') no-repeat center center;
|
||||
}
|
||||
#qrcontainer .qframe .info {
|
||||
padding: 1rem 0 0 0;
|
||||
#mask-box #load-link {
|
||||
color: #fbfbfb;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0 10px;
|
||||
bottom: 115px;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
position: absolute;
|
||||
background: #e4393c;
|
||||
line-height: 48px;
|
||||
text-decoration: none;
|
||||
}
|
||||
div[id$="-html"] {
|
||||
display: none;
|
||||
}
|
||||
div[data-prefix$="Cookies"] {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
<label class="cbi-value-title"><%= translate("获取Cookie") %></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="button" data-rel="1" class="cbi-button cbi-input-reload cookie-button" value="<%= translate('获取第一Cookie') %>" />
|
||||
<input type="button" data-rel="2" class="cbi-button cbi-input-reload cookie-button" value="<%= translate('获取第二Cookie') %>" />
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="帮助" /></span>
|
||||
<%= translate("点击上面按钮使用京东手机app扫码获取Cookie")%>
|
||||
</div>
|
||||
</div>
|
||||
<div id="qrcontainer" class="hidden">
|
||||
<div class="qframe">
|
||||
<div id="refresh_qrcode" class="hidden">
|
||||
<div>
|
||||
<h3>二维码已失效</h3>
|
||||
<div class="refresh" onclick="get_code()">刷新</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="qrcode"></div>
|
||||
<div class="info">请使用京东手机APP扫码</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const QRCODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","qrcode")%>';
|
||||
const CHECK_LOGIN_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","check_login")%>';
|
||||
(function( window, document, undefined ) {
|
||||
// 选取 DOM 元素
|
||||
var selector, section = document.querySelector("[data-prefix$='Cookies']");
|
||||
|
||||
let ckid = 0;
|
||||
// 遮罩容器
|
||||
var mask = document.createElement('div');
|
||||
mask.id = 'mask-box';
|
||||
|
||||
//初始化二维码
|
||||
let cookieBtn = Array.prototype.slice.call(document.getElementsByClassName("cookie-button"));
|
||||
try {
|
||||
qrcode = new QRCode(document.getElementById("qrcode"),
|
||||
{
|
||||
text: "sample",
|
||||
correctLevel: QRCode.CorrectLevel.L
|
||||
});
|
||||
cookieBtn.forEach(e => {
|
||||
e.onclick = () => {
|
||||
ckid = e.getAttribute("data-rel");
|
||||
get_code();
|
||||
// 二维码容器
|
||||
var code = document.createElement('div');
|
||||
code.id = 'code-box';
|
||||
code.innerHTML = "请使用 “手机京东” 进行扫码认证";
|
||||
|
||||
// 刷新按钮
|
||||
var load = document.createElement('a');
|
||||
load.id = 'load-link';
|
||||
load.innerHTML = "刷新";
|
||||
|
||||
// 创建二维码
|
||||
var make = new QRCode( code, { correctLevel: QRCode.CorrectLevel.L });
|
||||
|
||||
// 关闭按钮
|
||||
var link = document.createElement('a');
|
||||
link.id = 'close-link';
|
||||
link.addEventListener('click', ( e ) => {
|
||||
XHR.halt();
|
||||
XHR._q = [];
|
||||
mask.remove();
|
||||
return false;
|
||||
});
|
||||
|
||||
// 二维码层居中
|
||||
var center = function() {
|
||||
if ( selector.offsetTop <= 320 ) {
|
||||
code.style.top = selector.offsetTop + selector.offsetHeight + "px";
|
||||
} else {
|
||||
code.style.top = selector.offsetTop - code.offsetHeight + "px";
|
||||
}
|
||||
code.style.left = ( selector.offsetWidth - code.offsetWidth ) / 2 + "px";
|
||||
};
|
||||
|
||||
// 获取二维码
|
||||
var feedback = function() {
|
||||
// 获取通信数据
|
||||
XHR.get( '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","qrcode")%>', null, ( x, d ) => {
|
||||
if ( x.status != 200 ) {
|
||||
alert('获取二维码失败!');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
alert("网络离线状态无法使用二维码获取Cookie,请刷新后重试!")
|
||||
cookieBtn.forEach(e => {
|
||||
e.disabled = true;
|
||||
});
|
||||
}
|
||||
// 移除刷新
|
||||
load.remove();
|
||||
// 创建二维码
|
||||
make.clear();
|
||||
make.makeCode( d.qrcode_url );
|
||||
// 元素居中
|
||||
center();
|
||||
|
||||
//获取二维码
|
||||
function get_code(){
|
||||
XHR.get(QRCODE_URL, null, (x,d) => {
|
||||
document.getElementById("qrcontainer").classList.remove("hidden");
|
||||
document.getElementById("refresh_qrcode").classList.add("hidden");
|
||||
qrcode.clear();
|
||||
qrcode.makeCode(d.qrcode_url);
|
||||
checkLogin(d.check_url);
|
||||
// 监听扫码反馈
|
||||
XHR.poll( 3, '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","check_login")%>', { check_url: d.check_url }, ( x, d ) => {
|
||||
if ( d.error == 0 ) {
|
||||
// 清除线程
|
||||
XHR.halt();
|
||||
XHR._q = [];
|
||||
// 回写 Cookie 数据
|
||||
mask.remove();
|
||||
selector.value = d.cookie;
|
||||
} else if ( d.error == 21 || d.error == 261 ) {
|
||||
// 清除线程
|
||||
XHR.halt();
|
||||
XHR._q = [];
|
||||
// 插入容器
|
||||
if ( !document.contains( load ) ) {
|
||||
// 插入按钮
|
||||
load.addEventListener('click', feedback );
|
||||
code.prepend( load );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function checkLogin(check_url){
|
||||
let cname = ckid == 1?"cookie":"cookie2"
|
||||
XHR.poll(3, CHECK_LOGIN_URL, { check_url: check_url, id: cname }, (x, d) => {
|
||||
if (d.error == 0) {
|
||||
XHR.halt();
|
||||
XHR._q = [];
|
||||
document.getElementById("qrcontainer").classList.add("hidden");
|
||||
document.getElementById("refresh_qrcode").classList.add("hidden");
|
||||
let prefix_array = document.getElementsByClassName("cbi-input-text")[0].getAttribute("id").split(".")
|
||||
prefix_array.pop()
|
||||
let id = `${prefix_array.join(".")}.${cname}`;
|
||||
document.getElementById(id).value = d.cookie
|
||||
} else if (d.error == 21 || d.error == 261) {
|
||||
XHR.halt();
|
||||
XHR._q = [];
|
||||
document.getElementById("refresh_qrcode").classList.remove("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
// 鼠标事件
|
||||
var event = function( e ) {
|
||||
// 区分单击、双击事件
|
||||
if ( e.target.tagName == "INPUT" && e.type == "dblclick" ) {
|
||||
selector = e.target;
|
||||
} else if ( e.target.tagName == "IMG" && e.type == "click" && /add/ig.test( e.target.src ) ) {
|
||||
selector = section.getElementsByTagName("INPUT");
|
||||
selector = selector.item( selector.length - 1 );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// 插入容器
|
||||
if ( !document.contains( mask ) ) {
|
||||
section.prepend( mask );
|
||||
mask.prepend( code );
|
||||
code.prepend( link );
|
||||
center();
|
||||
}
|
||||
// 获取及监听扫码事件
|
||||
feedback();
|
||||
};
|
||||
|
||||
// 绑定事件
|
||||
section.addEventListener( 'click', event );
|
||||
section.addEventListener( 'dblclick', event );
|
||||
})( window, document );
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
config global
|
||||
option version '1.90'
|
||||
option version '1.96'
|
||||
option out '0'
|
||||
option stop '100'
|
||||
option serverchan ''
|
||||
@ -11,4 +11,4 @@ config global
|
||||
option auto_run_time '0'
|
||||
option auto_run_time_m '1'
|
||||
option auto_run_time_h '1'
|
||||
option cookie ''
|
||||
list Cookies '双击扫码添加 Cookie 数据'
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
京东多合一签到脚本
|
||||
|
||||
更新时间: 2021.01.28 18:40 v1.92
|
||||
有效接口: 40+
|
||||
更新时间: 2021.02.28 18:30 v1.96
|
||||
有效接口: 35+
|
||||
脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js
|
||||
电报频道: @NobyDa
|
||||
问题反馈: @NobyDa_bot
|
||||
@ -19,6 +19,8 @@ var Key = ''; //单引号内自行填写您抓取的Cookie
|
||||
|
||||
var DualKey = ''; //如需双账号签到,此处单引号内填写抓取的"账号2"Cookie, 否则请勿填写
|
||||
|
||||
var OtherKey = ''; //第三账号或以上的Cookie json串数据, 以下样例为第三第四账号:var OtherKey = '[{"cookie":"pt_key=xxxxxx;pt_pin=yyyyyy"},{"cookie":"pt_key=xxxxxx;pt_pin=yyyyyy"}]'
|
||||
|
||||
/* 注1: 以上选项仅针对于JsBox或Node.js, 如果使用QX,Surge,Loon, 请使用脚本获取Cookie.
|
||||
注2: 双账号用户抓取"账号1"Cookie后, 请勿点击退出账号(可能会导致Cookie失效), 需清除浏览器资料或更换浏览器登录"账号2"抓取.
|
||||
注3: 如果复制的Cookie开头为"Cookie: "请把它删除后填入.
|
||||
@ -35,16 +37,15 @@ var DualKey = ''; //如需双账号签到,此处单引号内填写抓取的"账
|
||||
由于cookie的有效性(经测试网页Cookie有效周期最长31天),如果脚本后续弹出cookie无效的通知,则需要重复上述步骤。
|
||||
签到脚本将在每天的凌晨0:05执行, 您可以修改执行时间。 因部分接口京豆限量领取, 建议调整为凌晨签到。
|
||||
|
||||
BoxJs订阅地址: https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json
|
||||
BoxJs或QX Gallery订阅地址: https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json
|
||||
|
||||
*************************
|
||||
【 配置双京东账号签到说明 】 :
|
||||
【 配置多京东账号签到说明 】 :
|
||||
*************************
|
||||
|
||||
正确配置QX、Surge、Loon后, 并使用此脚本获取"账号1"Cookie成功后, 请勿点击退出账号(可能会导致Cookie失效), 需清除浏览器资料或更换浏览器登录"账号2"获取即可.
|
||||
正确配置QX、Surge、Loon后, 并使用此脚本获取"账号1"Cookie成功后, 请勿点击退出账号(可能会导致Cookie失效), 需清除浏览器资料或更换浏览器登录"账号2"获取即可; 账号3或以上同理.
|
||||
注: 如需清除所有Cookie, 您可开启脚本内"DeleteCookie"选项 (第96行)
|
||||
|
||||
注: 获取"账号1"或"账号2"的Cookie后, 后续仅可更新该"账号1"或"账号2"的Cookie.
|
||||
如需写入其他账号,您可开启脚本内"DeleteCookie"选项以清除Cookie
|
||||
*************************
|
||||
【Surge 4.2+ 脚本配置】:
|
||||
*************************
|
||||
@ -76,7 +77,7 @@ hostname = api.m.jd.com
|
||||
[task_local]
|
||||
# 京东多合一签到
|
||||
# 注意此为远程路径, 低版本用户请自行调整为本地路径.
|
||||
5 0 * * * https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js, tag=京东多合一签到, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png,enabled=true
|
||||
5 0 * * * https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js, tag=京东多合一签到, img-url=https://raw.githubusercontent.com/NobyDa/mini/master/Color/jd.png,enabled=true
|
||||
|
||||
[rewrite_local]
|
||||
# 获取京东Cookie.
|
||||
@ -92,7 +93,7 @@ var LogDetails = false; //是否开启响应日志, true则开启
|
||||
|
||||
var stop = '0'; //自定义延迟签到, 单位毫秒. 默认分批并发无延迟; 该参数接受随机或指定延迟(例: '2000'则表示延迟2秒; '2000-5000'则表示延迟最小2秒,最大5秒内的随机延迟), 如填入延迟则切换顺序签到(耗时较长), Surge用户请注意在SurgeUI界面调整脚本超时; 注: 该参数Node.js或JSbox环境下已配置数据持久化, 留空(var stop = '')即可清除.
|
||||
|
||||
var DeleteCookie = false; //是否清除Cookie, true则开启.
|
||||
var DeleteCookie = false; //是否清除所有Cookie, true则开启.
|
||||
|
||||
var boxdis = true; //是否开启自动禁用, false则关闭. 脚本运行崩溃时(如VPN断连), 下次运行时将自动禁用相关崩溃接口(仅部分接口启用), 崩溃时可能会误禁用正常接口. (该选项仅适用于QX,Surge,Loon)
|
||||
|
||||
@ -109,8 +110,6 @@ async function all() {
|
||||
await Promise.all([
|
||||
JingDongBean(stop), //京东京豆
|
||||
JingDongStore(stop), //京东超市
|
||||
JingDongWebcasts(stop), //京东直播
|
||||
JingRongBean(stop), //金融简单赚钱
|
||||
JingRongSteel(stop), //金融钢镚
|
||||
JingDongTurn(stop), //京东转盘
|
||||
JDFlashSale(stop), //京东闪购
|
||||
@ -121,7 +120,7 @@ async function all() {
|
||||
JingDongShake(stop), //京东摇一摇
|
||||
JDSecKilling(stop), //京东秒杀
|
||||
JRLuckyLottery(stop), //金融抽奖顶部签到
|
||||
JingDongBuyCar(stop, '319fd268c5df469192d9420a2de4d8d2'), //京东汽车
|
||||
JingDongBuyCar(stop, '31dd4ebdcad341b79e36cb7c29095de9'), //京东汽车
|
||||
JingRongDoll(stop, 'JRDoll', '京东金融-签壹', '4D25A6F482'),
|
||||
JingRongDoll(stop, 'JRTwoDoll', '京东金融-签贰', '3A3E839252'),
|
||||
JingRongDoll(stop, 'JRThreeDoll', '京东金融-签叁', '69F5EC743C'),
|
||||
@ -129,28 +128,25 @@ async function all() {
|
||||
JingRongDoll(stop, 'JRFiveDoll', '京东金融-签伍', '1D06AA3B0F')
|
||||
]);
|
||||
await Promise.all([
|
||||
JDUserSignPre(stop, 'JDCustomized', '京东商城-定制', 'RPordkuhnM4MzR24fLWgc8YRbXJ'), //京东定制
|
||||
JDUserSignPre(stop, 'JDShoes', '京东商城-鞋靴', '4RXyb1W4Y986LJW8ToqMK14BdTD'), //京东鞋靴
|
||||
JDUserSignPre(stop, 'JDCalendar', '京东日历-翻牌', '36V2Qw59VPNsuLxY84vCFtxFzrFs'), //京东日历翻牌
|
||||
JDUserSignPre(stop, 'JDChild', '京东商城-童装', '3Af6mZNcf5m795T8dtDVfDwWVNhJ'), //京东童装馆
|
||||
JDUserSignPre(stop, 'JDBaby', '京东商城-母婴', '3BbAVGQPDd6vTyHYjmAutXrKAos6'), //京东母婴馆
|
||||
JDUserSignPre(stop, 'JD3C', '京东商城-数码', '4SWjnZSCTHPYjE5T7j35rxxuMTb6'), //京东数码电器馆
|
||||
// JDUserSignPre(stop, 'JDSubsidy', '京东晚市-补贴', 'xK148m4kWj5hBcTPuJUNNXH3AkJ'), //京东晚市补贴金
|
||||
JDUserSignPre(stop, 'JDWomen', '京东商城-女装', 'DpSh7ma8JV7QAxSE2gJNro8Q2h9'), //京东女装馆
|
||||
JDUserSignPre(stop, 'JDFineWine', '京东商城-酒饮', 'zGwAUzL3pVGjptBBGeYfpKjYdtX'), //京东酒饮馆
|
||||
JDUserSignPre(stop, 'JDBook', '京东商城-图书', '3SC6rw5iBg66qrXPGmZMqFDwcyXi'), //京东图书
|
||||
JingRongDoll(stop, 'JTDouble', '京东金贴-双签', '1DF13833F7'), //京东金融 金贴双签
|
||||
JingRongDoll(stop, 'XJDouble', '金融现金-双签', 'F68B2C3E71', '', '', '', 'xianjin') //京东金融 现金双签
|
||||
]);
|
||||
await Promise.all([
|
||||
JDUserSignPre(stop, 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'), //京东服饰
|
||||
JDUserSignPre(stop, 'JDUnderwear', '京东商城-内衣', '4PgpL1xqPSW1sVXCJ3xopDbB1f69'), //京东内衣馆
|
||||
JDUserSignPre(stop, 'JDSuitcase', '京东商城-箱包', 'ZrH7gGAcEkY2gH8wXqyAPoQgk6t'), //京东箱包馆
|
||||
JDUserSignPre(stop, 'JDSchool', '京东商城-校园', '2QUxWHx5BSCNtnBDjtt5gZTq7zdZ'), //京东校园
|
||||
JDUserSignPre(stop, 'JDHealth', '京东商城-健康', 'w2oeK5yLdHqHvwef7SMMy4PL8LF'), //京东健康
|
||||
// JDUserSignPre(stop, 'JDPet', '京东商城-宠物', '37ta5sh5ocrMZF3Fz5UMJbTsL42'), //京东宠物馆
|
||||
JDUserSignPre(stop, 'JDShand', '京东拍拍-二手', '3S28janPLYmtFxypu37AYAGgivfp'), //京东拍拍二手
|
||||
JDUserSignPre(stop, 'JDClean', '京东商城-清洁', '2Tjm6ay1ZbZ3v7UbriTj6kHy9dn6'), //京东清洁馆
|
||||
JDUserSignPre(stop, 'JDCare', '京东商城-个护', 'NJ1kd1PJWhwvhtim73VPsD1HwY3'), //京东个人护理馆
|
||||
JDUserSignPre(stop, 'JDCare', '京东商城-个护', '2tZssTgnQsiUqhmg5ooLSHY9XSeN'), //京东个人护理馆
|
||||
JDUserSignPre(stop, 'JDJewels', '京东商城-珠宝', 'zHUHpTHNTaztSRfNBFNVZscyFZU'), //京东珠宝馆
|
||||
// JDUserSignPre(stop, 'JDClocks', '京东商城-钟表', '2BcJPCVVzMEtMUynXkPscCSsx68W'), //京东钟表馆
|
||||
JDUserSignPre(stop, 'JDMakeup', '京东商城-美妆', '2smCxzLNuam5L14zNJHYu43ovbAP'), //京东美妆馆
|
||||
@ -162,8 +158,6 @@ async function all() {
|
||||
default:
|
||||
await JingDongBean(0); //京东京豆
|
||||
await JingDongStore(Wait(stop)); //京东超市
|
||||
await JingDongWebcasts(Wait(stop)); //京东直播
|
||||
await JingRongBean(Wait(stop)); //金融简单赚钱
|
||||
await JingRongSteel(Wait(stop)); //金融钢镚
|
||||
await JingDongTurn(Wait(stop)); //京东转盘
|
||||
await JDFlashSale(Wait(stop)); //京东闪购
|
||||
@ -174,7 +168,7 @@ async function all() {
|
||||
await JingDongShake(Wait(stop)); //京东摇一摇
|
||||
await JDSecKilling(Wait(stop)); //京东秒杀
|
||||
await JRLuckyLottery(Wait(stop)); //金融抽奖顶部签到
|
||||
await JingDongBuyCar(Wait(stop), '319fd268c5df469192d9420a2de4d8d2'); //京东汽车
|
||||
await JingDongBuyCar(Wait(stop), '31dd4ebdcad341b79e36cb7c29095de9'); //京东汽车
|
||||
await JingRongDoll(Wait(stop), 'JRTwoDoll', '京东金融-签贰', '3A3E839252');
|
||||
await JingRongDoll(Wait(stop), 'JRThreeDoll', '京东金融-签叁', '69F5EC743C');
|
||||
await JingRongDoll(Wait(stop), 'JRFourDoll', '京东金融-签肆', '30C4F86264');
|
||||
@ -182,7 +176,7 @@ async function all() {
|
||||
await JingRongDoll(Wait(stop), 'JRDoll', '京东金融-签壹', '4D25A6F482');
|
||||
await JingRongDoll(Wait(stop), 'XJDouble', '金融现金-双签', 'F68B2C3E71', '', '', '', 'xianjin'); //京东金融 现金双签
|
||||
await JingRongDoll(Wait(stop), 'JTDouble', '京东金贴-双签', '1DF13833F7'); //京东金融 金贴双签
|
||||
await JDUserSignPre(Wait(stop), 'JDUnderwear', '京东商城-内衣', '4PgpL1xqPSW1sVXCJ3xopDbB1f69'); //京东内衣馆
|
||||
await JDUserSignPre(Wait(stop), 'JDCustomized', '京东商城-定制', 'RPordkuhnM4MzR24fLWgc8YRbXJ'); //京东定制
|
||||
await JDUserSignPre(Wait(stop), 'JDSuitcase', '京东商城-箱包', 'ZrH7gGAcEkY2gH8wXqyAPoQgk6t'); //京东箱包馆
|
||||
await JDUserSignPre(Wait(stop), 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'); //京东服饰
|
||||
await JDUserSignPre(Wait(stop), 'JDSchool', '京东商城-校园', '2QUxWHx5BSCNtnBDjtt5gZTq7zdZ'); //京东校园
|
||||
@ -192,17 +186,14 @@ async function all() {
|
||||
await JDUserSignPre(Wait(stop), 'JDChild', '京东商城-童装', '3Af6mZNcf5m795T8dtDVfDwWVNhJ'); //京东童装馆
|
||||
await JDUserSignPre(Wait(stop), 'JDBaby', '京东商城-母婴', '3BbAVGQPDd6vTyHYjmAutXrKAos6'); //京东母婴馆
|
||||
await JDUserSignPre(Wait(stop), 'JD3C', '京东商城-数码', '4SWjnZSCTHPYjE5T7j35rxxuMTb6'); //京东数码电器馆
|
||||
// await JDUserSignPre(Wait(stop), 'JDSubsidy', '京东晚市-补贴', 'xK148m4kWj5hBcTPuJUNNXH3AkJ'); //京东晚市补贴金
|
||||
// await JDUserSignPre(Wait(stop), 'JDClocks', '京东商城-钟表', '2BcJPCVVzMEtMUynXkPscCSsx68W'); //京东钟表馆
|
||||
await JDUserSignPre(Wait(stop), 'JDWomen', '京东商城-女装', 'DpSh7ma8JV7QAxSE2gJNro8Q2h9'); //京东女装馆
|
||||
// await JDUserSignPre(Wait(stop), 'JDPet', '京东商城-宠物', '37ta5sh5ocrMZF3Fz5UMJbTsL42'); //京东宠物馆
|
||||
await JDUserSignPre(Wait(stop), 'JDBook', '京东商城-图书', '3SC6rw5iBg66qrXPGmZMqFDwcyXi'); //京东图书
|
||||
await JDUserSignPre(Wait(stop), 'JDShand', '京东拍拍-二手', '3S28janPLYmtFxypu37AYAGgivfp'); //京东拍拍二手
|
||||
await JDUserSignPre(Wait(stop), 'JDMakeup', '京东商城-美妆', '2smCxzLNuam5L14zNJHYu43ovbAP'); //京东美妆馆
|
||||
await JDUserSignPre(Wait(stop), 'JDFineWine', '京东商城-酒饮', 'zGwAUzL3pVGjptBBGeYfpKjYdtX'); //京东酒饮馆
|
||||
await JDUserSignPre(Wait(stop), 'JDVege', '京东商城-菜场', 'Wcu2LVCFMkBP3HraRvb7pgSpt64'); //京东菜场
|
||||
await JDUserSignPre(Wait(stop), 'JDClean', '京东商城-清洁', '2Tjm6ay1ZbZ3v7UbriTj6kHy9dn6'); //京东清洁馆
|
||||
await JDUserSignPre(Wait(stop), 'JDCare', '京东商城-个护', 'NJ1kd1PJWhwvhtim73VPsD1HwY3'); //京东个人护理馆
|
||||
await JDUserSignPre(Wait(stop), 'JDCare', '京东商城-个护', '2tZssTgnQsiUqhmg5ooLSHY9XSeN'); //京东个人护理馆
|
||||
await JDUserSignPre(Wait(stop), 'JDJewels', '京东商城-珠宝', 'zHUHpTHNTaztSRfNBFNVZscyFZU'); //京东珠宝馆
|
||||
await JingRongDoll(Wait(stop), 'JDDouble', '金融京豆-双签', 'F68B2C3E71', '', '', '', 'jingdou'); //京东金融 京豆双签
|
||||
await JingDongSpeedUp(Wait(stop)); //京东天天加速
|
||||
@ -260,29 +251,20 @@ function notify() {
|
||||
var four = `【账号总计】: ${beans+Steel}${beans||Steel?`\n`:`获取失败\n`}`
|
||||
var five = `【其他总计】: ${Subsidy+Money+Cash}${Subsidy||Money||Cash?`\n`:`获取失败\n`}`
|
||||
var DName = merge.TotalBean && merge.TotalBean.nickname ? merge.TotalBean.nickname : "获取失败"
|
||||
var Name = add ? DualAccount ? `【签到号一】: ${DName}\n` : `【签到号二】: ${DName}\n` : ""
|
||||
var cnNum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"];
|
||||
const numFix = !Key && !DualKey ? DualAccount - 2 : Key && DualKey ? DualAccount : DualAccount - 1 || DualAccount
|
||||
const Name = DualKey || OtherKey ? `【签到号${cnNum[numFix]||numFix}】: ${DName}\n` : ``
|
||||
const disables = $nobyda.read("JD_DailyBonusDisables")
|
||||
const amount = disables ? disables.split(",").length : 0
|
||||
const disa = !notify || amount ? `【温馨提示】: 检测到${$nobyda.disable?`上次执行意外崩溃, `:``}已禁用${notify?`${amount}个`:`所有`}接口, 如需开启请前往BoxJs或查看脚本内第99行注释.\n` : ``
|
||||
const disa = !notify || amount ? `【温馨提示】: 检测到${$nobyda.disable?`上次执行意外崩溃, `:``}已禁用${notify?`${amount}个`:`所有`}接口, 如需开启请前往BoxJs或查看脚本内第100行注释.\n` : ``
|
||||
$nobyda.notify("", "", Name + one + two + three + four + five + disa + notify, {
|
||||
'media-url': $nobyda.headUrl || 'https://cdn.jsdelivr.net/gh/Orz-3/task@master/jd.png'
|
||||
'media-url': $nobyda.headUrl || 'https://cdn.jsdelivr.net/gh/NobyDa/mini@master/Color/jd.png'
|
||||
});
|
||||
$nobyda.headUrl = null;
|
||||
if ($nobyda.isJSBox) {
|
||||
if (add && DualAccount) {
|
||||
Shortcut = Name + one + two + three + "\n"
|
||||
} else if (!add && DualAccount) {
|
||||
$intents.finish(Name + one + two + three + four + five + notify)
|
||||
} else if (typeof Shortcut != "undefined") {
|
||||
$intents.finish(Shortcut + Name + one + two + three)
|
||||
}
|
||||
}
|
||||
if (DualAccount) {
|
||||
double();
|
||||
} else {
|
||||
$nobyda.time();
|
||||
$nobyda.done();
|
||||
Shortcut = (typeof(Shortcut) == 'undefined' ? '' : Shortcut) + Name + one + two + three + four + five + "\n"
|
||||
}
|
||||
double();
|
||||
} catch (eor) {
|
||||
$nobyda.notify("通知模块 " + eor.name + "‼️", JSON.stringify(eor), eor.message)
|
||||
} finally {
|
||||
@ -292,13 +274,15 @@ function notify() {
|
||||
}
|
||||
|
||||
function ReadCookie() {
|
||||
DualAccount = true;
|
||||
DualAccount = 1;
|
||||
const EnvInfo = $nobyda.isJSBox ? "JD_Cookie" : "CookieJD"
|
||||
const EnvInfo2 = $nobyda.isJSBox ? "JD_Cookie2" : "CookieJD2"
|
||||
const EnvInfo3 = $nobyda.isJSBox ? "JD_Cookies" : "CookiesJD"
|
||||
if (DeleteCookie) {
|
||||
if ($nobyda.read(EnvInfo) || $nobyda.read(EnvInfo2)) {
|
||||
if ($nobyda.read(EnvInfo) || $nobyda.read(EnvInfo2) || ($nobyda.read(EnvInfo3) || '[]') != '[]') {
|
||||
$nobyda.write("", EnvInfo)
|
||||
$nobyda.write("", EnvInfo2)
|
||||
$nobyda.write("", EnvInfo3)
|
||||
$nobyda.notify("京东Cookie清除成功 !", "", '请手动关闭脚本内"DeleteCookie"选项')
|
||||
$nobyda.done()
|
||||
return
|
||||
@ -310,20 +294,27 @@ function ReadCookie() {
|
||||
GetCookie()
|
||||
return
|
||||
}
|
||||
if (Key || $nobyda.read(EnvInfo)) {
|
||||
Key = Key || $nobyda.read(EnvInfo)
|
||||
DualKey = DualKey || $nobyda.read(EnvInfo2)
|
||||
OtherKey = OtherKey || $nobyda.read(EnvInfo3)
|
||||
KEY = Key || DualKey
|
||||
if (KEY || OtherKey) {
|
||||
if ($nobyda.isJSBox || $nobyda.isNode) {
|
||||
if (Key) $nobyda.write(Key, EnvInfo);
|
||||
if (DualKey) $nobyda.write(DualKey, EnvInfo2);
|
||||
if (OtherKey) $nobyda.write(OtherKey, EnvInfo3);
|
||||
if (stop !== '0') $nobyda.write(stop, "JD_DailyBonusDelay");
|
||||
}
|
||||
add = DualKey || $nobyda.read(EnvInfo2) ? true : false
|
||||
KEY = Key ? Key : $nobyda.read(EnvInfo)
|
||||
out = parseInt($nobyda.read("JD_DailyBonusTimeOut")) || out
|
||||
stop = Wait($nobyda.read("JD_DailyBonusDelay"), true) || Wait(stop, true)
|
||||
boxdis = $nobyda.read("JD_Crash_disable") === "false" || $nobyda.isNode || $nobyda.isJSBox ? false : boxdis
|
||||
LogDetails = $nobyda.read("JD_DailyBonusLog") === "true" || LogDetails
|
||||
ReDis = ReDis ? $nobyda.write("", "JD_DailyBonusDisables") : ""
|
||||
all()
|
||||
if (KEY) {
|
||||
all()
|
||||
} else {
|
||||
double()
|
||||
}
|
||||
} else {
|
||||
$nobyda.notify("京东签到", "", "脚本终止, 未获取Cookie ‼️")
|
||||
$nobyda.done()
|
||||
@ -331,12 +322,30 @@ function ReadCookie() {
|
||||
}
|
||||
|
||||
function double() {
|
||||
add = true
|
||||
DualAccount = false
|
||||
if (DualKey || $nobyda.read($nobyda.isJSBox ? "JD_Cookie2" : "CookieJD2")) {
|
||||
KEY = DualKey ? DualKey : $nobyda.read($nobyda.isJSBox ? "JD_Cookie2" : "CookieJD2")
|
||||
KEY = '';
|
||||
if (DualAccount == 1) {
|
||||
DualAccount++;
|
||||
KEY = Key ? DualKey : ''
|
||||
}
|
||||
if (!KEY && OtherKey) {
|
||||
DualAccount++;
|
||||
let cks = [];
|
||||
try {
|
||||
cks = JSON.parse(OtherKey);
|
||||
} catch (e) {
|
||||
cks = [];
|
||||
console.log(`\n第三及以上账号Cookie读取失败, 请检查Json格式.`)
|
||||
}
|
||||
if (cks.length + 2 >= DualAccount) {
|
||||
KEY = cks[DualAccount - 3].cookie;
|
||||
}
|
||||
}
|
||||
if (KEY) {
|
||||
all()
|
||||
} else {
|
||||
if ($nobyda.isJSBox) {
|
||||
$intents.finish(Shortcut)
|
||||
}
|
||||
$nobyda.time();
|
||||
$nobyda.done();
|
||||
}
|
||||
@ -506,95 +515,6 @@ function JingDongTurnSign(s, code) {
|
||||
});
|
||||
}
|
||||
|
||||
function JingRongBean(s) {
|
||||
merge.JRBean = {};
|
||||
return new Promise(resolve => {
|
||||
if (disable("JRBean")) return resolve()
|
||||
setTimeout(() => {
|
||||
const login = {
|
||||
url: 'https://ms.jr.jd.com/gw/generic/zc/h5/m/queryOpenScreenReward',
|
||||
headers: {
|
||||
Cookie: KEY
|
||||
},
|
||||
body: "reqData=%7B%22channelCode%22%3A%22ZHUANQIAN%22%2C%22clientType%22%3A%22sms%22%2C%22clientVersion%22%3A%2211.0%22%7D"
|
||||
};
|
||||
$nobyda.post(login, async function(error, response, data) {
|
||||
try {
|
||||
if (error) {
|
||||
throw new Error(error)
|
||||
} else {
|
||||
const Details = LogDetails ? "response:\n" + data : '';
|
||||
if (data.match(/\"login\":true/)) {
|
||||
console.log("\n" + "京东金融-金贴查询成功 " + Details)
|
||||
const cc = JSON.parse(data)
|
||||
if (cc.resultData.data.reward === false) {
|
||||
await JRBeanCheckin(s, cc.resultData.data.rewardAmount);
|
||||
} else {
|
||||
const tp = cc.resultData.data.reward === true
|
||||
merge.JRBean.notify = `京东金融-金贴: 失败, 原因: ${tp?`已签过`:`未知`} ⚠️`
|
||||
merge.JRBean.fail = 1
|
||||
}
|
||||
} else {
|
||||
console.log("\n" + "京东金融-金贴查询失败 " + Details)
|
||||
const lt = data.match(/\"login\":false/)
|
||||
merge.JRBean.fail = 1
|
||||
merge.JRBean.notify = `京东金融-金贴: 失败, 原因: ${lt?`Cookie失效‼️`:`未知 ⚠️`}`
|
||||
}
|
||||
}
|
||||
} catch (eor) {
|
||||
$nobyda.AnError("金融金贴-查询", "JRBean", eor, response, data)
|
||||
} finally {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}, s)
|
||||
if (out) setTimeout(resolve, out + s)
|
||||
});
|
||||
}
|
||||
|
||||
function JRBeanCheckin(s, amount) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
const JRBUrl = {
|
||||
url: 'https://ms.jr.jd.com/gw/generic/zc/h5/m/openScreenReward',
|
||||
headers: {
|
||||
Cookie: KEY
|
||||
},
|
||||
body: "reqData=%7B%22channelCode%22%3A%22ZHUANQIAN%22%2C%22clientType%22%3A%22sms%22%2C%22clientVersion%22%3A%2211.0%22%7D"
|
||||
};
|
||||
$nobyda.post(JRBUrl, function(error, response, data) {
|
||||
try {
|
||||
if (error) {
|
||||
throw new Error(error)
|
||||
} else {
|
||||
const Details = LogDetails ? "response:\n" + data : '';
|
||||
if (data.match(/\"rewardCode\":\"00000\"/)) {
|
||||
console.log("\n" + "京东金融-金贴签到成功 " + Details)
|
||||
merge.JRBean.subsidy = amount || 0
|
||||
merge.JRBean.notify = `京东金融-金贴: 成功, 明细: ${amount || `无`}金贴 💰`
|
||||
merge.JRBean.success = 1
|
||||
} else {
|
||||
console.log("\n" + "京东金融-金贴签到失败 " + Details)
|
||||
merge.JRBean.fail = 1
|
||||
if (data.match(/发放失败|70111|10000|60203/)) {
|
||||
merge.JRBean.notify = "京东金融-金贴: 失败, 原因: 已签过 ⚠️"
|
||||
} else {
|
||||
const UnType = data.match(/\"resultCode\":3|请先登录/)
|
||||
merge.JRBean.notify = `京东金融-金贴: 失败, 原因: ${UnType?`Cookie失效‼️`:`未知 ⚠️`}`
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (eor) {
|
||||
$nobyda.AnError("京东金融-金贴", "JRBean", eor, response, data)
|
||||
} finally {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}, s)
|
||||
if (out) setTimeout(resolve, out + s)
|
||||
});
|
||||
}
|
||||
|
||||
function JingRongSteel(s) {
|
||||
merge.JRSteel = {};
|
||||
return new Promise(resolve => {
|
||||
@ -1741,44 +1661,6 @@ function JingDongGetCash(s) {
|
||||
});
|
||||
}
|
||||
|
||||
function JingDongWebcasts(s) {
|
||||
merge.JDWebcasts = {};
|
||||
return new Promise(resolve => {
|
||||
if (disable("JDWebcasts")) return resolve()
|
||||
setTimeout(() => {
|
||||
$nobyda.get({
|
||||
url: `https://api.m.jd.com/api?functionId=getChannelTaskRewardToM&appid=h5-live&body=%7B%22type%22%3A%22signTask%22%2C%22itemId%22%3A%221%22%7D`,
|
||||
headers: {
|
||||
Cookie: KEY,
|
||||
Origin: `https://h.m.jd.com`
|
||||
}
|
||||
}, (error, response, data) => {
|
||||
try {
|
||||
if (error) throw new Error(error)
|
||||
const cc = JSON.parse(data);
|
||||
const Details = LogDetails ? "response:\n" + data : '';
|
||||
if (cc.code == 0 && cc.subCode == 0) {
|
||||
console.log(`\n京东商城-直播签到成功 ${Details}`)
|
||||
merge.JDWebcasts.bean = cc.sum || 0
|
||||
merge.JDWebcasts.success = 1
|
||||
merge.JDWebcasts.notify = `京东商城-直播: 成功, 明细: ${merge.JDWebcasts.bean||`无`}京豆 🐶`
|
||||
} else {
|
||||
console.log(`\n京东商城-直播签到失败 ${Details}`)
|
||||
const tp = data.match(/擦肩而过/) ? `无机会` : cc.code == 3 ? `Cookie失效` : `${cc.msg||`未知`}`
|
||||
merge.JDWebcasts.notify = `京东商城-直播: 失败, 原因: ${tp}${cc.code==3?`‼️`:` ⚠️`}`
|
||||
merge.JDWebcasts.fail = 1
|
||||
}
|
||||
} catch (eor) {
|
||||
$nobyda.AnError("京东商城-直播", "JDWebcasts", eor, response, data)
|
||||
} finally {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}, s)
|
||||
if (out) setTimeout(resolve, out + s)
|
||||
});
|
||||
}
|
||||
|
||||
function JingDongStore(s) {
|
||||
merge.JDGStore = {};
|
||||
return new Promise(resolve => {
|
||||
@ -2205,36 +2087,49 @@ function Wait(readDelay, ini) {
|
||||
|
||||
function GetCookie() {
|
||||
try {
|
||||
if ($request.headers && $request.url.match(/api\.m\.jd\.com.*=signBean/)) {
|
||||
var CV = $request.headers['Cookie']
|
||||
if (CV.match(/pt_key=.+?;/) && CV.match(/pt_pin=.+?;/)) {
|
||||
var CookieValue = CV.match(/pt_key=.+?;/)[0] + CV.match(/pt_pin=.+?;/)[0]
|
||||
var CK1 = $nobyda.read("CookieJD")
|
||||
var CK2 = $nobyda.read("CookieJD2")
|
||||
var AccountOne = CK1 ? CK1.match(/pt_pin=.+?;/) ? CK1.match(/pt_pin=(.+?);/)[1] : null : null
|
||||
var AccountTwo = CK2 ? CK2.match(/pt_pin=.+?;/) ? CK2.match(/pt_pin=(.+?);/)[1] : null : null
|
||||
var UserName = CookieValue.match(/pt_pin=(.+?);/)[1]
|
||||
var DecodeName = decodeURIComponent(UserName)
|
||||
if (!AccountOne || UserName == AccountOne) {
|
||||
var CookieName = " [账号一] ";
|
||||
var CookieKey = "CookieJD";
|
||||
} else if (!AccountTwo || UserName == AccountTwo) {
|
||||
var CookieName = " [账号二] ";
|
||||
var CookieKey = "CookieJD2";
|
||||
} else {
|
||||
$nobyda.notify("更新京东Cookie失败", "非历史写入账号 ‼️", '请开启脚本内"DeleteCookie"以清空Cookie ‼️')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if ($request.method != 'OPTIONS' && $request.headers && $request.url !== 'http://www.apple.com/') {
|
||||
let acObj = {};
|
||||
// 提取ck数据
|
||||
let CV = ($request.headers['Cookie'] || $request.headers['cookie'] || '').replace(/ /g, '');
|
||||
let ckItems = CV.split(';').filter(s => /^(pt_key|pt_pin)=.+/.test(s)).sort();
|
||||
if (ckItems.length == 2) {
|
||||
acObj.cookie = ckItems.join(';') + ';';
|
||||
acObj.userName = decodeURIComponent(acObj.cookie.match(/pt_pin=(.+?);/)[1]);
|
||||
}
|
||||
// 无cookie数据进行提示,有ck数据,找到账号位进行存储
|
||||
if (!acObj.cookie) {
|
||||
$nobyda.notify("写入京东Cookie失败", "", "请查看脚本内说明, 登录网页获取 ‼️")
|
||||
return
|
||||
}
|
||||
const RA = $nobyda.read(CookieKey);
|
||||
if (RA == CookieValue) {
|
||||
console.log(`\n用户名: ${DecodeName}\n与历史京东${CookieName}Cookie相同, 跳过写入 ⚠️`)
|
||||
} else {
|
||||
const WT = $nobyda.write(CookieValue, CookieKey);
|
||||
$nobyda.notify(`用户名: ${DecodeName}`, ``, `${RA?`更新`:`写入`}京东${CookieName}Cookie${WT?`成功 🎉`:`失败 ‼️`}`)
|
||||
const allCk = [$nobyda.read('CookieJD'), $nobyda.read('CookieJD2')];
|
||||
const ocks = $nobyda.read('CookiesJD');
|
||||
let oldCks = [];
|
||||
try {
|
||||
oldCks = (ocks && JSON.parse(ocks)) || [];
|
||||
} catch (e) {
|
||||
console.log(`写入京东Cookie时转换京东扩展账号数据CookiesJD异常,扩展账号信息:\n${ocks}`)
|
||||
oldCks = [];
|
||||
}
|
||||
oldCks.forEach(item => allCk.push(item.cookie));
|
||||
let [status, seatNo] = chooseSeatNo(acObj.cookie, allCk, /pt_pin=(.+?);/);
|
||||
if (status) {
|
||||
if (status > 0) {
|
||||
let WT = '';
|
||||
if (seatNo < 2) {
|
||||
WT = $nobyda.write(acObj.cookie, `CookieJD${seatNo?seatNo+1:''}`);
|
||||
} else {
|
||||
if (oldCks.length <= seatNo - 2) {
|
||||
oldCks.push(acObj);
|
||||
} else {
|
||||
oldCks[seatNo - 2] = acObj;
|
||||
}
|
||||
WT = $nobyda.write(JSON.stringify(oldCks, null, 2), 'CookiesJD');
|
||||
}
|
||||
$nobyda.notify(`用户名: ${acObj.userName}`, ``, `${status==2?`更新`:`写入`}京东 [账号${seatNo+1}] Cookie${WT?`成功 🎉`:`失败 ‼️`}`)
|
||||
} else {
|
||||
console.log(`\n用户名: ${acObj.userName}\n与历史京东 [账号${seatNo+1}] Cookie相同, 跳过写入 ⚠️`)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($request.url === 'http://www.apple.com/') {
|
||||
$nobyda.notify("京东签到", "", "类型错误, 手动运行请选择上下文环境为Cron ⚠️");
|
||||
@ -2244,12 +2139,42 @@ function GetCookie() {
|
||||
} catch (eor) {
|
||||
$nobyda.write("", "CookieJD")
|
||||
$nobyda.write("", "CookieJD2")
|
||||
$nobyda.write("", "CookiesJD")
|
||||
$nobyda.notify("写入京东Cookie失败", "", '已尝试清空历史Cookie, 请重试 ⚠️')
|
||||
console.log(`\n写入京东Cookie出现错误 ‼️\n${JSON.stringify(eor)}\n\n${eor}\n\n${JSON.stringify($request.headers)}\n`)
|
||||
} finally {
|
||||
$nobyda.done()
|
||||
}
|
||||
}
|
||||
// 获取新ck存放位置
|
||||
function chooseSeatNo(newCk, allCk, reg) {
|
||||
// status-获取操作状态-0:异常、1-新增、2-更新、-1-相同 seatNo-存储位置,默认添加到最后面
|
||||
let [status, seatNo] = [1, allCk.length];
|
||||
try {
|
||||
let newId = ((newCk || '').match(reg) || ['', ''])[1];
|
||||
for (let i = 0, len = allCk.length; i < len; i++) {
|
||||
let oldId = ((allCk[i] || '').match(reg) || ['', ''])[1];
|
||||
if (oldId) {
|
||||
// 账号位数据存在,判断是否为当前账号的数据,不是则跳过,否则设置数据并跳出循环
|
||||
if (oldId == newId) {
|
||||
seatNo = i;
|
||||
status = newCk == allCk[i] ? -1 : 2;
|
||||
break;
|
||||
}
|
||||
} else if (seatNo == len) {
|
||||
// 旧cookie无效且在初始账号位,先标记新cookie数据存储于此位置
|
||||
seatNo = i;
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 异常时,不操作cookie
|
||||
status = 0;
|
||||
console.log(`\n查询账号存储位置异常 ‼️\n${JSON.stringify(e)}\n\n${e}\n`)
|
||||
}
|
||||
return [status, seatNo];
|
||||
}
|
||||
|
||||
// Modified from yichahucha
|
||||
function nobyda() {
|
||||
const start = Date.now()
|
||||
@ -2485,4 +2410,4 @@ function nobyda() {
|
||||
done
|
||||
}
|
||||
};
|
||||
ReadCookie();
|
||||
ReadCookie();
|
||||
|
||||
@ -3,17 +3,22 @@ local uci = require "luci.model.uci".cursor()
|
||||
local json = require 'luci.jsonc'
|
||||
|
||||
function write_json(file, content)
|
||||
local json = require 'luci.jsonc'
|
||||
local f = assert(io.open(file, 'w'))
|
||||
f:write(json.stringify(content, 1))
|
||||
f:close()
|
||||
end
|
||||
|
||||
|
||||
local data = {
|
||||
CookieJD = uci:get('jd-dailybonus', '@global[0]', 'cookie'),
|
||||
CookieJD2 = uci:get('jd-dailybonus', '@global[0]', 'cookie2'),
|
||||
CookiesJD = {},
|
||||
JD_DailyBonusDelay = uci:get('jd-dailybonus', '@global[0]', 'stop'),
|
||||
JD_DailyBonusTimeOut = uci:get('jd-dailybonus', '@global[0]', 'out')
|
||||
}
|
||||
|
||||
write_json('/usr/share/jd-dailybonus/CookieSet.json', data)
|
||||
for i, v in pairs( uci:get('jd-dailybonus', '@global[0]', 'Cookies') or {} ) do
|
||||
table.insert(data.CookiesJD, {["cookie"]=v})
|
||||
end
|
||||
|
||||
data.CookiesJD = json.stringify( data.CookiesJD )
|
||||
|
||||
write_json('/usr/share/jd-dailybonus/CookieSet.json', data)
|
||||
|
||||
@ -77,6 +77,14 @@ notify() {
|
||||
fi
|
||||
wget-ssl -q --output-document=/dev/null --post-data="text=$title~&desp=$desc" $serverurl$sckey.send
|
||||
fi
|
||||
|
||||
#Dingding
|
||||
dtoken=$(uci_get_by_type global dd_token)
|
||||
if [ ! -z $dtoken ]; then
|
||||
DTJ_FILE=/tmp/jd-djson.json
|
||||
echo "{\"msgtype\": \"markdown\",\"markdown\": {\"title\":\"${title}\",\"text\":\"${title} <br/> ${desc}\"}}" > ${DTJ_FILE}
|
||||
wget-ssl -q --output-document=/dev/null --header="Content-Type: application/json" --post-file=/tmp/jd-djson.json "https://oapi.dingtalk.com/robot/send?access_token=${dtoken}"
|
||||
fi
|
||||
|
||||
#telegram
|
||||
TG_BOT_TOKEN=$(uci_get_by_type global tg_token)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-serverchan
|
||||
PKG_VERSION:=1.80
|
||||
PKG_VERSION:=1.81
|
||||
PKG_RELEASE:=8
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -8,12 +8,12 @@ s = m:section(TypedSection, "serverchan", "高级设置")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
a=s:option(Value,"up_timeout",translate('设备上线检测超时'))
|
||||
a=s:option(Value,"up_timeout",translate('设备上线检测超时(s)'))
|
||||
a.default = "2"
|
||||
a.optional=false
|
||||
a.datatype="uinteger"
|
||||
|
||||
a=s:option(Value,"down_timeout",translate('设备离线检测超时'))
|
||||
a=s:option(Value,"down_timeout",translate('设备离线检测超时(s)'))
|
||||
a.default = "20"
|
||||
a.optional=false
|
||||
a.datatype="uinteger"
|
||||
|
||||
@ -25,33 +25,23 @@ s.anonymous = true
|
||||
|
||||
--基本设置
|
||||
a=s:taboption("basic", Flag,"serverchan_enable",translate("启用"))
|
||||
a.default=0
|
||||
a.rmempty = true
|
||||
|
||||
a=s:taboption("basic", ListValue,"send_tg",translate("推送模式"))
|
||||
a.default=""
|
||||
a=s:taboption("basic", Value,"sckey",translate('微信推送/新旧共用'), translate("").."<br>旧版调用代码<a href='http://sc.ftqq.com' target='_blank'>点击这里</a><br>调用代码获取<a href='https://sct.ftqq.com/' target='_blank'>点击这里</a><br>")
|
||||
a.rmempty = true
|
||||
a:value("",translate("微信"))
|
||||
a:value("2",translate("微信测试号版"))
|
||||
a:value("1",translate("Telegram"))
|
||||
|
||||
a=s:taboption("basic", Value,"sckey",translate('SCKEY'), translate("Serverchan Sckey").."<br>调用代码获取<a href='http://sc.ftqq.com' target='_blank'>点击这里</a><br><br>")
|
||||
a=s:taboption("basic", Value, "tg_token", translate("TG_token"),translate("").."<br>获取机器人<a href='https://telegram.me/botfather' target='_blank'>点击这里</a><br>新建机器人并拉入群组/频道,填入 token<br>")
|
||||
a.rmempty = true
|
||||
a:depends("send_tg","")
|
||||
|
||||
a=s:taboption("basic", Value,"sctkey",translate('SCKEY'), translate("Serverchan Sckey").."<br>调用代码获取<a href='https://sct.ftqq.com/' target='_blank'>点击这里</a><br><br>")
|
||||
a=s:taboption("basic", Value,"chat_id",translate('TG_chatid'))
|
||||
a.rmempty = true
|
||||
a:depends("send_tg","2")
|
||||
|
||||
a=s:taboption("basic", Value, "tgtoken", translate("tg推送链接"),translate("").."<br>目前公众号已停用,需要自建服务器<br>获取机器人<a href='https://github.com/Fndroid/tg_push_bot' target='_blank'>点击这里</a><br>此处填入推送链接,如https://tgbot.lbyczf.com/sendMessage/:Token<br>")
|
||||
a.rmempty = true
|
||||
a:depends("send_tg","1")
|
||||
a.description = translate('用 tg_token 替换下列URL中的****,并用浏览器打开<br> https://api.telegram.org/bot****/getUpdates<br>找到你的chat_id,并填入<br>{"chat":{"id":TG_chatid,"title":"群组名","type":"channel"}')
|
||||
|
||||
a=s:taboption("basic", Value,"device_name",translate('本设备名称'))
|
||||
a.rmempty = true
|
||||
a.description = translate("在推送信息标题中会标识本设备名称,用于区分推送信息的来源设备")
|
||||
|
||||
a=s:taboption("basic", Value,"sleeptime",translate('检测时间间隔'))
|
||||
a=s:taboption("basic", Value,"sleeptime",translate('检测时间间隔(s)'))
|
||||
a.rmempty = true
|
||||
a.optional = false
|
||||
a.default = "60"
|
||||
@ -72,6 +62,9 @@ a:depends("oui_data","1")
|
||||
a:depends("oui_data","2")
|
||||
a.description = translate("懒得做自动更新了,下载到内存中,重启会重新下载 <br/>若无梯子,还是下到机身吧")
|
||||
|
||||
a=s:taboption("basic", Flag,"reset_regularly",translate("每天零点重置流量数据"))
|
||||
a.rmempty = true
|
||||
|
||||
a=s:taboption("basic", Flag,"debuglevel",translate("开启日志"))
|
||||
a.rmempty = true
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ local dsp = require "luci.dispatcher"
|
||||
}
|
||||
XHR.poll(2, '<%=dsp.build_url("admin/services/serverchan/get_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
if(x && x.status == 200 && document.getElementById("checkbox1").checked == true) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
@ -27,6 +27,7 @@ local dsp = require "luci.dispatcher"
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section" id="_log_fieldset">
|
||||
<input type="checkbox" id="checkbox1" style="vertical-align:middle;height: auto;"checked><%:自动刷新%></input>
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="clearlog()" value="<%:Clear logs%>" />
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: 100%;margin-top: 10px;" data-update="change" rows="30" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
||||
|
||||
@ -10,7 +10,7 @@ function get_config(){
|
||||
|
||||
# 初始化设置信息
|
||||
function read_config(){
|
||||
get_config "serverchan_enable" "sckey" "serverchan_ipv4" "ipv4_interface" "ipv4_URL" "serverchan_ipv6" "ipv6_interface" "ipv6_URL" "serverchan_up" "serverchan_down" "serverchan_sheep" "serverchan_whitelist" "serverchan_blacklist" "serverchan_interface" "starttime" "endtime" "cpuload_enable" "cpuload" "temperature_enable" "temperature" "device_name" "err_enable" "network_err_event" "err_sheep_enable" "system_time_event" "autoreboot_time" "network_restart_time" "public_ip_event" "public_ip_retry_count" "soc_code" "sleeptime" "up_timeout" "down_timeout" "device_aliases" "debuglevel" "cpuload" "temperature" "send_mode" "regular_time" "regular_time_2" "regular_time_3" "interval_time" "thread_num" "timeout_retry_count" "send_tg" "tgtoken" "err_device_aliases" "sctkey" "oui_dir" "oui_data" "client_usage" "client_usage_max" "client_usage_disturb" "client_usage_whitelist"
|
||||
get_config "serverchan_enable" "sckey" "sctkey" "tg_token" "chat_id" "serverchan_ipv4" "ipv4_interface" "ipv4_URL" "serverchan_ipv6" "ipv6_interface" "ipv6_URL" "serverchan_up" "serverchan_down" "serverchan_sheep" "serverchan_whitelist" "serverchan_blacklist" "serverchan_interface" "starttime" "endtime" "cpuload_enable" "cpuload" "temperature_enable" "temperature" "device_name" "err_enable" "network_err_event" "err_sheep_enable" "system_time_event" "autoreboot_time" "network_restart_time" "public_ip_event" "public_ip_retry_count" "soc_code" "sleeptime" "up_timeout" "down_timeout" "device_aliases" "debuglevel" "cpuload" "temperature" "send_mode" "regular_time" "regular_time_2" "regular_time_3" "interval_time" "thread_num" "timeout_retry_count" "err_device_aliases" "oui_dir" "oui_data" "client_usage" "client_usage_max" "client_usage_disturb" "client_usage_whitelist" "reset_regularly"
|
||||
for str_version in "wrtbwmon" "iputils-arping" "curl" "iw"; do
|
||||
eval `echo ${str_version:0:2}"_version"`=`opkg list-installed|grep -w ^${str_version}|awk '{print $3}'` 2>/dev/null
|
||||
done
|
||||
@ -25,7 +25,9 @@ function read_config(){
|
||||
[ -z "$down_timeout" ] || [ "$down_timeout" -eq "0" ] && down_timeout="20";down_timeout=`expr ${down_timeout} / 2 + 1`
|
||||
[ -z "$timeout_retry_count" ] && timeout_retry_count="2";[ "$timeout_retry_count" -eq "0" ] && timeout_retry_count="1"
|
||||
markdown_splitline="%0D%0A%0D%0A---%0D%0A%0D%0A";markdown_linefeed="%0D%0A%0D%0A";markdown_tab=" ";markdown_space=" "
|
||||
[ ! -z "$send_tg" ] && [ "$send_tg" -eq "1" ] && markdown_splitline="%0D%0A%0D%0A%0D%0A%0D%0A" && markdown_tab=""
|
||||
[ -z "$sckey" ] && [ ! -z "$sctkey" ] && sckey="$sctkey" && uci set serverchan.serverchan.sckey="$sctkey" && uci delete serverchan.serverchan.sctkey && uci commit serverchan
|
||||
[ ! -z "$sckey" ] && [ ${sckey:0:3} == "SCU" ] && sckey_url="http://sc.ftqq.com/${sckey}.send"
|
||||
[ ! -z "$sckey" ] && [ ${sckey:0:3} == "SCT" ] && sckey_url="http://sctapi.ftqq.com/${sckey}.send"
|
||||
}
|
||||
|
||||
# 初始化
|
||||
@ -40,10 +42,9 @@ function serverchan_init(){
|
||||
deltemp
|
||||
rm -f ${dir}fd1 ${dir}sheep_usage ${dir}old_sheep_usage ${dir}client_usage_aliases ${dir}old_client_usage_aliases /usr/bin/serverchan/errlog >/dev/null 2>&1
|
||||
[ ! -f "/usr/sbin/wrtbwmon" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】未安装 wrtbwmon ,流量统计不可用" >> ${logfile}
|
||||
for read_str in "ip_version" "cu_version"; do
|
||||
[ -z `eval echo '$'$read_str` ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】依赖项 iputils-arping、curl 未安装,请确认插件是否正常运行" >> ${logfile}
|
||||
done
|
||||
[ -z "$sckey" ] && [ -z "$sctkey" ] && [ -z "$tgtoken" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】请填写正确的 sckey " >> ${logfile} && return 1
|
||||
[ -z "$ip_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 iputils-arping 版本号,请确认插件是否正常运行" >> ${logfile}
|
||||
[ -z "$cu_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 curl 版本号,请确认插件是否正常运行" >> ${logfile}
|
||||
[ -z "$sckey" ] && [ -z "$tg_token" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】请填写正确的 sckey " >> ${logfile} && return 1
|
||||
local interfacelist=`getinterfacelist` && [ -z "$interfacelist" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法正确获取接口信息,请确认插件是否正常运行" >> ${logfile}
|
||||
return 0
|
||||
}
|
||||
@ -121,21 +122,21 @@ function getinterfaceuptime(){
|
||||
# 查询 mac 地址
|
||||
function getmac(){
|
||||
( echo "$tmp_mac"|grep -q "unknown" ) && unset tmp_mac # 为unknown时重新读取
|
||||
[ -f "${dir}ipAddress" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u`
|
||||
[ -f "/var/dhcp.leases" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u`
|
||||
[ -z "$tmp_mac" ] && local tmp_mac=`cat /proc/net/arp|grep "0x2\|0x6"|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}ipAddress" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -f "/var/dhcp.leases" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -z "$tmp_mac" ] && local tmp_mac=`cat /proc/net/arp|grep "0x2\|0x6"|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -z "$tmp_mac" ] && local tmp_mac="unknown"
|
||||
echo "$tmp_mac"
|
||||
}
|
||||
|
||||
# 查询主机名
|
||||
function getname(){
|
||||
[ -z "$tmp_name" ] && local tmp_name=`echo "$device_aliases"|grep -i $2|awk '{print $2}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}ipAddress" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u`
|
||||
[ -z "$tmp_name" ] && local tmp_name=`echo "$device_aliases"|grep -i $2|awk '{print $2}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -f "${dir}ipAddress" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1`
|
||||
( ! echo "$tmp_name"|grep -q -w "unknown\|*" ) && [ ! -z "$tmp_name" ] && echo "$tmp_name" && return || unset tmp_name # 为unknown时重新读取
|
||||
[ -f "/var/dhcp.leases" ] && [ -z "$tmp_name" ] && local tmp_name=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u`
|
||||
[ -f "/var/dhcp.leases" ] && [ -z "$tmp_name" ] && local tmp_name=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1`
|
||||
( ! echo "$tmp_name"|grep -q -w "unknown\|*" ) && [ ! -z "$tmp_name" ] && echo "$tmp_name" && return || unset tmp_name # 为unknown时重新读取
|
||||
[ -z "$dhcp_config" ] && dhcp_config=`uci show dhcp|grep "ip\|mac\|name"`
|
||||
for dhcp_config_str in "host" "domain"; do
|
||||
@ -154,15 +155,15 @@ function getname(){
|
||||
|
||||
# 查询设备接口
|
||||
function getinterface(){
|
||||
[ -f "${dir}ipAddress" ] && local ip_interface=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $5}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$ip_interface" ] && local ip_interface=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $5}'|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}ipAddress" ] && local ip_interface=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $5}'|grep -v "^$"|sort -u|head -n1`
|
||||
[ -f "${dir}tmp_downlist" ] && [ -z "$ip_interface" ] && local ip_interface=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $5}'|grep -v "^$"|sort -u|head -n1`
|
||||
if [ -z "$ip_interface" ] && [ ! -z "$wlan_interface" ]; then
|
||||
for interface in $wlan_interface; do
|
||||
local ip_interface=`iw dev $interface station dump 2>/dev/null|grep Station|grep -i -w ${1}|sed -nr 's#^.*on (.*))#\1#gp'` >/dev/null 2>&1
|
||||
[ ! -z "$ip_interface" ] && echo "$ip_interface" && return
|
||||
done
|
||||
fi
|
||||
[ -z "$ip_interface" ] && local ip_interface=`cat /proc/net/arp|grep "0x2\|0x6"|grep -i -w ${1}|awk '{print $6}'|grep -v "^$"|sort -u`
|
||||
[ -z "$ip_interface" ] && local ip_interface=`cat /proc/net/arp|grep "0x2\|0x6"|grep -i -w ${1}|awk '{print $6}'|grep -v "^$"|sort -u|head -n1`
|
||||
echo "$ip_interface"
|
||||
}
|
||||
|
||||
@ -171,7 +172,7 @@ function getping(){
|
||||
[ "$iw_version" ] && local wlan_online=`iw dev ${ip_interface} station dump|grep -i -w ${ip_mac}|grep Station` >/dev/null 2>&1
|
||||
[ "$wlan_online" ] && return 0
|
||||
for i in `seq 1 ${3}`; do
|
||||
( ! echo "$ip_ms"|grep -q "ms" ) && local ip_ms=$( arping -I `cat /proc/net/arp|grep -w ${1}|awk '{print $6}'|grep -v "^$"|sort -u` -c 20 -f -w ${2} $1 ) 2>/dev/null
|
||||
( ! echo "$ip_ms"|grep -q "ms" ) && local ip_ms=$( arping -I `cat /proc/net/arp|grep -w ${1}|awk '{print $6}'|grep -v "^$"|sort -u|head -n1` -c 20 -f -w ${2} $1 ) 2>/dev/null
|
||||
( ! echo "$ip_ms"|grep -q "ms" ) && local ip_ms=`ping -c 5 -w ${2} ${1}|grep -v '100% packet loss'` 2>/dev/null
|
||||
( ! echo "$ip_ms"|grep -q "ms" ) && sleep 1
|
||||
done
|
||||
@ -202,10 +203,11 @@ function usage(){
|
||||
[ ! -z "$wr_version" ] && ( version_ge "${wr_version}" "1.2.0" ) && wrtbwmon -f ${dir}usage.db 2>/dev/null && return
|
||||
[ ! -z "$wr_version" ] && ( version_le "${wr_version}" "1.0.0" ) || [ -z "$wr_version" ] && wrtbwmon update ${dir}usage.db 2>/dev/null && return
|
||||
elif [ $1 == "get" ] ;then
|
||||
[ ! -f "${dir}usage.db" ] && echo `bytes_for_humans 0` && return
|
||||
[ ! -f "${dir}usage.db" ] && [ ! "$3" ] && echo `bytes_for_humans 0` && return
|
||||
[ ! -f "${dir}usage.db" ] && [ "$3" ] && echo 0 && return
|
||||
[ -z "$total_n" ] && total_n=`cat ${dir}usage.db|head -n1|grep "total"|sed 's/,/\n/g'|awk '/total/{print NR}'` 2>/dev/null
|
||||
[ -z "$total_n" ] && total_n="6"
|
||||
[ "$2" ] && local tmptotal=`cat ${dir}usage.db|sed 's/,,,/,0,0,/g'|sed 's/,,/,0,/g'|sed 's/,/ /g'|grep -i -w ${2}|awk "{print "'$'$total_n"}"|grep -v "^$"|sort -u` 2>/dev/null
|
||||
[ "$2" ] && local tmptotal=`cat ${dir}usage.db|sed 's/,,,/,0,0,/g'|sed 's/,,/,0,/g'|sed 's/,/ /g'|grep -i -w ${2}|awk "{print "'$'$total_n"}"|grep -v "^$"|sort -u|head -n1` 2>/dev/null
|
||||
[ -z "$tmptotal" ] && local tmptotal="0"
|
||||
[ ! "$3" ] && echo `bytes_for_humans ${tmptotal}` || echo "$tmptotal"
|
||||
elif [ $1 == "down" ] ;then
|
||||
@ -238,15 +240,15 @@ function get_client_usage(){
|
||||
if [ "$((`date +%s`-$get_client_usage_time))" -ge "60" ]; then
|
||||
> ${dir}client_usage_aliases
|
||||
for mac in $MACLIST; do
|
||||
( ! cat ${dir}ipAddress|grep -q -i -w $mac|grep -v "^$"|sort -u ) && continue
|
||||
( ! cat ${dir}ipAddress|grep -q -i -w $mac|grep -v "^$"|sort -u|head -n1 ) && continue
|
||||
echo "$mac" `usage get ${mac} bytes` >> ${dir}client_usage_aliases
|
||||
[ -f "${dir}old_client_usage_aliases" ] && get_client_usage_bytes=`cat ${dir}old_client_usage_aliases|grep -i -w $mac|awk '{print $2}'|grep -v "^$"|sort -u` || continue
|
||||
[ -f "${dir}old_client_usage_aliases" ] && get_client_usage_bytes=`cat ${dir}old_client_usage_aliases|grep -i -w $mac|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` || continue
|
||||
[ -z "$get_client_usage_bytes" ] && get_client_usage_bytes="0"
|
||||
if [ "$((`usage get ${mac} bytes`-$get_client_usage_bytes))" -ge "$client_usage_max" ]; then
|
||||
local ip=`cat ${dir}ipAddress|grep -i -w $mac|awk '{print $1}'|grep -v "^$"|sort -u`
|
||||
local ip=`cat ${dir}ipAddress|grep -i -w $mac|awk '{print $1}'|grep -v "^$"|sort -u|head -n1`
|
||||
local ip_name=`getname ${ip} ${mac}`
|
||||
local tmp_usage=$(bytes_for_humans $(expr `usage get ${mac} bytes` - ${get_client_usage_bytes}))
|
||||
local time_up=`cat ${dir}ipAddress|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u`
|
||||
local time_up=`cat ${dir}ipAddress|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1`
|
||||
local ip_total=`usage get $mac` && [ ! -z "$ip_total" ] && local ip_total="${markdown_linefeed}${markdown_tab}总计流量: ${markdown_space}${markdown_space}${markdown_space}${markdown_space}${ip_total}"
|
||||
local time1=`date +%s`
|
||||
local time1=$(time_for_humans `expr ${time1} - ${time_up}`)
|
||||
@ -348,22 +350,24 @@ function serverchan_cron(){
|
||||
/etc/init.d/cron stop
|
||||
/etc/init.d/cron start
|
||||
}
|
||||
if [ -z "$send_mode" ] || [ -z "$serverchan_enable" ]; then
|
||||
del_cron
|
||||
del_cron
|
||||
if [ -z "$serverchan_enable" ] || [ -z "$send_mode" -a -z "$reset_regularly" ]; then
|
||||
re_cron
|
||||
return
|
||||
fi
|
||||
|
||||
# 重置流量
|
||||
if [ ! -z "$reset_regularly" ] && [ "$reset_regularly" -eq "1" ]; then
|
||||
crontab -l > conf && echo -e "0 0 * * * rm /tmp/serverchan/usage.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
crontab -l > conf && echo -e "0 0 * * * rm /tmp/serverchan/usage6.db >/dev/null 2>&1" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
fi
|
||||
[ ! -z "$regular_time_2" ] && local regular_time_2=",${regular_time_2}"
|
||||
[ ! -z "$regular_time_3" ] && local regular_time_3=",${regular_time_3}"
|
||||
# 定时发送
|
||||
if [ ! -z "$regular_time" ] || [ ! -z "$regular_time_2" ] || [ ! -z "$regular_time_3" ]; then
|
||||
( echo `crontab -l`|grep "serverchan"|grep -q " $regular_time$regular_time_2$regular_time_3 " ) && return
|
||||
del_cron
|
||||
crontab -l > conf && echo -e "0 $regular_time$regular_time_2$regular_time_3 * * * /usr/bin/serverchan/serverchan send &" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
# 间隔发送
|
||||
elif [ ! -z "$interval_time" ]; then
|
||||
( echo `crontab -l`|grep "serverchan"|grep -q " */$interval_time " ) && return
|
||||
del_cron
|
||||
crontab -l > conf && echo -e "0 */$interval_time * * * /usr/bin/serverchan/serverchan send &" >> conf && crontab conf && rm -f conf >/dev/null 2>&1
|
||||
fi
|
||||
re_cron
|
||||
@ -375,8 +379,9 @@ function serverchan_disturb(){
|
||||
if [ `date +%H` -ge $endtime -a $starttime -lt $endtime ] || [ `date +%H` -lt $starttime -a $starttime -lt $endtime ] || [ `date +%H` -lt $starttime -a `date +%H` -ge $endtime -a $starttime -gt $endtime ]; then
|
||||
unset sheep_starttime
|
||||
rm -f ${dir}sheep_usage ${dir}old_sheep_usage 2>/dev/null
|
||||
disturb_text="【微信推送】"
|
||||
[ ! -z "$send_tg" ] && [ "$send_tg" -eq "1" ] && disturb_text="【Telegram推送】"
|
||||
[ ! -z "$sckey" ] && [ -z "$sckey" ] && disturb_text="【微信推送】"
|
||||
[ ! -z "$tg_token" ] && [ -z "$sckey" ] && disturb_text="【Telegram推送】"
|
||||
[ ! -z "$tg_token" ] && [ ! -z "$sckey" ] && disturb_text="【微信/TG推送】"
|
||||
return 0
|
||||
else
|
||||
[ -z "$sheep_starttime" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【免打扰】夜深了,该休息了" >> ${logfile} && sheep_starttime=`date +%s`
|
||||
@ -402,6 +407,7 @@ function LockFile(){
|
||||
LockFile lock
|
||||
fi
|
||||
[ $1 = "unlock" ] && rm -f ${dir}serverchan.lock >/dev/null 2>&1
|
||||
return
|
||||
}
|
||||
|
||||
# 检测黑白名单
|
||||
@ -411,6 +417,7 @@ function blackwhitelist(){
|
||||
[ ! -z "$serverchan_whitelist" ] && ( ! echo "$serverchan_whitelist"|grep -q -i -w $1) && return
|
||||
[ ! -z "$serverchan_blacklist" ] && ( echo "$serverchan_blacklist"|grep -q -i -w $1) && return
|
||||
[ ! -z "$serverchan_interface" ] && ( echo `getinterface ${1}`|grep -q -i -w $serverchan_interface ) && return
|
||||
return 1
|
||||
}
|
||||
|
||||
function get_client(){
|
||||
@ -454,7 +461,7 @@ function geterrdevicealiases(){
|
||||
[ -f ${dir}ipAddress ] && local logrow=$(grep -c "" ${dir}ipAddress) || local logrow="0";[ $logrow -eq "0" ] && return
|
||||
local MACLIST=`cat ${dir}ipAddress|awk '{print $2}'|grep -v "^$"|sort -u`
|
||||
for mac in $MACLIST; do
|
||||
[ -z "$err_mac" ] && [ ! -z "$mac" ] && local err_mac=`echo "$err_device_aliases"|grep -i $mac|grep -v "^$"|sort -u`
|
||||
[ -z "$err_mac" ] && [ ! -z "$mac" ] && local err_mac=`echo "$err_device_aliases"|grep -i $mac|grep -v "^$"|sort -u|head -n1`
|
||||
done
|
||||
# 进入免打扰时间已经超过一小时
|
||||
if [ ! -z "$sheep_starttime" ] && [ "$((`date +%s`-$sheep_starttime))" -ge "3600" ]; then
|
||||
@ -616,8 +623,8 @@ function ip_changes(){
|
||||
[ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "2" ] && local IPv6=`getip hostipv6`
|
||||
|
||||
if [ -f ${dir}ip ]; then
|
||||
local last_IPv4=$(cat "${dir}ip"|grep IPv4|awk '{print $2}'|grep -v "^$"|sort -u)
|
||||
local last_IPv6=$(cat "${dir}ip"|grep IPv6|awk '{print $2}'|grep -v "^$"|sort -u)
|
||||
local last_IPv4=$(cat "${dir}ip"|grep IPv4|awk '{print $2}'|grep -v "^$"|sort -u|head -n1)
|
||||
local last_IPv6=$(cat "${dir}ip"|grep IPv6|awk '{print $2}'|grep -v "^$"|sort -u|head -n1)
|
||||
if [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -ne "0" ] && [ ! -z "$IPv4" ] && ( ! echo ${IPv4}|grep -w -q ${last_IPv4} ); then
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}当前IP:${IPv4}" >> ${logfile}
|
||||
echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}ip
|
||||
@ -667,16 +674,18 @@ function up(){
|
||||
getping ${1} ${up_timeout} "1";local ping_online=$?
|
||||
if [ "$ping_online" -eq "0" ]; then
|
||||
LockFile lock
|
||||
[ -f "${dir}tmp_downlist" ] && local tmp_downip=`cat ${dir}tmp_downlist|grep -w ${1}|grep -v "^$"|sort -u`
|
||||
[ -f "${dir}tmp_downlist" ] && local tmp_downip=`cat ${dir}tmp_downlist|grep -w ${1}|grep -v "^$"|sort -u|head -n1`
|
||||
if [ ! -z "$tmp_downip" ]; then
|
||||
cat ${dir}tmp_downlist|grep -w ${1}|grep -v "^$"|sort -u >> ${dir}ipAddress
|
||||
cat ${dir}tmp_downlist|grep -w ${1}|grep -v "^$"|sort -u|head -n1 >> ${dir}ipAddress
|
||||
sed -i "/^${1} /d" ${dir}tmp_downlist
|
||||
else
|
||||
usage down $1
|
||||
local ip_name=`getname ${1} ${ip_mac}`
|
||||
blackwhitelist ${ip_mac};local ip_blackwhite=$?
|
||||
echo "$1 ${ip_mac} ${ip_name} `date +%s` ${ip_interface}" >> ${dir}ipAddress
|
||||
[ -f "${dir}send_enable.lock" ] || [ -z "$serverchan_up" ] || [ "$serverchan_up" -ne "1" ] || [ -z "$ip_blackwhite" ] || [ "$ip_blackwhite" -ne 0 ] && LockFile unlock && return
|
||||
[ -f "${dir}send_enable.lock" ] || [ -z "$serverchan_up" ] || [ -z "$ip_blackwhite" ] && LockFile unlock && return
|
||||
[ ! -z "$serverchan_up" ] && [ "$serverchan_up" -ne "1" ] && LockFile unlock && return
|
||||
[ ! -z "$ip_blackwhite" ] && [ "$ip_blackwhite" -ne "0" ] && LockFile unlock && return
|
||||
[ -f "${dir}title" ] && local title=`cat ${dir}title`
|
||||
[ -f "${dir}content" ] && local content=`cat ${dir}content`
|
||||
if [ -z "$title" ]; then
|
||||
@ -690,7 +699,7 @@ function up(){
|
||||
local content="${markdown_splitline}#### 新设备连接${markdown_linefeed}${markdown_tab}客户端名:${markdown_space}${markdown_space}${markdown_space}${markdown_space}${markdown_space}${ip_name}${markdown_linefeed}${markdown_tab}客户端IP: ${markdown_space}${markdown_space}${markdown_space}${markdown_space}${1}${markdown_linefeed}${markdown_tab}客户端MAC:${markdown_space}${markdown_space}${markdown_space}${markdown_space}${ip_mac}${markdown_linefeed}${markdown_tab}网络接口:${markdown_space}${markdown_space}${markdown_space}${markdown_space}${markdown_space}${ip_interface}"
|
||||
fi
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}新设备 ${ip_name} ${1} 连接了">> ${logfile}
|
||||
[ ! -z "$serverchan_blacklist" ] && local title="你偷偷关注的设备上线了"
|
||||
#[ ! -z "$serverchan_blacklist" ] && local title="你偷偷关注的设备上线了"
|
||||
[ ! -z "$title" ] && echo "$title" >${dir}title
|
||||
[ ! -z "$content" ] && echo -n "$content" >>${dir}content
|
||||
fi
|
||||
@ -706,14 +715,14 @@ function down(){
|
||||
getping ${1} ${down_timeout} ${timeout_retry_count};local ping_online=$?
|
||||
if [ "$ping_online" -eq "1" ]; then
|
||||
LockFile lock
|
||||
[ ! -f "${dir}send_enable.lock" ] && cat ${dir}ipAddress|grep -w ${1}|grep -v "^$"|sort -u >> ${dir}tmp_downlist
|
||||
[ ! -f "${dir}send_enable.lock" ] && cat ${dir}ipAddress|grep -w ${1}|grep -v "^$"|sort -u|head -n1 >> ${dir}tmp_downlist
|
||||
sed -i "/^${1} /d" ${dir}ipAddress
|
||||
LockFile unlock
|
||||
else
|
||||
local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u`
|
||||
local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1`
|
||||
if [ "$ip_name" != "$tmp_name" ]; then
|
||||
LockFile lock
|
||||
local tmp_str=$(echo "$1 ${ip_mac} ${ip_name} `cat ${dir}ipAddress|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u` ${ip_interface}")
|
||||
local tmp_str=$(echo "$1 ${ip_mac} ${ip_name} `cat ${dir}ipAddress|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1` ${ip_interface}")
|
||||
sed -i "/^${1} /d" ${dir}ipAddress
|
||||
echo "$tmp_str" >> ${dir}ipAddress
|
||||
LockFile unlock
|
||||
@ -728,9 +737,11 @@ function down_send(){
|
||||
for ip in $IPLIST; do
|
||||
local ip_mac=`getmac ${ip}`
|
||||
blackwhitelist ${ip_mac};local ip_blackwhite=$?
|
||||
[ -z "$serverchan_down" ] || [ "$serverchan_down" -ne "1" ] || [ -z "$ip_blackwhite" ] || [ "$ip_blackwhite" -ne 0 ] && continue
|
||||
[ -z "$serverchan_down" ] || [ -z "$ip_blackwhite" ] && continue
|
||||
[ ! -z "$serverchan_down" ] && [ "$serverchan_down" -ne "1" ] && continue
|
||||
[ ! -z "$ip_blackwhite" ] && [ "$ip_blackwhite" -ne "0" ] && continue
|
||||
local ip_name=`getname ${ip} ${ip_mac}`
|
||||
local time_up=`cat ${dir}tmp_downlist|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u`
|
||||
local time_up=`cat ${dir}tmp_downlist|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1`
|
||||
local ip_total=`usage get $ip_mac` && [ ! -z "$ip_total" ] && local ip_total="${markdown_linefeed}${markdown_tab}总计流量: ${markdown_space}${markdown_space}${markdown_space}${markdown_space}${ip_total}"
|
||||
local time1=`date +%s`
|
||||
local time1=$(time_for_humans `expr ${time1} - ${time_up}`)
|
||||
@ -860,7 +871,7 @@ function send(){
|
||||
if [ ! -z "$router_status" ] && [ "$router_status" -eq "1" ]; then
|
||||
local systemload=`cat /proc/loadavg|awk '{print $1" "$2" "$3}'`
|
||||
local cpuload=`getcpu`
|
||||
local ramload=`free -m|sed -n '2p'|awk '{print""($3/$2)*100"%"}'`
|
||||
local ramload=`free -m|sed -n '2p'|awk '{printf "%.2f%%\n",($3/$2)*100}'`
|
||||
local systemstatustime=`cat /proc/uptime|awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("运行时间:%d天%d时%d分%d秒",run_days,run_hour,run_minute,run_second)}'`;unset run_days run_hour run_minute run_second
|
||||
local send_content="${send_content}${markdown_splitline}#### 系统运行状态"
|
||||
local send_content="${send_content}${markdown_linefeed}${markdown_tab}平均负载:${systemload}"
|
||||
@ -891,7 +902,7 @@ function send(){
|
||||
local IPLIST=`cat ${dir}ipAddress 2>/dev/null|awk '{print $1}'`
|
||||
[ -z "$IPLIST" ] && local send_content="${send_content}${markdown_splitline}#### 当前无在线设备" || local send_content="${send_content}${markdown_splitline}#### 在线设备"
|
||||
for ip in $IPLIST; do
|
||||
local time_up=`cat ${dir}ipAddress|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u`
|
||||
local time_up=`cat ${dir}ipAddress|grep -w ${ip}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1`
|
||||
local time1=`date +%s`
|
||||
local time1=$(time_for_humans `expr ${time1} - ${time_up}`)
|
||||
local ip_mac=`getmac ${ip}`
|
||||
@ -906,9 +917,8 @@ function send(){
|
||||
local send_title=`echo "$send_title"|sed $'s/\ /%20/g'|sed $'s/\"/%22/g'|sed $'s/\#/%23/g'|sed $'s/\&/%26/g'|sed $'s/\,/%2C/g'|sed $'s/\//%2F/g'|sed $'s/\:/%3A/g'|sed $'s/\;/%3B/g'|sed $'s/\=/%3D/g'|sed $'s/\@/%40/g'`
|
||||
[ -z "$send_content" ] && local send_content="${markdown_splitline}#### 我遇到了一个难题${markdown_linefeed}${markdown_tab}定时发送选项错误,你没有选择需要发送的项目,该怎么办呢${markdown_splitline}"
|
||||
local nowtime=`date "+%Y-%m-%d %H:%M:%S"`
|
||||
[ "$send_disturb" -eq "0" ] && [ -z "$send_tg" ] && curl -s "http://sc.ftqq.com/${sckey}.send?text=${send_title}" -d "&desp=${nowtime}${markdown_linefeed}${send_content}" >/dev/null 2>&1
|
||||
[ "$send_disturb" -eq "0" ] && [ ! -z "$send_tg" ] && [ "$send_tg" -eq "2" ] && curl -s "http://sctapi.ftqq.com/${sctkey}.send?text=${send_title}" -d "desp=${nowtime}${markdown_linefeed}${send_content}" >/dev/null 2>&1
|
||||
[ "$send_disturb" -eq "0" ] && [ ! -z "$send_tg" ] && [ "$send_tg" -eq "1" ] && curl -d "text=${send_title}${markdown_linefeed}${nowtime}${markdown_linefeed}${send_content}" -X POST "${tgtoken}" >/dev/null 2>&1
|
||||
[ "$send_disturb" -eq "0" ] && [ ! -z "$sckey" ] && curl -s "${sckey_url}?text=${send_title}" -d "&desp=${nowtime}${markdown_linefeed}${send_content}" >/dev/null 2>&1
|
||||
[ "$send_disturb" -eq "0" ] && [ ! -z "$tg_token" ] && curl -s "https://api.telegram.org/bot${tg_token}/sendMessage" -d "chat_id=${chat_id}&text=${send_title}${nowtime}${send_content}" >/dev/null 2>&1
|
||||
deltemp
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}定时推送任务完成" >> ${logfile}
|
||||
}
|
||||
@ -982,9 +992,9 @@ while [ "$serverchan_enable" -eq "1" ]; do
|
||||
nowtime=`date "+%Y-%m-%d %H:%M:%S"`
|
||||
[ ! -z "$device_name" ] && title="【$device_name】$title"
|
||||
title=`echo "$title"|sed $'s/\ /%20/g'|sed $'s/\"/%22/g'|sed $'s/\#/%23/g'|sed $'s/\&/%26/g'|sed $'s/\,/%2C/g'|sed $'s/\//%2F/g'|sed $'s/\:/%3A/g'|sed $'s/\;/%3B/g'|sed $'s/\=/%3D/g'|sed $'s/\@/%40/g'`
|
||||
[ "$disturb" -eq "0" ] && [ -z "$send_tg" ] && curl -s "http://sc.ftqq.com/${sckey}.send?text=${title}" -d "desp=${nowtime}${markdown_linefeed}${content}" >/dev/null 2>&1
|
||||
[ "$disturb" -eq "0" ] && [ ! -z "$send_tg" ] && [ "$send_tg" -eq "2" ] && curl -s "http://sctapi.ftqq.com/${sctkey}.send?text=${title}" -d "desp=${nowtime}${markdown_linefeed}${content}" >/dev/null 2>&1
|
||||
[ "$disturb" -eq "0" ] && [ ! -z "$send_tg" ] && [ "$send_tg" -eq "1" ] && curl -d "text=${title}${markdown_linefeed}${nowtime}${markdown_linefeed}${content}" -X POST "${tgtoken}" >/dev/null 2>&1
|
||||
[ "$disturb" -eq "0" ] && [ ! -z "$sckey" ] && curl -s "${sckey_url}?text=${title}" -d "desp=${nowtime}${markdown_linefeed}${content}" >/dev/null 2>&1
|
||||
[ "$disturb" -eq "0" ] && [ ! -z "$tg_token" ] && curl -s "https://api.telegram.org/bot${tg_token}/sendMessage" -d "chat_id=${chat_id}&text=${title}${nowtime}${content}" >/dev/null 2>&1
|
||||
|
||||
fi
|
||||
|
||||
while [ -f "${dir}send_enable.lock" ]; do
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt
|
||||
# <https://immortalwrt.org>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=msgpack-c
|
||||
PKG_VERSION:=3.3.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@GHCODELOAD/msgpack/msgpack-c/tar.gz/cpp-$(PKG_VERSION)?
|
||||
PKG_HASH:=754c3ace499a63e45b77ef4bcab4ee602c2c414f58403bce826b76ffc2f77d0b
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-cpp-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=BSL-1.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
CMAKE_OPTIONS+= -DMSGPACK_BUILD_EXAMPLES:BOOL=OFF
|
||||
|
||||
define Package/libmsgpack-c
|
||||
SECTION:=lib
|
||||
CATEGORY:=Libraries
|
||||
URL:=https://github.com/msgpack/msgpack-c
|
||||
TITLE:=MessagePack implementation for C and C++ / msgpack.org[C/C++]
|
||||
endef
|
||||
|
||||
define Package/libmsgpack-c/description
|
||||
MessagePack is an efficient binary serialization format, which lets you exchange data among multiple languages like JSON, except that it's faster and smaller. Small integers are encoded into a single byte and short strings require only one extra byte in addition to the strings themselves.
|
||||
endef
|
||||
|
||||
define Package/libmsgpack-c/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libmsgpackc.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libmsgpack-c))
|
||||
@ -1,57 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt
|
||||
# <https://immortalwrt.org>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=tmate
|
||||
PKG_VERSION:=2.4.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/tmate-io/tmate.git
|
||||
PKG_SOURCE_DATE:=2020-04-25
|
||||
PKG_SOURCE_VERSION:=cbec43f56dfb48c2fb6e00faa2cb85443d4b7d8f
|
||||
PKG_MIRROR_HASH:=8622869c8acfa147275d4658fbc2c9afdc9dde45d5d07fc4a4cb51ec740a8ac7
|
||||
|
||||
PKG_LICENSE:=ISC
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_DEPENDS:=ncurses
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/tmate
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=SSH
|
||||
TITLE:=Instant Terminal Sharing
|
||||
URL:=https://tmate.io
|
||||
DEPENDS:=+libpthread +libevent2 +libssh +libmsgpack-c +libncurses
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--oldincludedir=$(STAGING_DIR)
|
||||
|
||||
CONFIGURE_VARS+= \
|
||||
LIBSSH_CFLAGS="-I$(STAGING_DIR)/usr/include" \
|
||||
LIBSSH_LIBS="-lssh"
|
||||
|
||||
define Package/tmate/description
|
||||
Tmate is a fork of tmux. It provides an instant pairing solution.
|
||||
endef
|
||||
|
||||
define Package/tmate/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/tmate $(1)/usr/bin/tmate
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,tmate))
|
||||
@ -1,67 +0,0 @@
|
||||
diff -Naur /dev/null b/compat/forkpty-linux.c
|
||||
--- /dev/null 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/compat/forkpty-linux.c 2014-01-08 12:44:00.885192436 +0100
|
||||
@@ -0,0 +1,63 @@
|
||||
+#include <fcntl.h>
|
||||
+#include <sys/ioctl.h>
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <termios.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int login_tty(int fd)
|
||||
+{
|
||||
+ setsid();
|
||||
+ if (ioctl(fd, TIOCSCTTY, NULL) == -1) return -1;
|
||||
+ dup2(fd, 0);
|
||||
+ dup2(fd, 1);
|
||||
+ dup2(fd, 2);
|
||||
+ if (fd > 2) close(fd);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
|
||||
+{
|
||||
+ char buf[512];
|
||||
+ int master, slave;
|
||||
+
|
||||
+ master = open("/dev/ptmx", O_RDWR);
|
||||
+ if (master == -1) return -1;
|
||||
+ if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail;
|
||||
+
|
||||
+ slave = open(buf, O_RDWR | O_NOCTTY);
|
||||
+ if (slave == -1) goto fail;
|
||||
+
|
||||
+ /* XXX Should we ignore errors here? */
|
||||
+ if (termp) tcsetattr(slave, TCSAFLUSH, termp);
|
||||
+ if (winp) ioctl(slave, TIOCSWINSZ, winp);
|
||||
+
|
||||
+ *amaster = master;
|
||||
+ *aslave = slave;
|
||||
+ if (name != NULL) strcpy(name, buf);
|
||||
+ return 0;
|
||||
+
|
||||
+fail:
|
||||
+ close(master);
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+int forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
|
||||
+{
|
||||
+ int master, slave, pid;
|
||||
+ if (openpty(&master, &slave, name, termp, winp) == -1) return -1;
|
||||
+ switch (pid = fork()) {
|
||||
+ case -1:
|
||||
+ return -1;
|
||||
+ case 0:
|
||||
+ close(master);
|
||||
+ if (login_tty (slave)) _exit (1);
|
||||
+ return 0;
|
||||
+ default:
|
||||
+ *amaster = master;
|
||||
+ close (slave);
|
||||
+ return pid;
|
||||
+ }
|
||||
+}
|
||||
@ -1,11 +0,0 @@
|
||||
--- a/compat/setenv.c 2019-11-17 06:09:38.000000000 +0800
|
||||
+++ b/compat/setenv.c 2020-02-20 05:36:25.183144203 +0800
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "tmux.h"
|
||||
|
||||
int
|
||||
-setenv(const char *name, const char *value, unused int overwrite)
|
||||
+setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
char *newval;
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=v2ray-plugin
|
||||
PKG_VERSION:=4.36.0
|
||||
PKG_VERSION:=4.36.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@GHCODELOAD/teddysun/v2ray-plugin/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=4672169553dd5ce7e700303d2e88dc5bd6acf02f53b4ded8d1214fb6e44b5482
|
||||
PKG_HASH:=70cf85958a5233c8798990f4b7de57ce6f2e9a4535345260df06a4962a21e85a
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
@ -20,7 +20,7 @@ PKG_CONFIG_DEPENDS:= \
|
||||
LUCI_TITLE:=SS/SSR/V2Ray/Trojan/NaiveProxy/Socks5/Tun LuCI interface
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+coreutils +coreutils-base64 +dns2socks +dnsmasq-full +ipset +ip-full \
|
||||
+iptables-mod-tproxy +ipt2socks-alt +lua +libuci-lua +microsocks +pdnsd-alt +tcping \
|
||||
+iptables-mod-tproxy +lua +libuci-lua +microsocks +pdnsd-alt +tcping \
|
||||
+resolveip +shadowsocksr-libev-ssr-check +wget-ssl \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_Kcptun:kcptun-client \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=v2ray
|
||||
PKG_VERSION:=4.36.0
|
||||
PKG_VERSION:=4.36.2
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/v2ray-core-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=v2ray-core-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@GHCODELOAD/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=2515c1addb961756b2d8c0e1a4d392882f51766335e4851121f58a7cb785eb2c
|
||||
PKG_HASH:=e7f7ceefd4cd9d2e57d18cecf55228a5a126c6ed5ee53767660601c35e70535c
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gettext-full
|
||||
PKG_VERSION:=0.21
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=gettext-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@GNU/gettext
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,1,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \
|
||||
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
|
||||
< $(srcdir)/libgnuintl.in.h \
|
||||
| if test '@WOE32DLL@' = yes; then \
|
||||
@ -93,7 +93,7 @@
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,1,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \
|
||||
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
|
||||
< $(srcdir)/libgnuintl.in.h > libintl.h
|
||||
MOSTLYCLEANFILES += libintl.h
|
||||
@ -278,7 +278,7 @@
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,1,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \
|
||||
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
|
||||
< $(srcdir)/libgnuintl.in.h \
|
||||
| if test '@WOE32DLL@' = yes; then \
|
||||
@ -287,7 +287,7 @@
|
||||
-e 's,@''HAVE_SNPRINTF''@,@HAVE_SNPRINTF@,g' \
|
||||
-e 's,@''HAVE_WPRINTF''@,@HAVE_WPRINTF@,g' \
|
||||
- -e 's,@''HAVE_NAMELESS_LOCALES''@,@HAVE_NAMELESS_LOCALES@,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,1,g' \
|
||||
+ -e 's,@''HAVE_NAMELESS_LOCALES''@,0,g' \
|
||||
-e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
|
||||
< $(srcdir)/libgnuintl.in.h > libintl.h
|
||||
MOSTLYCLEANFILES += libintl.h
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mbedtls
|
||||
PKG_VERSION:=2.16.9
|
||||
PKG_VERSION:=2.16.10
|
||||
PKG_RELEASE:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=fc17ff7d8c11d08f23ae2800a18269408ad2c24ea6bb8b9363e41a01c2425697
|
||||
PKG_HASH:=96257bb03b30300b2f35f861ffe204ed957e9fd0329d80646fe57fc49f589b29
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
|
||||
@ -144,7 +144,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT
|
||||
@@ -1779,7 +1779,7 @@
|
||||
@@ -1796,7 +1796,7 @@
|
||||
*
|
||||
* Comment this to disable run-time checking and save ROM space
|
||||
*/
|
||||
@ -153,7 +153,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
|
||||
@@ -2109,7 +2109,7 @@
|
||||
@@ -2126,7 +2126,7 @@
|
||||
* MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256
|
||||
* MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
|
||||
*/
|
||||
@ -162,7 +162,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ARIA_C
|
||||
@@ -2175,7 +2175,7 @@
|
||||
@@ -2192,7 +2192,7 @@
|
||||
* This module enables the AES-CCM ciphersuites, if other requisites are
|
||||
* enabled as well.
|
||||
*/
|
||||
@ -171,7 +171,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CERTS_C
|
||||
@@ -2187,7 +2187,7 @@
|
||||
@@ -2204,7 +2204,7 @@
|
||||
*
|
||||
* This module is used for testing (ssl_client/server).
|
||||
*/
|
||||
@ -180,7 +180,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CHACHA20_C
|
||||
@@ -2295,7 +2295,7 @@
|
||||
@@ -2312,7 +2312,7 @@
|
||||
* \warning DES is considered a weak cipher and its use constitutes a
|
||||
* security risk. We recommend considering stronger ciphers instead.
|
||||
*/
|
||||
@ -189,7 +189,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_DHM_C
|
||||
@@ -2458,7 +2458,7 @@
|
||||
@@ -2475,7 +2475,7 @@
|
||||
* This module adds support for the Hashed Message Authentication Code
|
||||
* (HMAC)-based key derivation function (HKDF).
|
||||
*/
|
||||
@ -198,7 +198,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_HMAC_DRBG_C
|
||||
@@ -2768,7 +2768,7 @@
|
||||
@@ -2785,7 +2785,7 @@
|
||||
*
|
||||
* This module enables abstraction of common (libc) functions.
|
||||
*/
|
||||
@ -207,7 +207,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_POLY1305_C
|
||||
@@ -2789,7 +2789,7 @@
|
||||
@@ -2806,7 +2806,7 @@
|
||||
* Caller: library/md.c
|
||||
*
|
||||
*/
|
||||
@ -216,7 +216,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_RSA_C
|
||||
@@ -2896,7 +2896,7 @@
|
||||
@@ -2913,7 +2913,7 @@
|
||||
*
|
||||
* Requires: MBEDTLS_CIPHER_C
|
||||
*/
|
||||
@ -225,7 +225,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_CLI_C
|
||||
@@ -2996,7 +2996,7 @@
|
||||
@@ -3013,7 +3013,7 @@
|
||||
*
|
||||
* This module provides run-time version information.
|
||||
*/
|
||||
@ -234,7 +234,7 @@
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_X509_USE_C
|
||||
@@ -3106,7 +3106,7 @@
|
||||
@@ -3123,7 +3123,7 @@
|
||||
* Module: library/xtea.c
|
||||
* Caller:
|
||||
*/
|
||||
|
||||
@ -40,7 +40,7 @@ local function get_new_port()
|
||||
return new_port
|
||||
end
|
||||
|
||||
function gen_outbound(node, tag, is_proxy)
|
||||
function gen_outbound(node, tag, is_proxy, proxy_tag)
|
||||
local result = nil
|
||||
if node and node ~= "nil" then
|
||||
local node_id = node[".name"]
|
||||
@ -48,20 +48,15 @@ function gen_outbound(node, tag, is_proxy)
|
||||
tag = node_id
|
||||
end
|
||||
|
||||
if is_proxy and is_proxy == "1" then
|
||||
new_port = get_new_port()
|
||||
table.insert(inbounds, {
|
||||
tag = "proxy_" .. tag,
|
||||
listen = "127.0.0.1",
|
||||
port = new_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {network = "tcp,udp", address = node.address, port = tonumber(node.port)}
|
||||
})
|
||||
if node.tls_serverName == nil then
|
||||
node.tls_serverName = node.address
|
||||
end
|
||||
node.address = "127.0.0.1"
|
||||
node.port = new_port
|
||||
if proxy_tag then
|
||||
node.proxySettings = {
|
||||
tag = proxy_tag,
|
||||
transportLayer = true
|
||||
}
|
||||
end
|
||||
|
||||
if node.type == "Xray" or node.type == "V2ray" then
|
||||
is_proxy = nil
|
||||
end
|
||||
|
||||
if node.type ~= "Xray" and node.type ~= "V2ray" then
|
||||
@ -102,6 +97,7 @@ function gen_outbound(node, tag, is_proxy)
|
||||
_flag_tag = node_id,
|
||||
_flag_is_proxy = (is_proxy and is_proxy == "1") and "1" or "0",
|
||||
tag = tag,
|
||||
proxySettings = node.proxySettings or nil,
|
||||
protocol = node.protocol,
|
||||
mux = (node.stream_security ~= "xtls") and {
|
||||
enabled = (node.mux == "1") and true or false,
|
||||
@ -265,35 +261,41 @@ if node_section then
|
||||
else
|
||||
local default_node = ucursor:get_all(appname, default_node_id)
|
||||
local main_node_id = node.main_node or "nil"
|
||||
local is_proxy = "0"
|
||||
local proxy_tag
|
||||
if main_node_id ~= "nil" then
|
||||
if main_node_id == default_node_id then
|
||||
else
|
||||
new_port = get_new_port()
|
||||
table.insert(inbounds, {
|
||||
tag = "proxy_default",
|
||||
listen = "127.0.0.1",
|
||||
port = new_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {network = "tcp,udp", address = default_node.address, port = tonumber(default_node.port)}
|
||||
})
|
||||
if default_node.tls_serverName == nil then
|
||||
default_node.tls_serverName = default_node.address
|
||||
end
|
||||
default_node.address = "127.0.0.1"
|
||||
default_node.port = new_port
|
||||
local node = ucursor:get_all(appname, main_node_id)
|
||||
local outbound = gen_outbound(node, "main")
|
||||
if outbound then
|
||||
table.insert(outbounds, outbound)
|
||||
table.insert(rules, 1, {
|
||||
type = "field",
|
||||
inboundTag = {"proxy_default"},
|
||||
outboundTag = "main"
|
||||
})
|
||||
if main_node_id ~= default_node_id then
|
||||
local main_node = ucursor:get_all(appname, main_node_id)
|
||||
local main_node_outbound = gen_outbound(main_node, "main")
|
||||
if main_node_outbound then
|
||||
table.insert(outbounds, main_node_outbound)
|
||||
is_proxy = "1"
|
||||
proxy_tag = "main"
|
||||
if default_node.type ~= "Xray" and default_node.type ~= "V2ray" then
|
||||
proxy_tag = nil
|
||||
new_port = get_new_port()
|
||||
table.insert(inbounds, {
|
||||
tag = "proxy_default",
|
||||
listen = "127.0.0.1",
|
||||
port = new_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {network = "tcp,udp", address = default_node.address, port = tonumber(default_node.port)}
|
||||
})
|
||||
if default_node.tls_serverName == nil then
|
||||
default_node.tls_serverName = default_node.address
|
||||
end
|
||||
default_node.address = "127.0.0.1"
|
||||
default_node.port = new_port
|
||||
table.insert(rules, 1, {
|
||||
type = "field",
|
||||
inboundTag = {"proxy_default"},
|
||||
outboundTag = "main"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local default_outbound = gen_outbound(default_node, "default")
|
||||
local default_outbound = gen_outbound(default_node, "default", is_proxy, proxy_tag)
|
||||
if default_outbound then
|
||||
table.insert(outbounds, default_outbound)
|
||||
default_outboundTag = "default"
|
||||
@ -326,15 +328,30 @@ if node_section then
|
||||
outboundTag = name
|
||||
else
|
||||
local _node = ucursor:get_all(appname, _node_id)
|
||||
local _outbound = gen_outbound(_node, name, is_proxy)
|
||||
if _outbound then
|
||||
if node.type ~= "Xray" and node.type ~= "V2ray" then
|
||||
if is_proxy == "1" then
|
||||
new_port = get_new_port()
|
||||
table.insert(inbounds, {
|
||||
tag = "proxy_" .. name,
|
||||
listen = "127.0.0.1",
|
||||
port = new_port,
|
||||
protocol = "dokodemo-door",
|
||||
settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)}
|
||||
})
|
||||
if _node.tls_serverName == nil then
|
||||
_node.tls_serverName = _node.address
|
||||
end
|
||||
_node.address = "127.0.0.1"
|
||||
_node.port = new_port
|
||||
table.insert(rules, 1, {
|
||||
type = "field",
|
||||
inboundTag = {"proxy_" .. name},
|
||||
outboundTag = "default"
|
||||
})
|
||||
end
|
||||
end
|
||||
local _outbound = gen_outbound(_node, name, is_proxy, (is_proxy == "1" and "default" or nil))
|
||||
if _outbound then
|
||||
table.insert(outbounds, _outbound)
|
||||
outboundTag = name
|
||||
end
|
||||
@ -451,10 +468,6 @@ if dns_server then
|
||||
network = "udp"
|
||||
}
|
||||
})
|
||||
table.insert(outbounds, {
|
||||
protocol = "dns",
|
||||
tag = "dns-out"
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(rules, {
|
||||
@ -465,8 +478,9 @@ if dns_server then
|
||||
outboundTag = "dns-out"
|
||||
})
|
||||
|
||||
local outboundTag = "direct"
|
||||
if doh_socks_address and doh_socks_port then
|
||||
table.insert(outbounds, {
|
||||
table.insert(outbounds, 1, {
|
||||
tag = "out",
|
||||
protocol = "socks",
|
||||
streamSettings = {
|
||||
@ -482,22 +496,15 @@ if dns_server then
|
||||
}
|
||||
}
|
||||
})
|
||||
table.insert(rules, {
|
||||
type = "field",
|
||||
inboundTag = {
|
||||
"dns-in1"
|
||||
},
|
||||
outboundTag = "out"
|
||||
})
|
||||
else
|
||||
table.insert(rules, {
|
||||
type = "field",
|
||||
inboundTag = {
|
||||
"dns-in1"
|
||||
},
|
||||
outboundTag = "direct"
|
||||
})
|
||||
outboundTag = "out"
|
||||
end
|
||||
table.insert(rules, {
|
||||
type = "field",
|
||||
inboundTag = {
|
||||
"dns-in1"
|
||||
},
|
||||
outboundTag = outboundTag
|
||||
})
|
||||
|
||||
routing = {
|
||||
domainStrategy = "IPOnDemand",
|
||||
@ -522,6 +529,10 @@ if inbounds or outbounds then
|
||||
protocol = "blackhole",
|
||||
tag = "blackhole"
|
||||
})
|
||||
table.insert(outbounds, {
|
||||
protocol = "dns",
|
||||
tag = "dns-out"
|
||||
})
|
||||
|
||||
local xray = {
|
||||
log = {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set dhcp.@dnsmasq[0].localuse=1
|
||||
commit dhcp
|
||||
delete ucitrack.@passwall[-1]
|
||||
add ucitrack passwall
|
||||
set ucitrack.@passwall[-1].init=passwall
|
||||
@ -25,9 +27,5 @@ uci -q batch <<-EOF >/dev/null
|
||||
commit uhttpd
|
||||
EOF
|
||||
|
||||
tmp=$(uci -q get passwall.@global_app[0].xray_file)
|
||||
[ -z "$tmp" ] && uci set passwall.@global_app[0].xray_file="/usr/bin/xray"
|
||||
uci commit passwall
|
||||
|
||||
rm -rf /tmp/luci-*cache
|
||||
exit 0
|
||||
|
||||
@ -801,6 +801,7 @@ start_dns() {
|
||||
nonuse)
|
||||
echolog " - 不过滤DNS..."
|
||||
TUN_DNS=""
|
||||
return
|
||||
;;
|
||||
dns2socks)
|
||||
local dns2socks_socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:9050) | sed "s/#/:/g")
|
||||
@ -1033,7 +1034,7 @@ add_dnsmasq() {
|
||||
echo "conf-dir=${TMP_DNSMASQ_PATH}" > "/var/dnsmasq.d/dnsmasq-${CONFIG}.conf"
|
||||
|
||||
if [ -z "${CHINADNS_NG}" ] && [ "${IS_DEFAULT_DNS}" = "1" ]; then
|
||||
echolog " - 不强制设置默认DNS"
|
||||
#echolog " - 不强制设置默认DNS"
|
||||
return
|
||||
else
|
||||
echo "${DEFAULT_DNS}" > $TMP_PATH/default_DNS
|
||||
@ -1112,6 +1113,7 @@ gen_pdnsd_config() {
|
||||
purge_cache = off;
|
||||
proxy_only = on;
|
||||
caching = $_cache;
|
||||
reject=::/0;
|
||||
}
|
||||
EOF
|
||||
echolog " | - [$?]上游DNS:${2}:${3}"
|
||||
|
||||
@ -94,6 +94,7 @@ int mtdsize = 0;
|
||||
int erasesize = 0;
|
||||
int jffs2_skip_bytes=0;
|
||||
int mtdtype = 0;
|
||||
uint32_t opt_trxmagic = TRX_MAGIC;
|
||||
|
||||
int mtd_open(const char *mtd, bool block)
|
||||
{
|
||||
@ -205,7 +206,7 @@ image_check(int imagefd, const char *mtd)
|
||||
|
||||
magic = ((uint32_t *)buf)[0];
|
||||
|
||||
if (be32_to_cpu(magic) == TRX_MAGIC)
|
||||
if (be32_to_cpu(magic) == opt_trxmagic)
|
||||
imageformat = MTD_IMAGE_FORMAT_TRX;
|
||||
else if (be32_to_cpu(magic) == SEAMA_MAGIC)
|
||||
imageformat = MTD_IMAGE_FORMAT_SEAMA;
|
||||
@ -810,6 +811,7 @@ static void usage(void)
|
||||
" -l <length> the length of data that we want to dump\n");
|
||||
if (mtd_fixtrx) {
|
||||
fprintf(stderr,
|
||||
" -M <magic> magic number of the image header in the partition (for fixtrx)\n"
|
||||
" -o offset offset of the image header in the partition(for fixtrx)\n");
|
||||
}
|
||||
if (mtd_fixtrx || mtd_fixseama || mtd_fixwrg || mtd_fixwrgg) {
|
||||
@ -877,7 +879,7 @@ int main (int argc, char **argv)
|
||||
#ifdef FIS_SUPPORT
|
||||
"F:"
|
||||
#endif
|
||||
"frnqe:d:s:j:p:o:c:t:l:")) != -1)
|
||||
"frnqe:d:s:j:p:o:c:t:l:M:")) != -1)
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
force = 1;
|
||||
@ -929,6 +931,14 @@ int main (int argc, char **argv)
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
errno = 0;
|
||||
opt_trxmagic = strtoul(optarg, 0, 0);
|
||||
if (errno) {
|
||||
fprintf(stderr, "-M: illegal numeric string\n");
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
errno = 0;
|
||||
offset = strtoul(optarg, 0, 0);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define __mtd_h
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(target_bcm47xx) || defined(target_bcm53xx)
|
||||
#define target_brcm 1
|
||||
@ -12,6 +13,7 @@
|
||||
extern int quiet;
|
||||
extern int mtdsize;
|
||||
extern int erasesize;
|
||||
extern uint32_t opt_trxmagic;
|
||||
|
||||
extern int mtd_open(const char *mtd, bool block);
|
||||
extern int mtd_check_open(const char *mtd);
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
#include "mtd.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#define TRX_MAGIC 0x30524448 /* "HDR0" */
|
||||
#define TRX_CRC32_DATA_OFFSET 12 /* First 12 bytes are not covered by CRC32 */
|
||||
#define TRX_CRC32_DATA_SIZE 16
|
||||
struct trx_header {
|
||||
@ -92,7 +91,7 @@ trx_fixup(int fd, const char *name)
|
||||
}
|
||||
|
||||
trx = ptr;
|
||||
if (trx->magic != TRX_MAGIC) {
|
||||
if (ntohl(trx->magic) != opt_trxmagic) {
|
||||
fprintf(stderr, "TRX header not found\n");
|
||||
goto err;
|
||||
}
|
||||
@ -127,7 +126,8 @@ trx_check(int imagefd, const char *mtd, char *buf, int *len)
|
||||
}
|
||||
}
|
||||
|
||||
if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) {
|
||||
if (ntohl(trx->magic) != opt_trxmagic ||
|
||||
trx->len < sizeof(struct trx_header)) {
|
||||
if (quiet < 2) {
|
||||
fprintf(stderr, "Bad trx header\n");
|
||||
fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
|
||||
@ -200,7 +200,7 @@ mtd_fixtrx(const char *mtd, size_t offset, size_t data_size)
|
||||
}
|
||||
|
||||
trx = (struct trx_header *)(first_block + offset);
|
||||
if (trx->magic != STORE32_LE(0x30524448)) {
|
||||
if (ntohl(trx->magic) != opt_trxmagic) {
|
||||
fprintf(stderr, "No trx magic found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=selinux-policy
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://git.defensec.nl/selinux-policy.git
|
||||
PKG_VERSION:=0.7
|
||||
PKG_MIRROR_HASH:=f9c555dfa2bb16e6bfd86f1481aad26fce72e5aa45e297e1b39636b6dd0ce021
|
||||
PKG_VERSION:=0.8
|
||||
PKG_MIRROR_HASH:=3b58f751a21394e3aef47fd6c9fe9430fadde6427deb5c79f08478904837ec91
|
||||
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
|
||||
PKG_BUILD_DEPENDS:=secilc/host policycoreutils/host
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@ version=1.0
|
||||
FIND="$(command -v find)"
|
||||
FIND="${FIND:-$(command -v gfind)}"
|
||||
TAR="${TAR:-$(command -v tar)}"
|
||||
GZIP="$(command -v gzip)"
|
||||
|
||||
# try to use fixed source epoch
|
||||
if [ -n "$PKG_SOURCE_DATE_EPOCH" ]; then
|
||||
@ -31,40 +30,40 @@ ipkg_extract_value() {
|
||||
required_field() {
|
||||
field=$1
|
||||
|
||||
grep "^$field:" < $CONTROL/control | ipkg_extract_value
|
||||
grep "^$field:" < "$CONTROL/control" | ipkg_extract_value
|
||||
}
|
||||
|
||||
pkg_appears_sane() {
|
||||
local pkg_dir=$1
|
||||
local pkg_dir="$1"
|
||||
|
||||
local owd=$PWD
|
||||
cd $pkg_dir
|
||||
local owd="$PWD"
|
||||
cd "$pkg_dir"
|
||||
|
||||
PKG_ERROR=0
|
||||
pkg=`required_field Package`
|
||||
version=`required_field Version | sed 's/Version://; s/^.://g;'`
|
||||
arch=`required_field Architecture`
|
||||
pkg="$(required_field Package)"
|
||||
version="$(required_field Version | sed 's/Version://; s/^.://g;')"
|
||||
arch="$(required_field Architecture)"
|
||||
|
||||
if echo $pkg | grep '[^a-zA-Z0-9_.+-]'; then
|
||||
if echo "$pkg" | grep '[^a-zA-Z0-9_.+-]'; then
|
||||
echo "*** Error: Package name $name contains illegal characters, (other than [a-z0-9.+-])" >&2
|
||||
PKG_ERROR=1;
|
||||
fi
|
||||
|
||||
if [ -f $CONTROL/conffiles ]; then
|
||||
rm -f $CONTROL/conffiles.resolved
|
||||
if [ -f "$CONTROL/conffiles" ]; then
|
||||
rm -f "$CONTROL/conffiles.resolved"
|
||||
|
||||
for cf in `$FIND $(sed -e "s!^/!$pkg_dir/!" $CONTROL/conffiles) -type f`; do
|
||||
echo "${cf#$pkg_dir}" >> $CONTROL/conffiles.resolved
|
||||
for cf in $($FIND $(sed -e "s!^/!$pkg_dir/!" "$CONTROL/conffiles") -type f); do
|
||||
echo "${cf#$pkg_dir}" >> "$CONTROL/conffiles.resolved"
|
||||
done
|
||||
|
||||
rm $CONTROL/conffiles
|
||||
if [ -f $CONTROL/conffiles.resolved ]; then
|
||||
mv $CONTROL/conffiles.resolved $CONTROL/conffiles
|
||||
chmod 0644 $CONTROL/conffiles
|
||||
rm "$CONTROL"/conffiles
|
||||
if [ -f "$CONTROL"/conffiles.resolved ]; then
|
||||
mv "$CONTROL"/conffiles.resolved "$CONTROL"/conffiles
|
||||
chmod 0644 "$CONTROL"/conffiles
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $owd
|
||||
cd "$owd"
|
||||
return $PKG_ERROR
|
||||
}
|
||||
|
||||
@ -95,17 +94,17 @@ file_modes=""
|
||||
usage="Usage: $0 [-v] [-h] [-m] <pkg_directory> [<destination_directory>]"
|
||||
while getopts "hvm:" opt; do
|
||||
case $opt in
|
||||
v ) echo $version
|
||||
v ) echo "$version"
|
||||
exit 0
|
||||
;;
|
||||
h ) echo $usage >&2 ;;
|
||||
h ) echo "$usage" >&2 ;;
|
||||
m ) file_modes=$OPTARG ;;
|
||||
\? ) echo $usage >&2
|
||||
\? ) echo "$usage" >&2
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
# continue on to process additional arguments
|
||||
|
||||
@ -115,42 +114,42 @@ case $# in
|
||||
;;
|
||||
2)
|
||||
dest_dir=$2
|
||||
if [ "$dest_dir" = "." -o "$dest_dir" = "./" ] ; then
|
||||
if [ "$dest_dir" = "." ] || [ "$dest_dir" = "./" ] ; then
|
||||
dest_dir=$PWD
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $usage >&2
|
||||
echo "$usage" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
pkg_dir=$1
|
||||
pkg_dir="$(realpath "$1")"
|
||||
|
||||
if [ ! -d $pkg_dir ]; then
|
||||
if [ ! -d "$pkg_dir" ]; then
|
||||
echo "*** Error: Directory $pkg_dir does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# CONTROL is second so that it takes precedence
|
||||
CONTROL=
|
||||
[ -d $pkg_dir/CONTROL ] && CONTROL=CONTROL
|
||||
[ -d "$pkg_dir"/CONTROL ] && CONTROL=CONTROL
|
||||
if [ -z "$CONTROL" ]; then
|
||||
echo "*** Error: Directory $pkg_dir has no CONTROL subdirectory." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! pkg_appears_sane $pkg_dir; then
|
||||
if ! pkg_appears_sane "$pkg_dir"; then
|
||||
echo >&2
|
||||
echo "ipkg-build: Please fix the above errors and try again." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmp_dir=$dest_dir/IPKG_BUILD.$$
|
||||
mkdir $tmp_dir
|
||||
mkdir "$tmp_dir"
|
||||
|
||||
echo $CONTROL > $tmp_dir/tarX
|
||||
cd $pkg_dir
|
||||
echo $CONTROL > "$tmp_dir"/tarX
|
||||
cd "$pkg_dir"
|
||||
for file_mode in $file_modes; do
|
||||
case $file_mode in
|
||||
/*:*:*:*)
|
||||
@ -179,22 +178,22 @@ for file_mode in $file_modes; do
|
||||
chown "$uid:$gid" "$pkg_dir/$path"
|
||||
chmod "$mode" "$pkg_dir/$path"
|
||||
done
|
||||
$TAR -X $tmp_dir/tarX --format=gnu --sort=name -cpf - --mtime="$TIMESTAMP" . | $GZIP -n - > $tmp_dir/data.tar.gz
|
||||
$TAR -X "$tmp_dir"/tarX --format=gnu --sort=name -cpf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/data.tar.gz
|
||||
|
||||
installed_size=`stat -c "%s" $tmp_dir/data.tar.gz`
|
||||
installed_size=$(stat -c "%s" "$tmp_dir"/data.tar.gz)
|
||||
sed -i -e "s/^Installed-Size: .*/Installed-Size: $installed_size/" \
|
||||
$pkg_dir/$CONTROL/control
|
||||
"$pkg_dir"/$CONTROL/control
|
||||
|
||||
( cd $pkg_dir/$CONTROL && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" . | $GZIP -n - > $tmp_dir/control.tar.gz )
|
||||
rm $tmp_dir/tarX
|
||||
( cd "$pkg_dir"/$CONTROL && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" . | gzip -n - > "$tmp_dir"/control.tar.gz )
|
||||
rm "$tmp_dir"/tarX
|
||||
|
||||
echo "2.0" > $tmp_dir/debian-binary
|
||||
echo "2.0" > "$tmp_dir"/debian-binary
|
||||
|
||||
pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk
|
||||
rm -f $pkg_file
|
||||
( cd $tmp_dir && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" ./debian-binary ./data.tar.gz ./control.tar.gz | $GZIP -n - > $pkg_file )
|
||||
rm -f "$pkg_file"
|
||||
( cd "$tmp_dir" && $TAR --format=gnu --sort=name -cf - --mtime="$TIMESTAMP" ./debian-binary ./data.tar.gz ./control.tar.gz | gzip -n - > "$pkg_file" )
|
||||
|
||||
rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
|
||||
rmdir $tmp_dir
|
||||
rm "$tmp_dir"/debian-binary "$tmp_dir"/data.tar.gz "$tmp_dir"/control.tar.gz
|
||||
rmdir "$tmp_dir"
|
||||
|
||||
echo "Packaged contents of $pkg_dir into $pkg_file"
|
||||
|
||||
@ -53,6 +53,7 @@ Print manifest:
|
||||
|
||||
make manifest PROFILE="<profilename>" # override the default target profile
|
||||
make manifest PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
|
||||
make manifest STRIP_ABI=1 # remove ABI version from printed package names
|
||||
|
||||
endef
|
||||
$(eval $(call shexport,Helptext))
|
||||
@ -125,7 +126,7 @@ _call_manifest: FORCE
|
||||
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
|
||||
$(MAKE) package_reload >/dev/null
|
||||
$(MAKE) package_install >/dev/null
|
||||
$(OPKG) list-installed
|
||||
$(OPKG) list-installed $(if $(STRIP_ABI),--strip-abi)
|
||||
|
||||
package_index: FORCE
|
||||
@echo >&2
|
||||
|
||||
@ -287,7 +287,6 @@ static int otrx_create_write_hdr(FILE *trx, struct trx_header *hdr) {
|
||||
uint8_t buf[1024];
|
||||
uint32_t crc32;
|
||||
|
||||
hdr->magic = cpu_to_le32(TRX_MAGIC);
|
||||
hdr->version = 1;
|
||||
|
||||
fseek(trx, 0, SEEK_SET);
|
||||
@ -324,9 +323,13 @@ static int otrx_create(int argc, char **argv) {
|
||||
ssize_t sbytes;
|
||||
size_t curr_idx = 0;
|
||||
size_t curr_offset = sizeof(hdr);
|
||||
char *e;
|
||||
uint32_t magic;
|
||||
int c;
|
||||
int err = 0;
|
||||
|
||||
hdr.magic = cpu_to_le32(TRX_MAGIC);
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "No TRX file passed\n");
|
||||
err = -EINVAL;
|
||||
@ -343,7 +346,7 @@ static int otrx_create(int argc, char **argv) {
|
||||
fseek(trx, curr_offset, SEEK_SET);
|
||||
|
||||
optind = 3;
|
||||
while ((c = getopt(argc, argv, "f:A:a:b:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "f:A:a:b:M:")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
if (curr_idx >= TRX_MAX_PARTS) {
|
||||
@ -400,6 +403,14 @@ static int otrx_create(int argc, char **argv) {
|
||||
curr_offset += sbytes;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
errno = 0;
|
||||
magic = strtoul(optarg, &e, 0);
|
||||
if (errno || (e == optarg) || *e)
|
||||
fprintf(stderr, "illegal magic string %s\n", optarg);
|
||||
else
|
||||
hdr.magic = cpu_to_le32(magic);
|
||||
break;
|
||||
}
|
||||
if (err)
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user