mirror of
https://github.com/gSpotx2f/luci-app-internet-detector.git
synced 2025-12-06 11:36:49 +03:00
main.InternetDetector.debugOutput().
This commit is contained in:
30
README.md
30
README.md
@@ -17,22 +17,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.5.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.5.1-r1_all.ipk
|
wget --no-check-certificate -O /tmp/internet-detector_1.5.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.5.2-r1_all.ipk
|
||||||
opkg install /tmp/internet-detector_1.5.1-r1_all.ipk
|
opkg install /tmp/internet-detector_1.5.2-r1_all.ipk
|
||||||
rm /tmp/internet-detector_1.5.1-r1_all.ipk
|
rm /tmp/internet-detector_1.5.2-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.5.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.5.1-r1_all.ipk
|
wget --no-check-certificate -O /tmp/luci-app-internet-detector_1.5.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-app-internet-detector_1.5.2-r1_all.ipk
|
||||||
opkg install /tmp/luci-app-internet-detector_1.5.1-r1_all.ipk
|
opkg install /tmp/luci-app-internet-detector_1.5.2-r1_all.ipk
|
||||||
rm /tmp/luci-app-internet-detector_1.5.1-r1_all.ipk
|
rm /tmp/luci-app-internet-detector_1.5.2-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.5.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.5.1-r1_all.ipk
|
wget --no-check-certificate -O /tmp/luci-i18n-internet-detector-ru_1.5.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/luci-i18n-internet-detector-ru_1.5.2-r1_all.ipk
|
||||||
opkg install /tmp/luci-i18n-internet-detector-ru_1.5.1-r1_all.ipk
|
opkg install /tmp/luci-i18n-internet-detector-ru_1.5.2-r1_all.ipk
|
||||||
rm /tmp/luci-i18n-internet-detector-ru_1.5.1-r1_all.ipk
|
rm /tmp/luci-i18n-internet-detector-ru_1.5.2-r1_all.ipk
|
||||||
|
|
||||||
## Screenshots:
|
## Screenshots:
|
||||||
|
|
||||||
@@ -44,9 +44,9 @@ i18n-ru:
|
|||||||
|
|
||||||
**Dependences:** modemmanager.
|
**Dependences:** modemmanager.
|
||||||
|
|
||||||
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.5.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.5.1-r1_all.ipk
|
wget --no-check-certificate -O /tmp/internet-detector-mod-modem-restart_1.5.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-modem-restart_1.5.2-r1_all.ipk
|
||||||
opkg install /tmp/internet-detector-mod-modem-restart_1.5.1-r1_all.ipk
|
opkg install /tmp/internet-detector-mod-modem-restart_1.5.2-r1_all.ipk
|
||||||
rm /tmp/internet-detector-mod-modem-restart_1.5.1-r1_all.ipk
|
rm /tmp/internet-detector-mod-modem-restart_1.5.2-r1_all.ipk
|
||||||
service internet-detector restart
|
service internet-detector restart
|
||||||
|
|
||||||

|

