diff --git a/README.md b/README.md index 1931d5f..37d62dc 100644 --- a/README.md +++ b/README.md @@ -20,22 +20,22 @@ Internet-detector is an application for checking the availability of the Interne ## Installation notes: opkg update - wget --no-check-certificate -O /tmp/internet-detector_1.6.6-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.6.6-r1_all.ipk - opkg install /tmp/internet-detector_1.6.6-r1_all.ipk - rm /tmp/internet-detector_1.6.6-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.6.7-r1_all.ipk + opkg install /tmp/internet-detector_1.6.7-r1_all.ipk + rm /tmp/internet-detector_1.6.7-r1_all.ipk service internet-detector start service internet-detector enable - wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.6.6-r2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.6.6-r2_all.ipk - opkg install /tmp/luci-app-internet-detector_1.6.6-r2_all.ipk - rm /tmp/luci-app-internet-detector_1.6.6-r2_all.ipk + wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.6.7-r1_all.ipk + opkg install /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk + rm /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk service rpcd restart i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.6.6-r2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.6.6-r2_all.ipk - opkg install /tmp/luci-i18n-internet-detector-ru_1.6.6-r2_all.ipk - rm /tmp/luci-i18n-internet-detector-ru_1.6.6-r2_all.ipk + wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk + opkg install /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk + rm /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk ## Screenshots: @@ -47,9 +47,9 @@ i18n-ru: **Dependences:** modemmanager. - wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.6.6-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.6.6-r1_all.ipk - opkg install /tmp/internet-detector-mod-modem-restart_1.6.6-r1_all.ipk - rm /tmp/internet-detector-mod-modem-restart_1.6.6-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk + opkg install /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk + rm /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg) @@ -58,9 +58,9 @@ i18n-ru: **Dependences:** mailsend. - wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.6.6-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.6.6-r1_all.ipk - opkg install /tmp/internet-detector-mod-email_1.6.6-r1_all.ipk - rm /tmp/internet-detector-mod-email_1.6.6-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.6.7-r1_all.ipk + opkg install /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk + rm /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg) @@ -69,9 +69,9 @@ i18n-ru: **Dependences:** curl. - wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.6.6-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-telegram_1.6.6-r1_all.ipk - opkg install /tmp/internet-detector-mod-telegram_1.6.6-r1_all.ipk - rm /tmp/internet-detector-mod-telegram_1.6.6-r1_all.ipk + wget --no-check-certificate -O /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-telegram_1.6.7-r1_all.ipk + opkg install /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk + rm /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk service internet-detector restart ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/06.jpg) diff --git a/internet-detector-mod-email/Makefile b/internet-detector-mod-email/Makefile index 8399da7..a83cf98 100644 --- a/internet-detector-mod-email/Makefile +++ b/internet-detector-mod-email/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-email -PKG_VERSION:=1.6.6 +PKG_VERSION:=1.6.7 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-email/files/usr/lib/lua/internet-detector/modules/mod_email.lua b/internet-detector-mod-email/files/usr/lib/lua/internet-detector/modules/mod_email.lua index 8ba0988..e078ae6 100644 --- a/internet-detector-mod-email/files/usr/lib/lua/internet-detector/modules/mod_email.lua +++ b/internet-detector-mod-email/files/usr/lib/lua/internet-detector/modules/mod_email.lua @@ -180,7 +180,7 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end self._connected = false - else + elseif currentStatus == 0 then self._deadCounter = 0 self._msgSentDisconnect = false diff --git a/internet-detector-mod-modem-restart/Makefile b/internet-detector-mod-modem-restart/Makefile index f1074a6..75fb65d 100644 --- a/internet-detector-mod-modem-restart/Makefile +++ b/internet-detector-mod-modem-restart/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-modem-restart -PKG_VERSION:=1.6.6 +PKG_VERSION:=1.6.7 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-telegram/Makefile b/internet-detector-mod-telegram/Makefile index 78a1dad..80252b6 100644 --- a/internet-detector-mod-telegram/Makefile +++ b/internet-detector-mod-telegram/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector-mod-telegram -PKG_VERSION:=1.6.6 +PKG_VERSION:=1.6.7 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua b/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua index a86f8a5..9400e34 100644 --- a/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua +++ b/internet-detector-mod-telegram/files/usr/lib/lua/internet-detector/modules/mod_telegram.lua @@ -225,7 +225,7 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked) end end self._connected = false - else + elseif currentStatus == 0 then self._deadCounter = 0 self._msgSentDisconnect = false diff --git a/internet-detector/Makefile b/internet-detector/Makefile index a9f75db..5f9b837 100644 --- a/internet-detector/Makefile +++ b/internet-detector/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=internet-detector -PKG_VERSION:=1.6.6 +PKG_VERSION:=1.6.7 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/internet-detector/files/usr/lib/lua/internet-detector/main.lua b/internet-detector/files/usr/lib/lua/internet-detector/main.lua index 4961bb8..39394e1 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/main.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/main.lua @@ -240,7 +240,6 @@ function InternetDetector:TCPConnectionToHost(host, port) "GETADDRINFO ERROR: %s, %s", errMsg, errNum)) else local family = saTable[1].family - if family then local sock, errMsg, errNum = socket.socket(family, socket.SOCK_STREAM, 0) @@ -330,7 +329,9 @@ function InternetDetector:mainLoop() signal.signal(signal.SIGQUIT, function(signo) self:exit(signo) end) signal.signal(signal.SIGUSR1, function(signo) self:resetUiCounter(signo) end) - local lastStatus, currentStatus, mTimeNow, mTimeDiff, mLastTime, uiTimeNow, uiLastTime + local mTimeNow, mTimeDiff, mLastTime, uiTimeNow, uiLastTime + local lastStatus = -1 + local currentStatus = -1 local interval = self.serviceConfig.interval_up local modulesStatus = {} local counter = 0 @@ -340,14 +341,18 @@ function InternetDetector:mainLoop() local attempt = 1 local checkFunc = (self.serviceConfig.check_type == 1) and self.pingHost or self.TCPConnectionToHost + self:writeValueToFile( + self.statusFile, self:statusJson(currentStatus, self.serviceConfig.instance)) + while true do if counter == 0 or counter >= interval then checking = true end + inetChecked = false + if checking then - local newStatus = 1 - local checkCompleted = false + local newStatus = 1 if hostNum <= #self.parsedHosts then if attempt <= self.serviceConfig.connection_attempts then local addr = self.parsedHosts[hostNum].addr @@ -368,12 +373,12 @@ function InternetDetector:mainLoop() end end if retCode == 0 then - attempt = 1 - hostNum = 1 - checking = false - newStatus = 0 - counter = 0 - checkCompleted = true + attempt = 1 + hostNum = 1 + checking = false + newStatus = 0 + counter = 0 + inetChecked = true else attempt = attempt + 1 if attempt > self.serviceConfig.connection_attempts then @@ -386,19 +391,19 @@ function InternetDetector:mainLoop() hostNum = hostNum + 1 end if hostNum > #self.parsedHosts then - hostNum = 1 - checking = false - counter = 0 - checkCompleted = true + hostNum = 1 + checking = false + counter = 0 + inetChecked = true end else - hostNum = 1 - checking = false - counter = 0 - checkCompleted = true + hostNum = 1 + checking = false + counter = 0 + inetChecked = true end - if checkCompleted then + if inetChecked then currentStatus = newStatus if not stat.stat(self.statusFile) then self:writeValueToFile(self.statusFile, self:statusJson( @@ -411,7 +416,7 @@ function InternetDetector:mainLoop() currentStatus, self.serviceConfig.instance)) self:writeLogMessage("notice", "Connected") end - else + elseif currentStatus == 1 then interval = self.serviceConfig.interval_down if currentStatus ~= lastStatus then self:writeValueToFile(self.statusFile, self:statusJson( @@ -423,7 +428,6 @@ function InternetDetector:mainLoop() end mTimeDiff = 0 - inetChecked = (counter == 0) for _, e in ipairs(self.modules) do mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec if mLastTime then @@ -432,6 +436,7 @@ function InternetDetector:mainLoop() mTimeDiff = 1 end mLastTime = mTimeNow + if self.debug then e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked) else @@ -651,9 +656,6 @@ function InternetDetector:run() inspectTable()(self, "self.") end - self:writeValueToFile( - self.statusFile, self:statusJson(-1, self.serviceConfig.instance)) - self:mainLoop() self:exit() end diff --git a/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_led_control.lua b/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_led_control.lua index 01c813e..f99b810 100644 --- a/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_led_control.lua +++ b/internet-detector/files/usr/lib/lua/internet-detector/modules/mod_led_control.lua @@ -269,7 +269,7 @@ function Module:ledRunFunc(t, currentStatus) ) end end - else + elseif currentStatus == 1 then if t.ledAction2 == 1 then if self:getCurrentState(t) or self:getCurrentTrigger(t) then self:off(t) diff --git a/luci-app-internet-detector/Makefile b/luci-app-internet-detector/Makefile index a8f9bee..6f06fcd 100644 --- a/luci-app-internet-detector/Makefile +++ b/luci-app-internet-detector/Makefile @@ -5,8 +5,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-internet-detector -PKG_VERSION:=1.6.6 -PKG_RELEASE:=2 +PKG_VERSION:=1.6.7 +PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for internet-detector LUCI_DEPENDS:=+internet-detector LUCI_PKGARCH:=all diff --git a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js index 710ef10..e134498 100644 --- a/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js +++ b/luci-app-internet-detector/htdocs/luci-static/resources/view/internet-detector.js @@ -915,7 +915,7 @@ return view.extend({ o.modalonly = true; if(this.leds.length > 0) { - this.leds.sort((a, b) => a.name > b.name ? 1 : -1); + this.leds.sort((a, b) => (a.name > b.name) ? 1 : (a.name < b.name) ? -1 : 0); // enabled o = s.taboption('led_control', form.Flag,