Fixed a crash on startup.

This commit is contained in:
gSpot
2025-10-04 23:35:11 +03:00
parent 663ac6c90b
commit 87d28fb618
11 changed files with 54 additions and 52 deletions

View File

@@ -20,22 +20,22 @@ Internet-detector is an application for checking the availability of the Interne
## Installation notes: ## Installation notes:
opkg update 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 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.6-r1_all.ipk opkg install /tmp/internet-detector_1.6.7-r1_all.ipk
rm /tmp/internet-detector_1.6.6-r1_all.ipk rm /tmp/internet-detector_1.6.7-r1_all.ipk
service internet-detector start service internet-detector start
service internet-detector enable 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 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.6-r2_all.ipk opkg install /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk
rm /tmp/luci-app-internet-detector_1.6.6-r2_all.ipk rm /tmp/luci-app-internet-detector_1.6.7-r1_all.ipk
service rpcd restart service rpcd restart
i18n-ru: 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 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.6-r2_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.6-r2_all.ipk rm /tmp/luci-i18n-internet-detector-ru_1.6.7-r1_all.ipk
## Screenshots: ## Screenshots:
@@ -47,9 +47,9 @@ i18n-ru:
**Dependences:** modemmanager. **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 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.6-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.6-r1_all.ipk rm /tmp/internet-detector-mod-modem-restart_1.6.7-r1_all.ipk
service internet-detector restart service internet-detector restart
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg) ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/04.jpg)
@@ -58,9 +58,9 @@ i18n-ru:
**Dependences:** mailsend. **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 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.6-r1_all.ipk opkg install /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk
rm /tmp/internet-detector-mod-email_1.6.6-r1_all.ipk rm /tmp/internet-detector-mod-email_1.6.7-r1_all.ipk
service internet-detector restart service internet-detector restart
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg) ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/05.jpg)
@@ -69,9 +69,9 @@ i18n-ru:
**Dependences:** curl. **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 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.6-r1_all.ipk opkg install /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk
rm /tmp/internet-detector-mod-telegram_1.6.6-r1_all.ipk rm /tmp/internet-detector-mod-telegram_1.6.7-r1_all.ipk
service internet-detector restart service internet-detector restart
![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/06.jpg) ![](https://github.com/gSpotx2f/luci-app-internet-detector/blob/master/screenshots/06.jpg)

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-email PKG_NAME:=internet-detector-mod-email
PKG_VERSION:=1.6.6 PKG_VERSION:=1.6.7
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -180,7 +180,7 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end end
end end
self._connected = false self._connected = false
else elseif currentStatus == 0 then
self._deadCounter = 0 self._deadCounter = 0
self._msgSentDisconnect = false self._msgSentDisconnect = false

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-modem-restart PKG_NAME:=internet-detector-mod-modem-restart
PKG_VERSION:=1.6.6 PKG_VERSION:=1.6.7
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-telegram PKG_NAME:=internet-detector-mod-telegram
PKG_VERSION:=1.6.6 PKG_VERSION:=1.6.7
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -225,7 +225,7 @@ function Module:run(currentStatus, lastStatus, timeDiff, timeNow, inetChecked)
end end
end end
self._connected = false self._connected = false
else elseif currentStatus == 0 then
self._deadCounter = 0 self._deadCounter = 0
self._msgSentDisconnect = false self._msgSentDisconnect = false

View File

@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector PKG_NAME:=internet-detector
PKG_VERSION:=1.6.6 PKG_VERSION:=1.6.7
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>

View File

@@ -240,7 +240,6 @@ function InternetDetector:TCPConnectionToHost(host, port)
"GETADDRINFO ERROR: %s, %s", errMsg, errNum)) "GETADDRINFO ERROR: %s, %s", errMsg, errNum))
else else
local family = saTable[1].family local family = saTable[1].family
if family then if family then
local sock, errMsg, errNum = socket.socket(family, socket.SOCK_STREAM, 0) 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.SIGQUIT, function(signo) self:exit(signo) end)
signal.signal(signal.SIGUSR1, function(signo) self:resetUiCounter(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 interval = self.serviceConfig.interval_up
local modulesStatus = {} local modulesStatus = {}
local counter = 0 local counter = 0
@@ -340,14 +341,18 @@ function InternetDetector:mainLoop()
local attempt = 1 local attempt = 1
local checkFunc = (self.serviceConfig.check_type == 1) and self.pingHost or self.TCPConnectionToHost 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 while true do
if counter == 0 or counter >= interval then if counter == 0 or counter >= interval then
checking = true checking = true
end end
inetChecked = false
if checking then if checking then
local newStatus = 1 local newStatus = 1
local checkCompleted = false
if hostNum <= #self.parsedHosts then if hostNum <= #self.parsedHosts then
if attempt <= self.serviceConfig.connection_attempts then if attempt <= self.serviceConfig.connection_attempts then
local addr = self.parsedHosts[hostNum].addr local addr = self.parsedHosts[hostNum].addr
@@ -373,7 +378,7 @@ function InternetDetector:mainLoop()
checking = false checking = false
newStatus = 0 newStatus = 0
counter = 0 counter = 0
checkCompleted = true inetChecked = true
else else
attempt = attempt + 1 attempt = attempt + 1
if attempt > self.serviceConfig.connection_attempts then if attempt > self.serviceConfig.connection_attempts then
@@ -389,16 +394,16 @@ function InternetDetector:mainLoop()
hostNum = 1 hostNum = 1
checking = false checking = false
counter = 0 counter = 0
checkCompleted = true inetChecked = true
end end
else else
hostNum = 1 hostNum = 1
checking = false checking = false
counter = 0 counter = 0
checkCompleted = true inetChecked = true
end end
if checkCompleted then if inetChecked then
currentStatus = newStatus currentStatus = newStatus
if not stat.stat(self.statusFile) then if not stat.stat(self.statusFile) then
self:writeValueToFile(self.statusFile, self:statusJson( self:writeValueToFile(self.statusFile, self:statusJson(
@@ -411,7 +416,7 @@ function InternetDetector:mainLoop()
currentStatus, self.serviceConfig.instance)) currentStatus, self.serviceConfig.instance))
self:writeLogMessage("notice", "Connected") self:writeLogMessage("notice", "Connected")
end end
else elseif currentStatus == 1 then
interval = self.serviceConfig.interval_down interval = self.serviceConfig.interval_down
if currentStatus ~= lastStatus then if currentStatus ~= lastStatus then
self:writeValueToFile(self.statusFile, self:statusJson( self:writeValueToFile(self.statusFile, self:statusJson(
@@ -423,7 +428,6 @@ function InternetDetector:mainLoop()
end end
mTimeDiff = 0 mTimeDiff = 0
inetChecked = (counter == 0)
for _, e in ipairs(self.modules) do for _, e in ipairs(self.modules) do
mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec mTimeNow = time.clock_gettime(time.CLOCK_MONOTONIC).tv_sec
if mLastTime then if mLastTime then
@@ -432,6 +436,7 @@ function InternetDetector:mainLoop()
mTimeDiff = 1 mTimeDiff = 1
end end
mLastTime = mTimeNow mLastTime = mTimeNow
if self.debug then if self.debug then
e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked) e:run(currentStatus, lastStatus, mTimeDiff, mTimeNow, inetChecked)
else else
@@ -651,9 +656,6 @@ function InternetDetector:run()
inspectTable()(self, "self.") inspectTable()(self, "self.")
end end
self:writeValueToFile(
self.statusFile, self:statusJson(-1, self.serviceConfig.instance))
self:mainLoop() self:mainLoop()
self:exit() self:exit()
end end

View File

@@ -269,7 +269,7 @@ function Module:ledRunFunc(t, currentStatus)
) )
end end
end end
else elseif currentStatus == 1 then
if t.ledAction2 == 1 then if t.ledAction2 == 1 then
if self:getCurrentState(t) or self:getCurrentTrigger(t) then if self:getCurrentState(t) or self:getCurrentTrigger(t) then
self:off(t) self:off(t)

View File

@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-internet-detector PKG_NAME:=luci-app-internet-detector
PKG_VERSION:=1.6.6 PKG_VERSION:=1.6.7
PKG_RELEASE:=2 PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for internet-detector LUCI_TITLE:=LuCI support for internet-detector
LUCI_DEPENDS:=+internet-detector LUCI_DEPENDS:=+internet-detector
LUCI_PKGARCH:=all LUCI_PKGARCH:=all

View File

@@ -915,7 +915,7 @@ return view.extend({
o.modalonly = true; o.modalonly = true;
if(this.leds.length > 0) { 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 // enabled
o = s.taboption('led_control', form.Flag, o = s.taboption('led_control', form.Flag,