Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and add socket activity check for internet #312

Merged
merged 6 commits into from
Aug 17, 2021
Merged

Commits on Aug 15, 2021

  1. Move connectivity check code to its own folder

    Deprecation warnings are emitted for anyone using the old locations.
    They'll still work.
    
    The reason for moving the code out of interface is that connectivity
    checking is becoming complicated and will have some additions soon. It
    feels easier to manage outside of the already fairly complicated
    interface handling code.
    fhunleth committed Aug 15, 2021
    Configuration menu
    Copy the full SHA
    eb59b42 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2021

  1. Move check handling logic into its own module

    This also simplifies what happens when the connectivity check fails. All
    errors are handled the same and there are no shortcuts to `:lan` even if
    it looks like the interface is removed. The expectation is that the
    interface will be properly removed shortly if it's for real and
    everything else is suspect.
    
    Moving the check handling logic into its own module is intended to make
    it easier to adjust it and to simplify addng the Inspector check to the
    InternetChecker.
    fhunleth committed Aug 16, 2021
    Configuration menu
    Copy the full SHA
    c191523 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2021

  1. Add internet connectivity inspector

    This is a new module that can determine whether a network interface is
    connected to the internet by watching traffic on TCP sockets known to
    Erlang/OTP. If a device is using long-lived TCP connections (like for
    MQTT) that send keepalive messages, then it can declare
    internet-connectivity just by watching to the tx and rx counters on the
    long-lived connection. This helps reduce use of metered connections and
    benefits devices behind restrictive firewalls that drop the pings.
    
    This commit only adds the module. It is hooked up in a subsequent commit.
    fhunleth committed Aug 17, 2021
    Configuration menu
    Copy the full SHA
    2be4b27 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fe964a6 View commit details
    Browse the repository at this point in the history
  3. Use the connectivity inspector as a first internet check

    This majorly reduces internet traffic for checking status on those
    network interfaces with long-lived TCP connections. Basically, if a TCP
    connection on the interface that's to connecting to a host on a
    different LAN has sent and received bytes since the last internet check,
    then the check is skipped. Internet is available. AWS IoT and NervesHub
    connections are sufficient since their keepalive messages will satisfy
    this check.
    fhunleth committed Aug 17, 2021
    Configuration menu
    Copy the full SHA
    1a65371 View commit details
    Browse the repository at this point in the history
  4. Fix internet connectivity integration tests

    The connectivity checker is pickier now on whether the interface is up
    or down so the unit tests can't take as many shortcuts.
    
    This also fixes an issue where `ifup` would be called and then a
    connectivity check done immediately afterwards. The intended behavior is
    for the CheckLogic to decide rather than this to be assumed. The result
    of this is that the check will be done 500 ms later. This seems good
    since it's short and 500 ms allows for a little time for the interface
    to settle after it just declared that it was up.
    fhunleth committed Aug 17, 2021
    Configuration menu
    Copy the full SHA
    0ae2714 View commit details
    Browse the repository at this point in the history