Hackerfleet / hfos-legacy

Hackerfleet Operating System
GNU Affero General Public License v3.0
29 stars 4 forks source link

Teach hfos to know on/offline state #220

Closed ij0n closed 6 years ago

ij0n commented 7 years ago

hfos needs to know wether an uplink is available or not so that for example maplayers can be shown or not because the box is offline.

Maybe a third state is a good idea, like "online but limited to low volume/traffic". Necessary for sat uplink or 3g in some countrys

ri0t commented 6 years ago

This is inherently impossible. No, pinging google-servers is not going to work reliably nor with privacy in mind. One thing that may be possible once our system controls the uplink means (which it currently does not) is to determine which uplinks have been tasked to connect. Using this to determine internet-connectivity is (again) impossible to do in a reliable way.

What we can (and will) do, is to use the mesh network state to see what we can reach, but only later (probably not before 1.5)

ij0n commented 6 years ago

Pinging outside servers is the only way to determine that. It may not be reliable, but the rate of error is small. If a DNS answers a request and a different server responds to an ICMP-packet, then we can say "we are online". Everything else is "we dont know" and if nothing is hooked up and "no interface available" we are definitly offline.

I dont see a problem of having a third state, that is chosen, whenever the state can not be reliably determined.

I also dont see any privacy problems, pinging any outside server.

Pushing this to "when we control interfaces" is even less reliable, because it does not include bridging mode, many marinas are offering wifi, so we should be able to connect to them. This would then be in bridge-mode. On top of that, wether an interface is tasked to connect provides absolutly no information wether down the line of that interface something may be wrong.

To determine that state, we need to ping an outside server.

ri0t commented 6 years ago

Re: "when we control interfaces" - imho is the only reliable way of telling if we're on a costly interface or not. Re: no privacy problems - i have a compromise: a configurable target host. That way people can choose 8.8.8.8 but don't have to.

ri0t commented 6 years ago

We can't send icmp. This needs root access or a hacky access to setuid /bin/ping - so i researched and it seems doing a socket connect somewhere is the most sane approach to test connectivity.

ri0t commented 6 years ago

Ah, to clarify: This has become a component inside the comms-module, which'll also deal with managing local network connections etc.

Since it relies on the nodestate module, it also uses that to display connectivity status to the user.