mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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_linux