diff --git a/luci-app-serverchan/Makefile b/luci-app-serverchan/Makefile index e8bba3ba1..48900cc88 100644 --- a/luci-app-serverchan/Makefile +++ b/luci-app-serverchan/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-serverchan -PKG_VERSION:=2.03.00 +PKG_VERSION:=2.03.01 PKG_RELEASE:=10 PKG_MAINTAINER:=tty228 diff --git a/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua b/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua index 662bcdef7..3a7a186fc 100644 --- a/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua +++ b/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua @@ -27,6 +27,7 @@ a.description = translate("若无二级路由设备,信号强度良好,可 a = s:option(Value, "thread_num", translate('最大并发进程数')) a.default = "3" a.datatype = "uinteger" +a.description = translate("低性能设备请勿更改设置值,或酌情减少参数") a = s:option(Value, "soc_code", "自定义温度读取命令") a.rmempty = true diff --git a/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua b/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua index e11d44932..f65afcc27 100644 --- a/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua +++ b/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua @@ -129,7 +129,7 @@ a.rmempty = true a.optional = false a.default = "60" a.datatype = "and(uinteger,min(10))" -a.description = translate("越短的时间时间响应越及时,但会占用更多的系统资源") +a.description = translate("越短的时间响应越及时,但会占用更多的系统资源") a = s:taboption("basic", ListValue, "oui_data", translate("MAC设备信息数据库")) a.rmempty = true diff --git a/luci-app-serverchan/root/usr/share/serverchan/api/ipv4.list b/luci-app-serverchan/root/usr/share/serverchan/api/ipv4.list index 20b7d8875..5c19d8ae1 100644 --- a/luci-app-serverchan/root/usr/share/serverchan/api/ipv4.list +++ b/luci-app-serverchan/root/usr/share/serverchan/api/ipv4.list @@ -1,9 +1,9 @@ -www.cip.cc -ifcfg.cn -ddns.oray.com/checkip -www.net.cn/static/customercare/yourip.asp -myip.ipip.net/s -speed.neu.edu.cn/getIP.php -www.uc.cn/ip -ifcfg.cn -ip.3322.net +cip.cc +ddns.oray.com/checkip +www.net.cn/static/customercare/yourip.asp +myip.ipip.net/s +ip.3322.net +ip.cn +ip.threep.top +10086.cn/web-Center/commonservice/getUserIp.do --referer http://10086.cn -XPOST +https://www.taobao.com/help/getip.php -H 'authority: www.taobao.com' \ No newline at end of file diff --git a/luci-app-serverchan/root/usr/share/serverchan/api/ipv6.list b/luci-app-serverchan/root/usr/share/serverchan/api/ipv6.list index e8b6d6b1e..70cf0b0c0 100644 --- a/luci-app-serverchan/root/usr/share/serverchan/api/ipv6.list +++ b/luci-app-serverchan/root/usr/share/serverchan/api/ipv6.list @@ -1,5 +1,5 @@ -ip.sb -ipv6.ddnspod.com -api-ipv6.ip.sb/ip -speed.neu6.edu.cn/getIP.php -v6.myip.la/json +ipv6.ddnspod.com +speed.neu6.edu.cn/getIP.php +6.ipw.cn +10086.cn/web-Center/commonservice/getUserIp.do --referer http://10086.cn -XPOST +https://www.taobao.com/help/getip.php -H 'authority: www.taobao.com' \ No newline at end of file diff --git a/luci-app-serverchan/root/usr/share/serverchan/serverchan b/luci-app-serverchan/root/usr/share/serverchan/serverchan index 4af710bde..b7c4587fa 100755 --- a/luci-app-serverchan/root/usr/share/serverchan/serverchan +++ b/luci-app-serverchan/root/usr/share/serverchan/serverchan @@ -139,13 +139,16 @@ function getip(){ function get_hostipv4() { local url_number=`echo "$ipv4_urllist"|wc -l` - local ipv4_URL=`echo "$ipv4_urllist"| sed -n "$(rand 1 $url_number)p"|sed -e 's/\r//g'` + [ -z $rand_number ] && local rand_number=`rand 1 $url_number` || rand_number=`expr $rand_number + 1` && [ $rand_number -gt $url_number ] && rand_number=1 + local ipv4_URL=`echo "$ipv4_urllist"| sed -n "${rand_number}p"|sed -e 's/\r//g'` [ ! -z "$ipv4_interface" ] && local hostIP=$(curl -k -s -4 --interface ${ipv4_interface} -m 5 ${ipv4_URL}) || local hostIP=$(curl -k -s -4 -m 5 ${ipv4_URL}) - echo $hostIP|grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'|head -n1 + [ -z "$hostIP" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】IP 获取失败,当前使用的 API 为 $ipv4_URL" >> ${logfile} + echo "`echo $hostIP|grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'|head -n1` $ipv4_URL" } local hostIP=`get_hostipv4` - [ -z "$hostIP" ] && sleep 1 && local hostIP=`get_hostipv4` - [ -z "$hostIP" ] && sleep 1 && local hostIP=`get_hostipv4` + [ `echo $hostIP|awk '{print NF}'` -ne "2" ] && sleep 10 && local hostIP=`get_hostipv4` + [ `echo $hostIP|awk '{print NF}'` -ne "2" ] && sleep 10 && local hostIP=`get_hostipv4` + [ `echo $hostIP|awk '{print NF}'` -ne "2" ] && wget --no-check-certificate -t 3 -T 15 -O /usr/share/serverchan/api/ipv4.list https://raw.githubusercontent.com/tty228/luci-app-serverchan/master/root/usr/share/serverchan/api/ipv4.list >/dev/null 2>&1 && echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】多次获取 IP 失败,重新同步 API 列表" >> ${logfile} echo $hostIP # 重试,偷懒,有空再优化 elif [ $1 == "wanipv6" ] ;then [ ! -z "$ipv6_interface" ] && local wanIPv6=$(ip addr show ${ipv6_interface}|grep -v deprecated|grep -A1 'inet6 [^f:]'|sed -nr ':a;N;s#^ +inet6 ([a-f0-9:]+)/.+? scope global .*? valid_lft ([0-9]+sec) .*#\2 \1#p;ta'|sort -nr|head -n1|awk '{print $2}') @@ -155,13 +158,16 @@ function getip(){ function get_hostipv6() { local urlv6_number=`echo "$ipv6_urllist"|wc -l` - local ipv6_URL=`echo "$ipv6_urllist"| sed -n "$(rand 1 $urlv6_number)p"|sed -e 's/\r//g'` + [ -z $rand_numberv6 ] && local rand_numberv6=`rand 1 $urlv6_number` || rand_numberv6=`expr $rand_numberv6 + 1` && [ $rand_numberv6 -gt $urlv6_number ] && rand_numberv6=1 + local ipv6_URL=`echo "$ipv6_urllist"| sed -n "${rand_numberv6}p"|sed -e 's/\r//g'` [ ! -z "$ipv6_interface" ] && local hostIPv6=$(curl -k -s -6 --interface ${ipv6_interface} -m 5 ${ipv6_URL}) || local hostIPv6=$(curl -k -s -6 -m 5 ${ipv6_URL}) - echo $hostIPv6|grep -oE '([\da-fA-F0-9]{1,4}(:{1,2})){1,15}[\da-fA-F0-9]{1,4}'|head -n1 + [ -z "$hostIPv6" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】IPv6 获取失败,当前使用的 API 为 $ipv6_URL" >> ${logfile} + echo "`echo $hostIPv6|grep -oE '([\da-fA-F0-9]{1,4}(:{1,2})){1,15}[\da-fA-F0-9]{1,4}'|head -n1` $ipv6_URL" } local hostIPv6=`get_hostipv6` - [ -z "$hostIPv6" ] && sleep 1 && local hostIPv6=`get_hostipv6` - [ -z "$hostIPv6" ] && sleep 1 && local hostIPv6=`get_hostipv6` + [ `echo $hostIPv6|awk '{print NF}'` -ne "2" ] && sleep 10 && local hostIPv6=`get_hostipv6` + [ `echo $hostIPv6|awk '{print NF}'` -ne "2" ] && sleep 10 && local hostIPv6=`get_hostipv6` + [ `echo $hostIPv6|awk '{print NF}'` -ne "2" ] && wget --no-check-certificate -t 3 -T 15 -O /usr/share/serverchan/api/ipv6.list https://raw.githubusercontent.com/tty228/luci-app-serverchan/master/root/usr/share/serverchan/api/ipv6.list >/dev/null 2>&1 && echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】多次获取 IP 失败,重新同步 API 列表" >> ${logfile} echo $hostIPv6 # 重试,偷懒,有空再优化 fi } @@ -393,7 +399,7 @@ function cut_str { temp_length=`expr $temp_length + 1` done temp_length=`expr $temp_length - 1` - echo $(echo "$1"|cut -c -$temp_length)"*" + echo $(echo "$1"|cut -c -$temp_length)"..." } # 随机数 @@ -572,16 +578,16 @@ function unattended(){ if [ ! -z "$public_ip_event" ] && [ ! -z "$public_ip_retry_count" ] && [ "$public_ip_count" -le "$public_ip_retry_count" ]; then public_ip_count=`expr $public_ip_count + 1` local wanIP=`getip wanipv4` - local hostIP=`getip hostipv4` + local hostIP=`getip hostipv4|awk '{print $1}'` if [ ! -z "$wanIP" ] && [ ! -z "$hostIP" ] && ( ! echo "$wanIP"|grep -q -w ${hostIP} );then echo "`date "+%Y-%m-%d %H:%M:%S"` 【无人值守任务】重拨尝试获取公网 ip,当前第 $public_ip_count 次 " >> ${logfile} ifup wan >/dev/null 2>&1 sleep 60 - local wanIP=`getip wanipv4` && local hostIP=`getip hostipv4` + local wanIP=`getip wanipv4` && local hostIP=`getip hostipv4|awk '{print $1}'` [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -eq "1" ] && local IPv4=${wanIP} [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -eq "2" ] && local IPv4=${hostIP} [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "1" ] && local IPv6=`getip wanipv6` - [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "2" ] && local IPv6=`getip hostipv6` + [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "2" ] && local IPv6=`getip hostipv6|awk '{print $1}'` [ ! -z "$wanIP" ] && [ ! -z "$hostIP" ] && ( ! echo "$wanIP"|grep -q -w ${hostIP} ) && echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}ip fi fi @@ -593,12 +599,12 @@ function rand_geturl(){ local urllist="https://www.163.com https://www.qq.com https://www.baidu.com https://www.qidian.com https://www.douban.com" local url_number=`expr $(echo "$urllist"|grep -o ' '|wc -l) + 1` local url_str=`echo "$urllist"|awk -v i=$(rand 1 $url_number) '{print $i}'` - echo `curl -k -s -w "%{http_code}" -m 5 ${url_str} -A "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" -o /dev/null` + echo `curl -k -s -w "%{http_code}" -m 5 ${url_str} -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.58" -o /dev/null` } local check=`getcheck` - while [ -z "$check" ] || [ "$check" -ne "200" ]; do + while [ -z "$check" ] || [[ $check -ne 200 && $check -ne 301 && $check -ne 302 ]]; do local check=`getcheck` - if [ ! -z "$check" ] && [ "$check" -eq "200" ]; then + if [ ! -z "$check" ] && [[ $check -eq 200 || $check -eq 301 || $check -eq 302 ]]; then [ ! -z "$network_enable" ] && [ "$network_enable" -eq "404" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【网络状态】网络恢复正常.." >> ${logfile} local network_enable="200" else @@ -686,9 +692,9 @@ function rand_geturl(){ # 检测 ip 状况 function ip_changes(){ [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -eq "1" ] && local IPv4=`getip wanipv4` - [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -eq "2" ] && local IPv4=`getip hostipv4` + [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -eq "2" ] && local IPv4=`getip hostipv4|awk '{print $1}'` [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "1" ] && local IPv6=`getip wanipv6` - [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "2" ] && local IPv6=`getip hostipv6` + [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -eq "2" ] && local IPv6=`getip hostipv6|awk '{print $1}'` if [ -f ${dir}ip ]; then local last_IPv4=$(cat "${dir}ip"|grep IPv4|awk '{print $2}'|grep -v "^$"|sort -u|head -n1) @@ -698,8 +704,7 @@ function ip_changes(){ echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}ip title="IP 地址变化" content="${content}${str_splitline}${str_title_start} IP 地址变化${str_title_end}${str_linefeed}${str_tab}当前 IP:${IPv4}" - elif [ ! -z "$serverchan_ipv4" ] && [ "$serverchan_ipv4" -ne "0" ] && [ -z "$IPv4" ]; then - echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv4 地址失败" >> ${logfile} + echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】当前 IP 获取来源为 `getip hostipv4|awk '{print $2}'`" >> ${logfile} fi if [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -ne "0" ] && [ ! -z "$IPv6" ] && ( ! echo "$IPv6"|grep -w -q ${last_IPv6} ); then @@ -708,8 +713,7 @@ function ip_changes(){ [ -z "$title" ] && title="IPv6 地址变化" [ ! -z "$title" ] && title="IP 地址变化" content="${content}${str_splitline}${str_title_start} IPv6 地址变化${str_title_end}${str_linefeed}${str_tab}当前 IPv6:${IPv6}" - elif [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -ne "0" ] && [ -z "$IPv6" ]; then - echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv6 地址失败" >> ${logfile} + echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】当前 IPv6 获取来源为 `getip hostipv6|awk '{print $2}'`" >> ${logfile} fi else @@ -804,7 +808,8 @@ function down(){ LockFile unlock else local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1` - if [ ${ip_name} != ${tmp_name} ]; then + local tmp_mac=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` + if [ ${ip_name} != ${tmp_name} ] || [ ${ip_mac} != ${tmp_mac} ]; 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|head -n1` ${ip_interface}") sed -i "/^${1} /d" ${dir}ipAddress @@ -1076,7 +1081,7 @@ function add_ip_black(){ [ ! -f "${ip_blacklist_path}" ] && touch ${ip_blacklist_path} local logrow=$(grep -c "" ${ip_blacklist_path}) [ ! -z "$web_login_black" ] && [ "$web_login_black" -eq "0" ] || [ -z "$web_login_black" ] && logrow=0 - [ ! -z "$1" ] && logrow=logrow+1 + [ ! -z "$1" ] && logrow=`expr $logrow + 1` ipset flush ip_blacklist >/dev/null 2>&1 if [ $logrow -le "0" ]; then @@ -1111,7 +1116,7 @@ function send(){ local cpuload=`getcpu` local ramload=`free -m|sed -n '2p'|awk '{printf "%.2f%%\n",($3/$2)*100}'` local Qwai=`curl -o /dev/null --connect-timeout 5 -s -w %{http_code} www.google.com` - if [[ "$Qwai" -eq "200" ]] || [[ "$Qwai" -eq "301" ]] || [[ "$Qwai" -eq "302" ]]; then + if [[ $Qwai -eq 200 || $Qwai -eq 301 || $Qwai -eq 302 ]]; then local Qwai_status="已连通!" else local Qwai_status="已断开!" @@ -1132,11 +1137,11 @@ function send(){ fi if [ -z "$1" ] && [ ! -z "$router_wan" ] && [ "$router_wan" -eq "1" ]; then - local send_wanIP=`getip wanipv4`;local send_hostIP=`getip hostipv4` + local send_wanIP=`getip wanipv4`;local send_hostIP=`getip hostipv4|awk '{print $1}'` local send_content="${send_content}${str_splitline}${str_title_start} WAN 口信息${str_title_end}${str_linefeed}${str_tab}接口 IPv4:${send_wanIP}" local send_content="${send_content}${str_linefeed}${str_tab}外网 IPv4:${send_hostIP}" if [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -ne "0" ]; then - local send_wanIPv6=`getip wanipv6`;local send_hostIPv6=`getip hostipv6` + local send_wanIPv6=`getip wanipv6`;local send_hostIPv6=`getip hostipv6|awk '{print $1}'` local send_content="${send_content}${str_linefeed}${str_tab}接口 IPv6:${send_wanIPv6}" local send_content="${send_content}${str_linefeed}${str_tab}外网 IPv6:${send_hostIPv6}" fi diff --git a/luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/main.lua b/luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/main.lua index 4bf25a2dc..0405618cf 100644 --- a/luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/main.lua +++ b/luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/main.lua @@ -137,7 +137,7 @@ o.description = translate("非必要不推荐使用") o.default = 0 o = s:option(ListValue, "log_level", translate("日志等级")) -o:value("debug", translate("'调试")); +o:value("debug", translate("调试")); o:value("info", translate("信息(默认)")) o:value("silent", translate("静默")) o.default = "info"; diff --git a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/custom.js b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/custom.js index ed0b68a37..07ff99fa1 100644 --- a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/custom.js +++ b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/custom.js @@ -16,7 +16,7 @@ return view.extend({ E('h2', {'name': 'content'}, [ _('Usage - Custom User File') ]), E('div', {'class': 'cbi-map-descr'}, [ _('Each line must have the following format:'), - E('em', {}, E('font', {'color': 'red'}, '00:aa:bb:cc:ee:ff,hostname')) + E('em', {'style': 'color:red'}, '00:aa:bb:cc:ee:ff,hostname') ]), E('div', {'class': 'cbi-section'}, [ E('textarea', { @@ -32,13 +32,6 @@ return view.extend({ var map = document.querySelector('#custom_hosts'); return fs.write('/etc/wrtbwmon.user', map.value.trim().replace(/\r\n/g, '\n') + '\n'); }, - - addFooter: function() { - return E('div', { 'class': 'cbi-page-actions' }, [ - E('button', { - 'class': 'cbi-button cbi-button-save', - 'click': ui.createHandlerFn(this, 'handleSave') - }, [ _('Save') ]) - ]); - } + handleSaveApply: null, + handleReset: null }); diff --git a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/details.js b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/details.js index a9e398d13..a55e6cd67 100644 --- a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/details.js +++ b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/details.js @@ -10,6 +10,17 @@ var cachedData = []; var luciConfig = '/etc/luci-wrtbwmon.conf'; var hostNameFile = '/etc/wrtbwmon.user'; +var columns = { + thClient: _('Clients'), + thMAC: _('MAC'), + thDownload: _('Download'), + thUpload: _('Upload'), + thTotalDown: _('Total Down'), + thTotalUp: _('Total Up'), + thTotal: _('Total'), + thFirstSeen: _('First Seen'), + thLastSeen: _('Last Seen') +}; var callLuciDHCPLeases = rpc.declare({ object: 'luci-rpc', @@ -89,26 +100,9 @@ function clickToSelectProtocol(settings, table, updated, updating, ev) { updateData(settings, table, updated, updating, true); } -function clickToShowMore(settings, table, ev) { - var t = table.querySelector('.tr.table-totals'); - settings.showMore = ev.target.checked - - if (t && t.firstElementChild) - t.firstElementChild.textContent = _('TOTAL') + (settings.showMore ? '' : ': ' + (table.childElementCount - 2)); - - table.querySelectorAll('.showMore').forEach(function(e) { - e.classList.toggle('hide'); - }); - - if (!settings.showMore && table.querySelector('.th.sorted').classList.contains('hide')) { - table.querySelector('[id="thTotal"]').click(); - } -} - function createOption(args, val) { var cstr = args[0], title = args[1], desc = args.slice(-1), widget, frame; - val = val != null ? val : args[2]; - widget = args.length == 5 ? new cstr(val, args[3]) : new cstr(val, args[3], args[4]); + widget = args.length == 4 ? new cstr(val, args[2]) : new cstr(val, args[2], args[3]); frame = E('div', {'class': 'cbi-value'}, [ E('label', {'class': 'cbi-value-title'}, title), @@ -123,13 +117,12 @@ function createOption(args, val) { function displayTable(tb, settings) { var elm, elmID, col, sortedBy, flag, IPVer; - var thID = ['thClient', 'thMAC', 'thDownload', 'thUpload', 'thTotalDown', 'thTotalUp', 'thTotal', 'thFirstSeen', 'thLastSeen', '']; elm = tb.querySelector('.th.sorted'); elmID = elm ? elm.id : 'thTotal'; sortedBy = elm && elm.classList.contains('ascent') ? 'asc' : 'desc'; - col = thID.indexOf(elmID); + col = Object.keys(columns).indexOf(elmID); IPVer = col == 0 ? settings.protocol : null; flag = sortedBy == 'desc' ? 1 : -1; @@ -156,8 +149,8 @@ function formatSpeed(speed, useBits, useMultiple) { } function formatDate(d) { - var Y = d.getFullYear(), M = d.getMonth() + 1, D = d.getDate(); - var hh = d.getHours(), mm = d.getMinutes(), ss = d.getSeconds(); + var Y = d.getFullYear(), M = d.getMonth() + 1, D = d.getDate(), + hh = d.getHours(), mm = d.getMinutes(), ss = d.getSeconds(); return '%04d/%02d/%02d %02d:%02d:%02d'.format(Y, M, D, hh, mm, ss); } @@ -180,17 +173,17 @@ function handleConfig(ev) { var arglist, keylist = Object.keys(settings), res, cstrs = {}, node = [], body; arglist = [ - [ui.Select, _('Default Protocol'), 'ipv4', {'ipv4': _('ipv4'), 'ipv6': _('ipv6')}, {}, ''], - [ui.Select, _('Default Refresh Interval'), '5', {'-1': _('Disabled'), '2': _('2 seconds'), '5': _('5 seconds'), '10': _('10 seconds'), '30': _('30 seconds')}, {sort: ['-1', '2', '5', '10', '30']}, ''], - [ui.Checkbox, _('Default More Columns'), false, {value_enabled: true, value_disabled: false}, ''], - [ui.Checkbox, _('Show Zeros'), true, {value_enabled: true, value_disabled: false}, ''], - [ui.Checkbox, _('Transfer Speed in Bits'), false, {value_enabled: true, value_disabled: false}, ''], - [ui.Select, _('Multiple of Unit'), '1000', {'1000': _('SI - 1000'), '1024': _('IEC - 1024')}, {}, ''], - [ui.Checkbox, _('Use DSL Bandwidth'), false, {value_enabled: true, value_disabled: false}, ''], - [ui.Textfield, _('Upstream Bandwidth'), '100', {datatype: 'ufloat'}, 'Mbps'], - [ui.Textfield, _('Downstream Bandwidth'), '100', {datatype: 'ufloat'}, 'Mbps'], - [ui.DynamicList, _('Hide MAC Addresses'), [], '', {datatype: 'macaddr'}, ''] - ]; // [constructor, label, default_value(, all_values), options, description] + [ui.Select, _('Default Protocol'), {'ipv4': _('ipv4'), 'ipv6': _('ipv6')}, {}, ''], + [ui.Select, _('Default Refresh Interval'), {'-1': _('Disabled'), '2': _('2 seconds'), '5': _('5 seconds'), '10': _('10 seconds'), '30': _('30 seconds')}, {sort: ['-1', '2', '5', '10', '30']}, ''], + [ui.Dropdown, _('Default More Columns'), columns, {multiple: true, sort: false, custom_placeholder: '', dropdown_items: 3}, ''], + [ui.Checkbox, _('Show Zeros'), {value_enabled: true, value_disabled: false}, ''], + [ui.Checkbox, _('Transfer Speed in Bits'), {value_enabled: true, value_disabled: false}, ''], + [ui.Select, _('Multiple of Unit'), {'1000': _('SI - 1000'), '1024': _('IEC - 1024')}, {}, ''], + [ui.Checkbox, _('Use DSL Bandwidth'), {value_enabled: true, value_disabled: false}, ''], + [ui.Textfield, _('Upstream Bandwidth'), {datatype: 'ufloat'}, 'Mbps'], + [ui.Textfield, _('Downstream Bandwidth'), {datatype: 'ufloat'}, 'Mbps'], + [ui.DynamicList, _('Hide MAC Addresses'), '', {datatype: 'macaddr'}, ''] + ]; // [constructor, label(, all_choices), options, description] for (var i = 0; i < keylist.length; i++) { res = createOption(arglist[i], settings[keylist[i]]); @@ -229,59 +222,58 @@ function loadCss(path) { head.appendChild(link); } -function parseDatabase(values, hosts, showZero, hideMACs) { - var valArr = [], totals = [0, 0, 0, 0, 0], valToRows, row; +function parseDatabase(raw, hosts, showZero, hideMACs) { + var values = [], + totals = [0, 0, 0, 0, 0], + rows = raw.trim().split(/\r?\n|\r/g), + rowIndex = [1, 0, 3, 4, 5, 6, 7, 8, 9, 0]; - valToRows = values.replace(/(^\s*)|(\s*$)/g, '').split(/\r?\n|\r/g); - valToRows.shift(); + rows.shift(); - for (var i = 0; i < valToRows.length; i++) { - row = valToRows[i].split(','); + for (var i = 0; i < rows.length; i++) { + var row = rows[i].split(','); if ((!showZero && row[7] == 0) || hideMACs.indexOf(row[0]) >= 0) continue; for (var j = 0; j < totals.length; j++) { totals[j] += parseInt(row[3 + j]); } - row = Array.prototype.concat(row.slice(0, 2).reverse(), row.slice(3), row.slice(0, 1)); - if (row[1] in hosts && hosts[row[1]] != '-') { - row[9] = hosts[row[1]]; + var newRow = rowIndex.map(function(i) { return row[i] }); + if (newRow[1].toLowerCase() in hosts) { + newRow[9] = hosts[newRow[1].toLowerCase()]; } - valArr.push(row); + values.push(newRow); } - return [valArr, totals]; + return [values, totals]; } function parseDefaultSettings(file) { - var keylist = ['protocol', 'interval', 'showMore', 'showZero', 'useBits', 'useMultiple', 'useDSL', 'upstream', 'downstream', 'hideMACs']; - var valuelist = ['ipv4', '5', false, true, false, '1000', false, '100', '100', []]; - - return fs.read_direct(file).then(function(json) { - var settings; - try { - settings = JSON.parse(json); - } - catch(err) { - settings = {}; - } + var defaultColumns = ['thClient', 'thDownload', 'thUpload', 'thTotalDown', 'thTotalUp', 'thTotal'], + keylist = ['protocol', 'interval', 'showColumns', 'showZero', 'useBits', 'useMultiple', 'useDSL', 'upstream', 'downstream', 'hideMACs'], + valuelist = ['ipv4', '5', defaultColumns, true, false, '1000', false, '100', '100', []]; + return fs.read_direct(file, 'json').then(function(oldSettings) { + var settings = {}; for (var i = 0; i < keylist.length; i++) { - if (!(keylist[i] in settings)) + if (!(keylist[i] in oldSettings)) settings[keylist[i]] = valuelist[i]; + else + settings[keylist[i]] = oldSettings[keylist[i]]; } if (settings.useDSL) { return getDSLBandwidth().then(function(dsl) { - settings.upstream = dsl.upstream || settings.upstream; - settings.downstream = dsl.downstream || settings.downstream; + for (var s in dsl) + settings[s] = dsl[s]; return settings; }); } else { return settings; } - }); + }) + .catch(function() { return {} }); } function progressbar(query, v, m, useBits, useMultiple) { @@ -317,8 +309,11 @@ function setupThisDOM(settings, table) { displayTable(table, settings); }); - if (e.classList.contains('showMore')) - settings.showMore ? e.classList.remove('hide') : e.classList.add('hide'); + if (settings.showColumns.indexOf(e.id) >= 0) + e.classList.remove('hide'); + else + e.classList.add('hide'); + } }); } @@ -333,13 +328,13 @@ function renameFile(str, tag) { function resolveCustomizedHostName() { return fs.stat(hostNameFile).then(function() { return fs.read_direct(hostNameFile).then(function(raw) { - var hostNames = [], arr = raw.trim().split(/\r?\n/), row; + var arr = raw.trim().split(/\r?\n/), hosts = {}, row; for (var i = 0; i < arr.length; i++) { row = arr[i].split(','); if (row.length == 2 && row[0]) - hostNames.push({ macaddr: row[0], hostname: row[1] }); + hosts[row[0].toLowerCase()] = row[1]; } - return hostNames; + return hosts; }) }) .catch(function() { return []; }); @@ -350,23 +345,18 @@ function resolveHostNameByMACAddr() { resolveCustomizedHostName(), callLuciDHCPLeases() ]).then(function(res) { - var leaseNames, macaddr, hostNames = {}; - leaseNames = [ - res[0], - Array.isArray(res[1].dhcp_leases) ? res[1].dhcp_leases : [], - Array.isArray(res[1].dhcp6_leases) ? res[1].dhcp6_leases : [] - ]; - for (var i = 0; i < leaseNames.length; i++) { - for (var j = 0; j < leaseNames[i].length; j++) { - if (leaseNames[i][j].macaddr) { - macaddr = leaseNames[i][j].macaddr.toLowerCase(); - if (!(macaddr in hostNames) || hostNames[macaddr] == '-') { - hostNames[macaddr] = leaseNames[i][j].hostname || '-'; - } + var hosts = res[0]; + for (var key in res[1]) { + var leases = Array.isArray(res[1][key]) ? res[1][key] : []; + for (var i = 0; i < leases.length; i++) { + if(leases[i].macaddr) { + var macaddr = leases[i].macaddr.toLowerCase(); + if (!(macaddr in hosts) && Boolean(leases[i].hostname)) + hosts[macaddr] = leases[i].hostname; } } } - return hostNames; + return hosts; }); } @@ -413,7 +403,10 @@ function sortTable(col, IPVer, flag, x, y) { } function updateData(settings, table, updated, updating, once) { - if (!(poll.tick % settings.interval) || once) { + var tick = poll.tick, + interval = settings.interval, + sec = (interval - tick % interval) % interval; + if (!sec || once) { callGetDatabasePath() .then(function(res) { var params = settings.protocol == 'ipv4' ? '-4' : '-6'; @@ -433,17 +426,10 @@ function updateData(settings, table, updated, updating, once) { //console.timeEnd('start'); }); } - updatePerSec(updating, settings.interval); -} -function updatePerSec(e, interval) { - var tick = poll.tick; - var sec = tick % interval ? interval - tick % interval : 0; - - setUpdateMessage(e, sec); - if (sec == 0) { - setTimeout(setUpdateMessage.bind(this, e, interval), 100); - } + setUpdateMessage(updating, sec); + if (!sec) + setTimeout(setUpdateMessage.bind(this, updating, interval), 100); } function updateTable(tb, values, placeholder, settings) { @@ -460,10 +446,10 @@ function updateTable(tb, values, placeholder, settings) { newNode = fragment.firstChild.cloneNode(true); } else { - newNode = document.createElement('div'); - childTD = document.createElement('div'); + newNode = document.createElement('tr'); + childTD = document.createElement('td'); for (var j = 0; j < tbTitle.children.length; j++) { - childTD.className = 'td' + ('178'.indexOf(j) != -1 ? ' showMore' + (settings.showMore ? '' : ' hide') : ''); + childTD.className = 'td' + (settings.showColumns.indexOf(tbTitle.children[j].id) >= 0 ? '' : ' hide'); childTD.setAttribute('data-title', tbTitle.children[j].textContent); newNode.appendChild(childTD.cloneNode(true)); } @@ -502,9 +488,9 @@ function updateTable(tb, values, placeholder, settings) { //Append the totals or placeholder row. if (formData.length == 0) { - newNode = document.createElement('div'); + newNode = document.createElement('tr'); newNode.className = 'tr placeholder'; - childTD = document.createElement('div'); + childTD = document.createElement('td'); childTD.className = 'td'; childTD.innerHTML = placeholder; newNode.appendChild(childTD); @@ -513,7 +499,7 @@ function updateTable(tb, values, placeholder, settings) { newNode = fragment.firstChild.cloneNode(true); newNode.className = 'tr table-totals'; - newNode.children[0].textContent = _('TOTAL') + (settings.showMore ? '' : ': ' + formData.length); + newNode.children[0].textContent = _('TOTAL') + (settings.showColumns.indexOf('thMAC') >= 0 ? '' : ': ' + formData.length); newNode.children[1].textContent = formData.length + ' ' + _('Clients'); for (var j = 0; j < tbTitle.childElementCount; j++) { @@ -565,20 +551,20 @@ return view.extend({ var settings = data[0], labelUpdated = E('label'), labelUpdating = E('label'), - table = E('div', { 'class': 'table', 'id': 'traffic' }, [ - E('div', { 'class': 'tr table-titles' }, [ - E('div', { 'class': 'th', 'id': 'thClient' }, _('Clients')), - E('div', { 'class': 'th showMore hide', 'id': 'thMAC' }, _('MAC')), - E('div', { 'class': 'th', 'id': 'thDownload' }, _('Download')), - E('div', { 'class': 'th', 'id': 'thUpload' }, _('Upload')), - E('div', { 'class': 'th', 'id': 'thTotalDown' }, _('Total Down')), - E('div', { 'class': 'th', 'id': 'thTotalUp' }, _('Total Up')), - E('div', { 'class': 'th sorted', 'id': 'thTotal' }, _('Total')), - E('div', { 'class': 'th showMore hide', 'id': 'thFirstSeen' }, _('First Seen')), - E('div', { 'class': 'th showMore hide', 'id': 'thLastSeen' }, _('Last Seen')) + table = E('table', { 'class': 'table', 'id': 'traffic' }, [ + E('tr', { 'class': 'tr table-titles' }, [ + E('th', { 'class': 'th', 'id': 'thClient' }, _('Clients')), + E('th', { 'class': 'th hide', 'id': 'thMAC' }, _('MAC')), + E('th', { 'class': 'th', 'id': 'thDownload' }, _('Download')), + E('th', { 'class': 'th', 'id': 'thUpload' }, _('Upload')), + E('th', { 'class': 'th', 'id': 'thTotalDown' }, _('Total Down')), + E('th', { 'class': 'th', 'id': 'thTotalUp' }, _('Total Up')), + E('th', { 'class': 'th sorted', 'id': 'thTotal' }, _('Total')), + E('th', { 'class': 'th hide', 'id': 'thFirstSeen' }, _('First Seen')), + E('th', { 'class': 'th hide', 'id': 'thLastSeen' }, _('Last Seen')) ]), - E('div', {'class': 'tr placeholder'}, [ - E('div', { 'class': 'td' }, E('em', {}, _('Collecting data...'))) + E('tr', {'class': 'tr placeholder'}, [ + E('td', { 'class': 'td' }, E('em', {}, _('Collecting data...'))) ]) ]); @@ -598,15 +584,6 @@ return view.extend({ 'ipv6': 'ipv6' }, settings.protocol)) ]), - E('div', {}, [ - E('label', { 'for': 'showMore' }, _('Show More Columns:')), - E('input', { - 'id': 'showMore', - 'type': 'checkbox', - 'click': clickToShowMore.bind(this, settings, table), - 'checked': settings.showMore ? '' : null - }), - ]), E('div', {}, [ E('button', { 'class': 'btn cbi-button cbi-button-reset important', @@ -636,24 +613,24 @@ return view.extend({ }, settings.interval)) ]) ]), - E('div', { 'id': 'progressbar_panel', 'class': 'table' }, [ - E('div', { 'class': 'tr' }, [ - E('div', { 'class': 'td' }, E('div', {}, _('Downstream:'))), - E('div', { 'class': 'td' }, E('div', { + E('div', { 'id': 'progressbar_panel' }, [ + E('div', {}, [ + E('label', {}, _('Downstream:')), + E('div', { 'id': 'downstream', 'class': 'cbi-progressbar', 'title': '-' }, E('div') - )) + ) ]), - E('div', { 'class': 'tr' }, [ - E('div', { 'class': 'td' }, E('div', {}, _('Upstream:'))), - E('div', { 'class': 'td' }, E('div', { + E('div', {}, [ + E('label', {}, _('Upstream:')), + E('div', { 'id': 'upstream', 'class': 'cbi-progressbar', 'title': '-' }, E('div') - )) + ) ]), ]), table diff --git a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/wrtbwmon.css b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/wrtbwmon.css index f58feb4a4..a2eeaa878 100644 --- a/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/wrtbwmon.css +++ b/luci-app-wrtbwmon/htdocs/luci-static/resources/view/wrtbwmon/wrtbwmon.css @@ -13,27 +13,24 @@ padding: .5rem; line-height: 2rem; } -#control_panel > :nth-child(1), #control_panel > :nth-child(2) { +#control_panel > :nth-child(1) { display: inline-block; - flex: 1 1 25%; + flex: 1 1 50%; } -#control_panel > :nth-child(3) { +#control_panel > :nth-child(2) { flex: 1 1 50%; text-align: right; } #control_panel > * > * { vertical-align: middle; } -div > label { +#control_panel > div > label { margin-right: .5rem; } -div > label + select { +#control_panel > div > label + select { min-width: unset; width: auto; } -#control_panel input[type="checkbox"]{ - margin: 0 -} #control_panel + div { display: flex; margin-bottom: .5rem; @@ -60,14 +57,8 @@ div > label + select { #thFirstSeen, #thLastSeen { width: 15%; } -#progressbar_panel > .tr { - background: none; -} -#progressbar_panel > .tr > .td:nth-child(1) { - width: 10%; -} .tr.table-totals { - background: #e0e0e0 !important; + font-weight: bold; } #traffic .tr:not(.table-totals):not(.placeholder) > .td:not(.th):first-child::before { content: attr(title)'\a'; diff --git a/v2ray-geodata/Makefile b/v2ray-geodata/Makefile index f0520b0bc..fdf63a4f3 100644 --- a/v2ray-geodata/Makefile +++ b/v2ray-geodata/Makefile @@ -21,13 +21,13 @@ define Download/geoip HASH:=80087c87710e92ec9966553098c5f65eb636060fb821b0d92dd8119560de7d77 endef -GEOSITE_VER:=20230428052845 +GEOSITE_VER:=20230429042459 GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER) define Download/geosite URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/ URL_FILE:=dlc.dat FILE:=$(GEOSITE_FILE) - HASH:=69de742e7e279ad889adb4aafea678ff6c0032a4afdb9ba25bfe884f32922888 + HASH:=8a3a2c656e241f00cc438136a7486bf5db63cad006a810c0202741f2b08371b6 endef define Package/v2ray-geodata/template