Skip to content

Commit

Permalink
Merge pull request #81 from highvolt-dev/enhancement/explicit_ipv4_ping
Browse files Browse the repository at this point in the history
Enhancement/explicit ipv4 ping
  • Loading branch information
highvolt-dev committed Feb 11, 2023
2 parents 7649a2b + 938bb66 commit dfc0d1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Valid values are `NOK5G21` for the Nokia gateway, `ARCKVD21` for the square, bla

### Connectivity check
**Mode:** `--connectivity-check`
Defaults to `ping`. Can instead use a HTTP(S) based health check with the `http` value. The `http` health check defaults to checking `https://google.com/generate_204` and checking its status code. _All connectivity checks will respect the `-I --interface` flag_.
Defaults to `ping`. Can instead use a HTTP(S) based health check with the `http` value. The `http` health check defaults to checking `https://google.com/generate_204` and checking its status code.

**Interface:** `-I --interface`
Can be used to specify the network interface used by the ping command. Useful if T-Mobile Home Internet is not your default network interface: e.g., this is running on a dual WAN router. On Windows, pass the source IP address to use. `http` connectivity checks will be dictated by system routing rules.
Expand Down
4 changes: 4 additions & 0 deletions tmo_monitor/gateway/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ControllerBase:
# functions that don't touch the API
def ping(self, ping_host, ping_count, ping_interval, interface = None, ping_6 = False):
is_win = platform.system() == 'Windows'
is_mac = platform.system() == 'Darwin'

ping_cmd = []
extra_flags = []
Expand All @@ -21,6 +22,9 @@ def ping(self, ping_host, ping_count, ping_interval, interface = None, ping_6 =
ping_bin = 'ping6'
else:
extra_flags.append('-6')
# Explicitly use -4 flag for IPv4 except for Mac OS X
elif not is_mac:
extra_flags.append('-4')

# Add optional interface flag
if interface:
Expand Down

0 comments on commit dfc0d1a

Please sign in to comment.