|
||||||
@@ -55,9 +55,9 @@ i18n-ru:
|
|||||||
|
|
||||||
**Dependences:** mailsend.
|
**Dependences:** mailsend.
|
||||||
|
|
||||||
wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.5.1-r2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.5.1-r2_all.ipk
|
wget --no-check-certificate -O /tmp/internet-detector-mod-email_1.5.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector-mod-email_1.5.2-r1_all.ipk
|
||||||
opkg install /tmp/internet-detector-mod-email_1.5.1-r2_all.ipk
|
opkg install /tmp/internet-detector-mod-email_1.5.2-r1_all.ipk
|
||||||
rm /tmp/internet-detector-mod-email_1.5.1-r2_all.ipk
|
rm /tmp/internet-detector-mod-email_1.5.2-r1_all.ipk
|
||||||
service internet-detector restart
|
service internet-detector restart
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector-mod-email
|
PKG_NAME:=internet-detector-mod-email
|
||||||
PKG_VERSION:=1.5.1
|
PKG_VERSION:=1.5.2
|
||||||
PKG_RELEASE:=2
|
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>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ local Module = {
|
|||||||
debug = false,
|
debug = false,
|
||||||
},
|
},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
deadPeriod = 0,
|
deadPeriod = 0,
|
||||||
@@ -122,8 +123,7 @@ function Module:sendMessage(msg, textPattern)
|
|||||||
-- Debug
|
-- Debug
|
||||||
if self.config.debug then
|
if self.config.debug then
|
||||||
verboseArg = " -v"
|
verboseArg = " -v"
|
||||||
io.stdout:write(string.format("--- %s ---\n", self.name))
|
self.debugOutput(string.format("--- %s ---", self.name))
|
||||||
io.stdout:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local securityArgs = "-starttls -auth-login"
|
local securityArgs = "-starttls -auth-login"
|
||||||
@@ -141,8 +141,7 @@ function Module:sendMessage(msg, textPattern)
|
|||||||
|
|
||||||
-- Debug
|
-- Debug
|
||||||
if self.config.debug then
|
if self.config.debug then
|
||||||
io.stdout:write(string.format("%s: %s\n", self.name, mtaCmd))
|
self.debugOutput(string.format("%s: %s", self.name, mtaCmd))
|
||||||
io.stdout:flush()
|
|
||||||
self.syslog("debug", string.format("%s: %s", self.name, mtaCmd))
|
self.syslog("debug", string.format("%s: %s", self.name, mtaCmd))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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.5.1
|
PKG_VERSION:=1.5.2
|
||||||
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>
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ local Module = {
|
|||||||
runPrio = 40,
|
runPrio = 40,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
mmcli = "/usr/bin/mmcli",
|
mmcli = "/usr/bin/mmcli",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=internet-detector
|
PKG_NAME:=internet-detector
|
||||||
PKG_VERSION:=1.5.1
|
PKG_VERSION:=1.5.2
|
||||||
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>
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,13 @@ function InternetDetector:writeLogMessage(level, msg)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function InternetDetector:debugOutput(msg)
|
||||||
|
if self.debug then
|
||||||
|
io.stdout:write(string.format("[%s] %s\n", os.date("%Y.%m.%d-%H:%M:%S"), msg))
|
||||||
|
io.stdout:flush()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function InternetDetector:loadModules()
|
function InternetDetector:loadModules()
|
||||||
self.modules = {}
|
self.modules = {}
|
||||||
local ok, modulesDir = pcall(dirent.files, self.modulesDir)
|
local ok, modulesDir = pcall(dirent.files, self.modulesDir)
|
||||||
@@ -182,6 +189,7 @@ function InternetDetector:loadModules()
|
|||||||
if m then
|
if m then
|
||||||
m.config = self
|
m.config = self
|
||||||
m.syslog = function(level, msg) self:writeLogMessage(level, msg) end
|
m.syslog = function(level, msg) self:writeLogMessage(level, msg) end
|
||||||
|
m.debugOutput = function(msg) self:debugOutput(msg) end
|
||||||
m.writeValue = function(filePath, str) return self:writeValueToFile(filePath, str) end
|
m.writeValue = function(filePath, str) return self:writeValueToFile(filePath, str) end
|
||||||
m.readValue = function(filePath) return self:readValueFromFile(filePath) end
|
m.readValue = function(filePath) return self:readValueFromFile(filePath) end
|
||||||
m:init(modConfig)
|
m:init(modConfig)
|
||||||
@@ -223,12 +231,8 @@ function InternetDetector:pingHost(host)
|
|||||||
)
|
)
|
||||||
local retCode = os.execute(ping)
|
local retCode = os.execute(ping)
|
||||||
|
|
||||||
if self.debug then
|
self:debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"--- Ping ---\ntime = %s\n%s\nretCode = %s", os.time(), ping, retCode))
|
||||||
"--- Ping ---\ntime = %s\n%s\nretCode = %s\n", os.time(), ping, retCode)
|
|
||||||
)
|
|
||||||
io.stdout:flush()
|
|
||||||
end
|
|
||||||
|
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
@@ -238,21 +242,16 @@ function InternetDetector:TCPConnectionToHost(host, port)
|
|||||||
local saTable, errMsg, errNum = socket.getaddrinfo(host, port or self.serviceConfig.tcp_port)
|
local saTable, errMsg, errNum = socket.getaddrinfo(host, port or self.serviceConfig.tcp_port)
|
||||||
|
|
||||||
if not saTable then
|
if not saTable then
|
||||||
if self.debug then
|
self:debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"GETADDRINFO ERROR: %s, %s", errMsg, errNum))
|
||||||
"GETADDRINFO ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
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)
|
||||||
|
|
||||||
if not sock then
|
if not sock then
|
||||||
if self.debug then
|
self:debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
||||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -265,10 +264,8 @@ function InternetDetector:TCPConnectionToHost(host, port)
|
|||||||
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||||
socket.SO_BINDTODEVICE, self.serviceConfig.iface)
|
socket.SO_BINDTODEVICE, self.serviceConfig.iface)
|
||||||
if not ok then
|
if not ok then
|
||||||
if self.debug then
|
self:debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
||||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
unistd.close(sock)
|
unistd.close(sock)
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
@@ -278,23 +275,23 @@ function InternetDetector:TCPConnectionToHost(host, port)
|
|||||||
|
|
||||||
if self.debug then
|
if self.debug then
|
||||||
if not success then
|
if not success then
|
||||||
io.stdout:write(string.format(
|
self:debugOutput(string.format(
|
||||||
"SOCKET CONNECT ERROR: %s\n", tostring(success)))
|
"SOCKET CONNECT ERROR: %s", tostring(success)))
|
||||||
end
|
end
|
||||||
local sockTable, err_s, e_s = socket.getsockname(sock)
|
local sockTable, err_s, e_s = socket.getsockname(sock)
|
||||||
local peerTable, err_p, e_p = socket.getpeername(sock)
|
local peerTable, err_p, e_p = socket.getpeername(sock)
|
||||||
if not sockTable then
|
if not sockTable then
|
||||||
sockTable = {}
|
sockTable = {}
|
||||||
io.stdout:write(
|
self:debugOutput(
|
||||||
string.format("SOCKET ERROR: %s, %s\n", err_s, e_s))
|
string.format("SOCKET ERROR: %s, %s", err_s, e_s))
|
||||||
end
|
end
|
||||||
if not peerTable then
|
if not peerTable then
|
||||||
peerTable = {}
|
peerTable = {}
|
||||||
io.stdout:write(
|
self:debugOutput(
|
||||||
string.format("SOCKET ERROR: %s, %s\n", err_p, e_p))
|
string.format("SOCKET ERROR: %s, %s", err_p, e_p))
|
||||||
end
|
end
|
||||||
io.stdout:write(string.format(
|
self:debugOutput(string.format(
|
||||||
"--- TCP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nhost:port = [%s]:%s\nsockname = [%s]:%s\npeername = [%s]:%s\nsuccess = %s\n",
|
"--- TCP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nhost:port = [%s]:%s\nsockname = [%s]:%s\npeername = [%s]:%s\nsuccess = %s",
|
||||||
os.time(),
|
os.time(),
|
||||||
self.serviceConfig.connection_timeout,
|
self.serviceConfig.connection_timeout,
|
||||||
tostring(self.serviceConfig.iface),
|
tostring(self.serviceConfig.iface),
|
||||||
@@ -306,7 +303,6 @@ function InternetDetector:TCPConnectionToHost(host, port)
|
|||||||
tostring(peerTable.port),
|
tostring(peerTable.port),
|
||||||
tostring(success))
|
tostring(success))
|
||||||
)
|
)
|
||||||
io.stdout:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
socket.shutdown(sock, socket.SHUT_RDWR)
|
socket.shutdown(sock, socket.SHUT_RDWR)
|
||||||
@@ -400,6 +396,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
|
||||||
@@ -423,7 +420,6 @@ function InternetDetector:mainLoop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
lastStatus = currentStatus
|
lastStatus = currentStatus
|
||||||
|
|
||||||
unistd.sleep(1)
|
unistd.sleep(1)
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
|
|
||||||
@@ -589,8 +585,8 @@ function InternetDetector:run()
|
|||||||
f = function(t, prefix)
|
f = function(t, prefix)
|
||||||
tables[t] = true
|
tables[t] = true
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
io.stdout:write(string.format(
|
self:debugOutput(string.format(
|
||||||
"%s%s = %s\n", prefix, k, tostring(v))
|
"%s%s = %s", prefix, k, tostring(v))
|
||||||
)
|
)
|
||||||
if type(v) == "table" and not tables[v] then
|
if type(v) == "table" and not tables[v] then
|
||||||
f(v, string.format("%s%s.", prefix, k))
|
f(v, string.format("%s%s.", prefix, k))
|
||||||
@@ -600,9 +596,8 @@ function InternetDetector:run()
|
|||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
|
|
||||||
io.stdout:write("--- Config ---\n")
|
self:debugOutput("--- Config ---")
|
||||||
inspectTable()(self, "self.")
|
inspectTable()(self, "self.")
|
||||||
io.stdout:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:writeValueToFile(
|
self:writeValueToFile(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local Module = {
|
|||||||
runPrio = 10,
|
runPrio = 10,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
runInterval = 5,
|
runInterval = 5,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local Module = {
|
|||||||
runPrio = 30,
|
runPrio = 30,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
deadPeriod = 900,
|
deadPeriod = 900,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ local Module = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
port = 53,
|
port = 53,
|
||||||
@@ -136,29 +137,21 @@ function Module:sendUDPMessage(message, server, port)
|
|||||||
local retCode = 1
|
local retCode = 1
|
||||||
local data
|
local data
|
||||||
|
|
||||||
if self.config.debug then
|
self.debugOutput(string.format("--- %s ---", self.name))
|
||||||
io.stdout:write(string.format("--- %s ---\n", self.name))
|
|
||||||
io.stdout:flush()
|
|
||||||
end
|
|
||||||
|
|
||||||
local saTable, errMsg, errNum = socket.getaddrinfo(server, port)
|
local saTable, errMsg, errNum = socket.getaddrinfo(server, port)
|
||||||
|
|
||||||
if not saTable then
|
if not saTable then
|
||||||
if self.config.debug then
|
self.debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"GETADDRINFO ERROR: %s, %s", errMsg, errNum))
|
||||||
"GETADDRINFO ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
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_DGRAM, 0)
|
local sock, errMsg, errNum = socket.socket(family, socket.SOCK_DGRAM, 0)
|
||||||
|
|
||||||
if not sock then
|
if not sock then
|
||||||
if self.config.debug then
|
self.debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
||||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -171,10 +164,8 @@ function Module:sendUDPMessage(message, server, port)
|
|||||||
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
local ok, errMsg, errNum = socket.setsockopt(sock, socket.SOL_SOCKET,
|
||||||
socket.SO_BINDTODEVICE, self.config.serviceConfig.iface)
|
socket.SO_BINDTODEVICE, self.config.serviceConfig.iface)
|
||||||
if not ok then
|
if not ok then
|
||||||
if self.config.debug then
|
self.debugOutput(string.format(
|
||||||
io.stdout:write(string.format(
|
"SOCKET ERROR: %s, %s", errMsg, errNum))
|
||||||
"SOCKET ERROR: %s, %s\n", errMsg, errNum))
|
|
||||||
end
|
|
||||||
unistd.close(sock)
|
unistd.close(sock)
|
||||||
return retCode
|
return retCode
|
||||||
end
|
end
|
||||||
@@ -189,17 +180,17 @@ function Module:sendUDPMessage(message, server, port)
|
|||||||
success = true
|
success = true
|
||||||
response = resp
|
response = resp
|
||||||
elseif self.config.debug then
|
elseif self.config.debug then
|
||||||
io.stdout:write(string.format(
|
self.debugOutput(string.format(
|
||||||
"SOCKET RECV ERROR: %s, %s\n", tostring(resp), tostring(errNum)))
|
"SOCKET RECV ERROR: %s, %s", tostring(resp), tostring(errNum)))
|
||||||
end
|
end
|
||||||
elseif self.config.debug then
|
elseif self.config.debug then
|
||||||
io.stdout:write(string.format(
|
self.debugOutput(string.format(
|
||||||
"SOCKET SEND ERROR: %s, %s\n", tostring(errMsg), tostring(errNum)))
|
"SOCKET SEND ERROR: %s, %s", tostring(errMsg), tostring(errNum)))
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.config.debug then
|
if self.config.debug then
|
||||||
io.stdout:write(string.format(
|
self.debugOutput(string.format(
|
||||||
"--- UDP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nserver = %s:%s\nsockname = %s:%s\nsuccess = %s\n",
|
"--- UDP ---\ntime = %s\nconnection_timeout = %s\niface = %s\nserver = %s:%s\nsockname = %s:%s\nsuccess = %s",
|
||||||
os.time(),
|
os.time(),
|
||||||
self.timeout,
|
self.timeout,
|
||||||
tostring(self.config.serviceConfig.iface),
|
tostring(self.config.serviceConfig.iface),
|
||||||
@@ -209,7 +200,6 @@ function Module:sendUDPMessage(message, server, port)
|
|||||||
tostring(response.port),
|
tostring(response.port),
|
||||||
tostring(success))
|
tostring(success))
|
||||||
)
|
)
|
||||||
io.stdout:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
unistd.close(sock)
|
unistd.close(sock)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local Module = {
|
|||||||
runPrio = 20,
|
runPrio = 20,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
deadPeriod = 3600,
|
deadPeriod = 3600,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local Module = {
|
|||||||
runPrio = 90,
|
runPrio = 90,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
inetState = 2, -- 0: connected, 1: disconnected, 2: both
|
inetState = 2, -- 0: connected, 1: disconnected, 2: both
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local Module = {
|
|||||||
runPrio = 80,
|
runPrio = 80,
|
||||||
config = {},
|
config = {},
|
||||||
syslog = function(level, msg) return true end,
|
syslog = function(level, msg) return true end,
|
||||||
|
debugOutput = function(msg) return true end,
|
||||||
writeValue = function(filePath, str) return false end,
|
writeValue = function(filePath, str) return false end,
|
||||||
readValue = function(filePath) return nil end,
|
readValue = function(filePath) return nil end,
|
||||||
deadPeriod = 0,
|
deadPeriod = 0,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-internet-detector
|
PKG_NAME:=luci-app-internet-detector
|
||||||
PKG_VERSION:=1.5.1
|
PKG_VERSION:=1.5.2
|
||||||
PKG_RELEASE:=1
|
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
|
||||||
|
|||||||
@@ -919,6 +919,7 @@ return view.extend({
|
|||||||
o.value(3);
|
o.value(3);
|
||||||
o.value(4);
|
o.value(4);
|
||||||
o.value(5);
|
o.value(5);
|
||||||
|
o.value(10);
|
||||||
o.value(0, _('infinitely'));
|
o.value(0, _('infinitely'));
|
||||||
o.default = '1';
|
o.default = '1';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user