14 releases (8 stable)

4.0.2 Feb 14, 2024
4.0.1 Mar 10, 2023
4.0.0 Sep 20, 2022
3.0.2 Sep 4, 2022
0.2.0 May 21, 2019

#840 in Network programming

Download history 2606/week @ 2024-11-15 2994/week @ 2024-11-22 2718/week @ 2024-11-29 2731/week @ 2024-12-06 2897/week @ 2024-12-13 1918/week @ 2024-12-20 1027/week @ 2024-12-27 1459/week @ 2025-01-03 2380/week @ 2025-01-10 2683/week @ 2025-01-17 2842/week @ 2025-01-24 3081/week @ 2025-01-31 3015/week @ 2025-02-07 3400/week @ 2025-02-14 2777/week @ 2025-02-21 1429/week @ 2025-02-28

11,458 downloads per month
Used in 8 crates

MIT license

8KB
87 lines

online

📶 Library to check your Internet connectivity

Logo

Workflow status Latest version

Features

  • Both asynchronous and blocking implementations.
  • IPv4 and IPv6 support.

How it works

  • Tries to connect to Chrome captive portal (using its domain name).
  • If fails, tries the Firefox one.
  • If both fail, the second error is returned to help with diagnostics.

Install

The library is available on crates.io. In example, through cargo-edit:

cargo add online

Async

online = { version = "4.0.0",  default-features = false, features = ["tokio"] }

Use

📝 Please visit the examples and documentation to check the details.

use online::check;

println!("Online? {}", check(None).is_ok());
println!("Online (timeout)? {}", check(Some(5)).is_ok());

Examples

cargo run --example sync
cargo run --features="tokio-runtime" --example tokio

Dependencies

~0–8MB
~63K SLoC