luci-app-autoipsetadder: sync with upstream source
This commit is contained in:
parent
bb5049a0d1
commit
22cf1a5adc
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-autoipsetadder
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=7
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
@ -19,7 +19,7 @@ define Package/luci-app-autoipsetadder
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=LuCI Support for autoipsetadder
|
||||
PKGARCH:=all
|
||||
DEPENDS:= +coreutils-stdbuf +httping +curl
|
||||
DEPENDS:= +httping +curl
|
||||
endef
|
||||
|
||||
define Package/luci-app-autoipsetadder/description
|
||||
|
||||
@ -33,14 +33,24 @@ end
|
||||
luci.http.write(a)
|
||||
end
|
||||
function get_log()
|
||||
local logfile=uci:get("autoipsetadder","autoipsetadder","logfile") or "/tmp/addlist.log"
|
||||
local logfile,fdp
|
||||
logfile=uci:get("autoipsetadder","autoipsetadder","logfile") or "/tmp/addlist.log"
|
||||
luci.http.prepare_content("text/plain; charset=utf-8")
|
||||
local fdp=tonumber(fs.readfile("/var/run/lucilogpos_ipset")) or 0
|
||||
if not fs.access(logfile) then
|
||||
luci.http.write("")
|
||||
return
|
||||
end
|
||||
if fs.access("/var/run/lucilogreload") then
|
||||
fdp=0
|
||||
fs.remove("/var/run/lucilogreload")
|
||||
else
|
||||
fdp=tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||
end
|
||||
local f=io.open(logfile, "r+")
|
||||
f:seek("set",fdp)
|
||||
local a=f:read(2048000) or ""
|
||||
fdp=f:seek()
|
||||
fs.writefile("/var/run/lucilogpos_ipset",tostring(fdp))
|
||||
fs.writefile("/var/run/lucilogpos",tostring(fdp))
|
||||
f:close()
|
||||
luci.http.write(a)
|
||||
end
|
||||
@ -71,7 +71,7 @@ o.widget = "checkbox"
|
||||
o.default = "nochina pingadd packetpass"
|
||||
o.rmempty=true
|
||||
---- apply
|
||||
nixio.fs.writefile("/var/run/lucilogpos_ipset","0")
|
||||
nixio.fs.writefile("/var/run/lucilogreload","")
|
||||
function m.on_commit(map)
|
||||
local ucitracktest=uci:get("autoipsetadder","autoipsetadder","ucitracktest")
|
||||
if ucitracktest=="1" then
|
||||
|
||||
@ -31,11 +31,12 @@ stop_dnsmasq_log()
|
||||
reload_service()
|
||||
{
|
||||
rm -f /var/run/AdGucitest 2>/dev/null
|
||||
procd_kill $CONFIGURATION
|
||||
kill $(cat /var/run/autoipsetadder.pid)
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONFIGURATION"
|
||||
}
|
||||
start_service() {
|
||||
# Reading config
|
||||
config_load "${CONFIGURATION}"
|
||||
@ -70,26 +71,26 @@ stop_service()
|
||||
}
|
||||
do_crontab(){
|
||||
config_get_bool enabled $CONFIGURATION enabled 0
|
||||
config_get logfile $CONFIGURATION logfile "/tmp/addlist.log"
|
||||
config_get dnslogfile $CONFIGURATION dnslogfile "/tmp/dnsmasq.log"
|
||||
#config_get logfile $CONFIGURATION logfile "/tmp/addlist.log"
|
||||
#config_get dnslogfile $CONFIGURATION dnslogfile "/tmp/dnsmasq.log"
|
||||
config_get crontab $CONFIGURATION crontab ""
|
||||
cronreload=0
|
||||
findstr="echo qingkong > $dnslogfile"
|
||||
default="0 * * * * echo qingkong > $dnslogfile"
|
||||
[ -n "$lastdnslogfile" ] && findstr="echo qingkong > $lastdnslogfile" && [ "$lastdnslogfile" != "$dnslogfile" ] && replace="${lastdnslogfile//\//\\/}/${dnslogfile//\//\\/}"
|
||||
findstr="echo qingkong > \$(uci get autoipsetadder.autoipsetadder.dnslogfile)"
|
||||
default="0 * * * * echo qingkong > \$(uci get autoipsetadder.autoipsetadder.dnslogfile)"
|
||||
#[ -n "$lastdnslogfile" ] && findstr="echo qingkong > $lastdnslogfile" && [ "$lastdnslogfile" != "$dnslogfile" ] && replace="${lastdnslogfile//\//\\/}/${dnslogfile//\//\\/}"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//autodeldnslog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
[ "$lastdnslogfile" != "$dnslogfile" ] && uci set autoipsetadder.autoipsetadder.lastdnslogfile="$dnslogfile" && commit=1
|
||||
#[ "$lastdnslogfile" != "$dnslogfile" ] && uci set autoipsetadder.autoipsetadder.lastdnslogfile="$dnslogfile" && commit=1
|
||||
|
||||
findstr="/usr/bin/autoipsetadder/tailto.sh [0-9]* $logfile"
|
||||
default="0 0 * * * /usr/bin/autoipsetadder/tailto.sh 2000 $logfile"
|
||||
[ -n "$lastlogfile" ] && findstr="/usr/bin/autoipsetadder/tailto.sh [0-9]* $lastlogfile" && [ "$lastlogfile" != "$logfile" ] && replace="${lastlogfile//\//\\/}/${logfile//\//\\/}"
|
||||
findstr="/usr/bin/autoipsetadder/tailto.sh [0-9]* \$(uci get autoipsetadder.autoipsetadder.logfile)"
|
||||
default="0 0 * * * /usr/bin/autoipsetadder/tailto.sh 2000 \$(uci get autoipsetadder.autoipsetadder.logfile)"
|
||||
#[ -n "$lastlogfile" ] && findstr="/usr/bin/autoipsetadder/tailto.sh [0-9]* $lastlogfile" && [ "$lastlogfile" != "$logfile" ] && replace="${lastlogfile//\//\\/}/${logfile//\//\\/}"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//autotaillog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set autoipsetadder.autoipsetadder.lastlogfile="$logfile" && commit=1
|
||||
#[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set autoipsetadder.autoipsetadder.lastlogfile="$logfile" && commit=1
|
||||
|
||||
[ "$cronreload" -gt 0 ] && /etc/init.d/cron restart
|
||||
[ "$commit" -gt 0 ] && uci commit autoipsetadder
|
||||
#[ "$commit" -gt 0 ] && uci commit autoipsetadder
|
||||
}
|
||||
crontab_editor(){
|
||||
local testline reload
|
||||
|
||||
@ -7,7 +7,7 @@ dnslogfile=$(uci get autoipsetadder.autoipsetadder.dnslogfile)
|
||||
config=$(uci get autoipsetadder.autoipsetadder.config 2>/dev/null)
|
||||
[ "${config//nochina/}" == "$config" ] && nochina="0" || nochina="1"
|
||||
[ "${config//packetpass/}" == "$config" ] && packetpass="0" || packetpass="1"
|
||||
( stdbuf -oL tail -F $dnslogfile & echo $! >/var/run/autoipsetadder.pid ) | awk -v nochina="$nochina" -v packetpass="$packetpass" -F "[, ]+" '/reply/{
|
||||
(tail -F $dnslogfile & echo $! >/var/run/autoipsetadder.pid ) | awk -v nochina="$nochina" -v packetpass="$packetpass" -F "[, ]+" '/reply/{
|
||||
ip=$8;
|
||||
if (ip=="" || ip=="127.0.0.1"|| ip=="0.0.0.0")
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user