Skip to content

fix: replace single-IP ping with multi-method internet check#358

Merged
fe51 merged 3 commits intodevelopfrom
watchdog-internet
Apr 27, 2026
Merged

fix: replace single-IP ping with multi-method internet check#358
fe51 merged 3 commits intodevelopfrom
watchdog-internet

Conversation

@fe51
Copy link
Copy Markdown
Member

@fe51 fe51 commented Apr 22, 2026

Pitch

ICMP ping to public IPs (1.1.1.1, 8.8.8.8) can be blocked on mobile/4G networks even when real internet access works. This caused false-positive internet failures on some watchdog CRON run

Modifications

Replaces ping_host(INTERNET_IP) with internet_check_ok() which tries lightweight HTTP/HTTPS probes first (generate_204 endpoints) and falls back to pinging multiple IPs only if all HTTP checks fail. No new dependencies — uses stdlib urllib.request.


Hypothesis

ICMP — Internet Control Message Protocol is a low-level network protocol used for diagnostics (ping, traceroute, "host unreachable" messages). It operates below TCP/UDP — no ports, just raw IP packets with a type field.

Why operators might block it:

  • DDoS mitigation — ICMP flood attacks are trivial to launch, so many carriers simply drop inbound/outbound ICMP at their edge to protect infrastructure.
  • Traffic prioritization — on constrained 4G links, operators deprioritize or discard "non-revenue" control traffic; ICMP is the easiest thing to drop without breaking real applications.
  • Firewalling policy — some operators run CGNAT + stateful firewalls that only track TCP/UDP sessions; ICMP has no session concept so it gets dropped by default.
  • Prevent network mapping — blocking ICMP makes it harder for outsiders to probe the operator's internal topology.

HTTP/HTTPS traffic on port 443 is virtually never blocked because that would break the entire web — which is why it's a more reliable signal for "internet is actually working."

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.85%. Comparing base (1bc58f6) to head (cb71c7c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #358   +/-   ##
========================================
  Coverage    73.85%   73.85%           
========================================
  Files            6        6           
  Lines          631      631           
========================================
  Hits           466      466           
  Misses         165      165           
Flag Coverage Δ
unittests 73.85% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fe51 fe51 requested a review from MateoLostanlen April 23, 2026 17:02
Comment thread watchdog/pi_zero/watchdog.py Outdated
MateoLostanlen
MateoLostanlen previously approved these changes Apr 27, 2026
Copy link
Copy Markdown
Member

@MateoLostanlen MateoLostanlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small efficiency comment but ok for me, thanks

@fe51
Copy link
Copy Markdown
Member Author

fe51 commented Apr 27, 2026

Fixed @MateoLostanlen , can you approve and I merge after :) ?

@MateoLostanlen
Copy link
Copy Markdown
Member

hi @fe51 can you fix style first ?

@fe51
Copy link
Copy Markdown
Member Author

fe51 commented Apr 27, 2026

done @MateoLostanlen ! thanks for the catch

@fe51 fe51 merged commit 74e39bc into develop Apr 27, 2026
11 of 12 checks passed
@fe51 fe51 deleted the watchdog-internet branch April 27, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants