diff --git a/autoinstall/autoinstall.sh b/autoinstall/autoinstall.sh index 0afb0ce..48b2850 100755 --- a/autoinstall/autoinstall.sh +++ b/autoinstall/autoinstall.sh @@ -8,9 +8,9 @@ LUA_MODULE=1 LUCI_APP=1 OWRT_VERSION="current" -RUAB_VERSION="0.9.4-0" -RUAB_MOD_LUA_VERSION="0.9.4-0" -RUAB_LUCI_APP_VERSION="0.9.4-0" +RUAB_VERSION="0.9.4-1" +RUAB_MOD_LUA_VERSION="0.9.4-1" +RUAB_LUCI_APP_VERSION="0.9.4-1" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" PKG_DIR="/tmp" diff --git a/luci-app-ruantiblock/Makefile b/luci-app-ruantiblock/Makefile index 8714490..d8b57da 100644 --- a/luci-app-ruantiblock/Makefile +++ b/luci-app-ruantiblock/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk -PKG_VERSION:=0.9.4-0 +PKG_VERSION:=0.9.4-1 LUCI_TITLE:=LuCI support for ruantiblock LUCI_DEPENDS:=+ruantiblock LUCI_PKGARCH:=all diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/info.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/info.js index 6a45372..1fd70c4 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/info.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/info.js @@ -6,6 +6,69 @@ 'require view.ruantiblock.tools as tools'; return view.extend({ + secToTimeString: function(value) { + let string = ''; + if(/^\d+$/.test(value)) { + value = Number(value); + let hours = 0, mins = 0, sec = 0, rest = value; + if(value >= 3600) { + hours = Math.floor(value / 3600); + rest = value % 3600; + }; + if(rest >= 60) { + mins = Math.floor(rest / 60); + rest = rest % 60; + }; + sec = rest; + if(hours > 0) { + string = string + hours + _('h'); + }; + if(mins > 0) { + string = string + ' ' + mins + _('m'); + }; + string = string + ' ' + sec + _('s'); + }; + return string; + }, + + makeDnsmasqTable: function(ipDataArray) { + let lines = `${_('No entries available...')}`; + let ipTable = E('table', { 'id': 'ipTable', 'class': 'table' }); + + if(ipDataArray.length > 1) { + lines = []; + ipDataArray.forEach((e, i) => { + if(e) { + lines.push( + `${e[0]}` + + ((e[1]) ? `${this.secToTimeString(e[1])}` : '') + + `` + ); + }; + }); + lines = lines.join(''); + + ipTable.append( + E('tr', { 'class': 'tr table-titles' }, [ + E('th', { 'class': 'th left', 'style': 'min-width:33%' }, _('IP address')), + (ipDataArray[0][1]) ? E('th', { 'class': 'th left' }, _('Timeout')) : '' + ]) + ); + }; + + try { + ipTable.insertAdjacentHTML('beforeend', lines); + } catch(err) { + if(err.name === 'SyntaxError') { + ui.addNotification(null, + E('p', {}, _('HTML/XML error') + ': ' + err.message), 'error'); + }; + throw err; + }; + + return ipTable; + }, + infoPoll: function() { return fs.exec_direct(tools.execPath, [ 'html-info' ], 'json').catch(e => { ui.addNotification(null, E('p', _('Unable to execute or read contents') @@ -72,6 +135,12 @@ return view.extend({ }; }; }; + + if(data.dnsmasq) { + let rdTableWrapper = document.getElementById('rdTableWrapper'); + rdTableWrapper.innerHTML = ''; + rdTableWrapper.append(this.makeDnsmasqTable(data.dnsmasq)); + }; } else { if(poll.active()) { poll.stop(); @@ -99,7 +168,8 @@ return view.extend({ let update_status = null, iptables = null, - ipset = null; + ipset = null, + dnsmasq = null; if(data) { if(data.status === 'enabled') { update_status = E('table', { 'class': 'table' }); @@ -110,25 +180,25 @@ return view.extend({ E('td', { 'class': 'td left', 'style': 'min-width:33%' }, _('Last blacklist update') + ':'), E('td', { 'class': 'td left', - 'id': 'last_blacklist_update.date' }, + 'id' : 'last_blacklist_update.date' }, data.last_blacklist_update.date), ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td left' }, 'CIDR:'), E('td', { 'class': 'td left', - 'id': 'last_blacklist_update.cidr' }, + 'id' : 'last_blacklist_update.cidr' }, data.last_blacklist_update.cidr), ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td left' }, 'IP:'), E('td', { 'class': 'td left', - 'id': 'last_blacklist_update.ip' }, + 'id' : 'last_blacklist_update.ip' }, data.last_blacklist_update.ip), ]), E('tr', { 'class': 'tr' }, [ E('td', { 'class': 'td left' }, 'FQDN:'), E('td', { 'class': 'td left', - 'id': 'last_blacklist_update.fqdn' }, + 'id' : 'last_blacklist_update.fqdn' }, data.last_blacklist_update.fqdn), ]) ); @@ -153,6 +223,7 @@ return view.extend({ for(let [k, v] of Object.entries(data.iptables)) { if(k === '_dummy') continue; + table_iptables.append( E('tr', { 'class': 'tr' }, [ E('td', { @@ -215,7 +286,19 @@ return view.extend({ ]); }; - poll.add(this.infoPoll); + if(data.dnsmasq) { + let rdTableWrapper = E('div', { + 'id' : 'rdTableWrapper', + 'style': 'width:100%' + }, this.makeDnsmasqTable(data.dnsmasq)); + + dnsmasq = E([ + E('h3', {}, _('Dnsmasq')), + rdTableWrapper, + ]); + }; + + poll.add(L.bind(this.infoPoll, this)); } else { update_status = E('em', {}, _('Status') + ' : ' + _('disabled')); }; @@ -234,6 +317,10 @@ return view.extend({ E('div', { 'class': 'cbi-section fade-in' }, E('div', { 'class': 'cbi-section-node' }, ipset) ), + E('div', { 'class': 'cbi-section fade-in' }, + E('div', { 'class': 'cbi-section-node' }, dnsmasq) + ), + ]); }, diff --git a/luci-app-ruantiblock/po/ru/ruantiblock.po b/luci-app-ruantiblock/po/ru/ruantiblock.po index 772e81d..7e193c0 100644 --- a/luci-app-ruantiblock/po/ru/ruantiblock.po +++ b/luci-app-ruantiblock/po/ru/ruantiblock.po @@ -161,8 +161,11 @@ msgstr "Фильтр хостов" msgid "Hour" msgstr "Час" +msgid "IP address" +msgstr "IP-адрес" + msgid "IP addresses of hosts" -msgstr "IP адреса хостов" +msgstr "IP-адреса хостов" msgid "IP filter" msgstr "Фильтр IP" @@ -380,6 +383,9 @@ msgstr "" msgid "Time" msgstr "Время" +msgid "Timeout" +msgstr "Таймаут" + msgid "Timestamp" msgstr "Время" diff --git a/luci-app-ruantiblock/po/templates/ruantiblock.pot b/luci-app-ruantiblock/po/templates/ruantiblock.pot index 6e6d0c8..3a44892 100644 --- a/luci-app-ruantiblock/po/templates/ruantiblock.pot +++ b/luci-app-ruantiblock/po/templates/ruantiblock.pot @@ -144,6 +144,9 @@ msgstr "" msgid "Hour" msgstr "" +msgid "IP address" +msgstr "" + msgid "IP addresses of hosts" msgstr "" @@ -344,6 +347,9 @@ msgstr "" msgid "Time" msgstr "" +msgid "Timeout" +msgstr "" + msgid "Timestamp" msgstr "" diff --git a/ruantiblock-mod-lua/Makefile b/ruantiblock-mod-lua/Makefile index ee9bc96..f362062 100644 --- a/ruantiblock-mod-lua/Makefile +++ b/ruantiblock-mod-lua/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-lua PKG_VERSION:=0.9.4 -PKG_RELEASE:=0 +PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot include $(INCLUDE_DIR)/package.mk diff --git a/ruantiblock-mod-py/Makefile b/ruantiblock-mod-py/Makefile index d301b19..84dec18 100644 --- a/ruantiblock-mod-py/Makefile +++ b/ruantiblock-mod-py/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-py PKG_VERSION:=0.9.4 -PKG_RELEASE:=0 +PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot include $(INCLUDE_DIR)/package.mk diff --git a/ruantiblock/Makefile b/ruantiblock/Makefile index 68b266f..526fee1 100644 --- a/ruantiblock/Makefile +++ b/ruantiblock/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock PKG_VERSION:=0.9.4 -PKG_RELEASE:=0 +PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot include $(INCLUDE_DIR)/package.mk diff --git a/ruantiblock/files/etc/ruantiblock/scripts/info_output b/ruantiblock/files/etc/ruantiblock/scripts/info_output index cfd4e74..b1a5d46 100644 --- a/ruantiblock/files/etc/ruantiblock/scripts/info_output +++ b/ruantiblock/files/etc/ruantiblock/scripts/info_output @@ -25,19 +25,41 @@ Info() { printf "\"_dummy\":false},"; }' printf "\"ipset\":{"; - for _set in "$IPSET_ALLOWED_HOSTS" "$IPSET_ONION" "$IPSET_CIDR_TMP" "$IPSET_CIDR" "$IPSET_IP_TMP" "$IPSET_IP" "$IPSET_DNSMASQ" + for _set in "$IPSET_ALLOWED_HOSTS" "$IPSET_ONION" "$IPSET_CIDR_TMP" "$IPSET_CIDR" "$IPSET_IP_TMP" "$IPSET_IP" do $IPSET_CMD list "$_set" -terse | $AWK_CMD -F ": " ' { - if($1 ~ /^Name/) + if($1 ~ /^Name/) { printf "\""$2"\":["; - else if($1 ~ /^Size in memory/) + } + else if($1 ~ /^Size in memory/) { printf "\""$2"\","; - else if($1 ~ /^Number of entries/) + } + else if($1 ~ /^Number of entries/) { printf "\""$2"\"],"; + }; }' done - printf "\"_dummy\":false}}" + $IPSET_CMD list "$IPSET_DNSMASQ" | $AWK_CMD -F ": " ' + { + if($1 ~ /^Name/) { + printf "\""$2"\":["; + } + else if($1 ~ /^Size in memory/) { + printf "\""$2"\","; + } + else if($1 ~ /^Number of entries/) { + printf "\""$2"\"]},\"dnsmasq\":["; + } + else if($0 ~ /^[0-9]/) { + split($0, a, " "); + printf "[\"" a[1] "\",\"" a[3] "\"],"; + }; + } + END { + printf "false],"; + }' + printf "\"_dummy\":false}" else printf "{\"status\": \"disabled\"}" fi diff --git a/screenshots/06.jpg b/screenshots/06.jpg index 7f40d5f..7a957f5 100644 Binary files a/screenshots/06.jpg and b/screenshots/06.jpg differ