mirror of https://github.com/koreader/koreader
NetworkMgr: Use cheaper/simpler hasDefaultRoute in isOnline
Device:getDefaultRoute parses /proc/net/route and converts the hex addresses to textual IP addresses, but in `isOnline` we don't care what address the gateway actually has, we only care about whether we have a default route into the Internet. This provides a simpler alternative that does the equivalent of "ip route get 203.0.113.1 || ip route get 2001:db8::1" (note that it does support IPv6-only connectivity as opposed to Device:getDefaultRoute) and returns true if we have a route. Inspired by https://github.com/pavel-odintsov/get_default_outgoing_ip_linuxreviewable/pr11639/r1
parent
b3e125a7ce
commit
4fa6783dbb
Loading…
Reference in New Issue