Hotfix followup to #10139 (#10151)

Don't blow up if we fall back to exec'ing ping
Fix https://github.com/koreader/koreader/pull/10139#issuecomment-1437678458
reviewable/pr10152/r1
NiLuJe 1 year ago committed by GitHub
parent 5330c24b77
commit d0b78c01aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -540,9 +540,9 @@ function Device:ping4(ip)
if socket == -1 then if socket == -1 then
errno = ffi.errno() errno = ffi.errno()
if errno == C.EPERM then if errno == C.EPERM then
logger.dbg("Device:ping4: Opening a RAW ICMP socket requires CAP_NET_RAW capabilities!") logger.dbg("Device:ping4: opening a RAW ICMP socket requires CAP_NET_RAW capabilities!")
else else
logger.dbg("Device:ping4: Raw ICMP socket:", ffi.string(C.strerror(errno))) logger.dbg("Device:ping4: raw ICMP socket:", ffi.string(C.strerror(errno)))
end end
--- Fall-back to the ping CLI tool, in the hope that it's setuid... --- Fall-back to the ping CLI tool, in the hope that it's setuid...
if self:isKindle() and self:hasDPad() then if self:isKindle() and self:hasDPad() then
@ -841,9 +841,11 @@ function Device:retrieveNetworkInfo()
if default_gw then if default_gw then
local ok, rtt = self:ping4(default_gw) local ok, rtt = self:ping4(default_gw)
if ok then if ok then
rtt = string.format("%.3f", rtt * 1/1000) -- i.e., time.to_ms w/o flooring
table.insert(results, _("Gateway ping successful")) table.insert(results, _("Gateway ping successful"))
table.insert(results, T(_("RTT: %1 ms"), rtt)) if rtt then
rtt = string.format("%.3f", rtt * 1/1000) -- i.e., time.to_ms w/o flooring
table.insert(results, T(_("RTT: %1 ms"), rtt))
end
else else
table.insert(results, _("Gateway ping FAILED")) table.insert(results, _("Gateway ping FAILED"))
if rtt then if rtt then

Loading…
Cancel
Save