Merge pull request #1280 from hwhw/master

fix a case when "ip r" command fails
pull/1291/head
Huang Xin 10 years ago
commit e835c1e502

@ -74,10 +74,12 @@ end
function NetworkMgr:getWifiStatus()
local default_string = io.popen("ip r | grep default")
if not default_string then return false end
local result = default_string:read()
default_string:close()
if result ~= nil then
local gateway = string.match(result,"%d+.%d+.%d+.%d+")
if os.execute("ping -q -c1 "..gateway) == 0 then
if gateway and os.execute("ping -q -c1 "..gateway) == 0 then
return true
end -- ping to gateway
end -- test for empty string

Loading…
Cancel
Save