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

#383 in Network programming

Download history 4225/week @ 2024-03-14 6219/week @ 2024-03-21 3690/week @ 2024-03-28 6143/week @ 2024-04-04 4592/week @ 2024-04-11 7362/week @ 2024-04-18 4429/week @ 2024-04-25 4549/week @ 2024-05-02 6512/week @ 2024-05-09 11464/week @ 2024-05-16 6600/week @ 2024-05-23 5702/week @ 2024-05-30 6581/week @ 2024-06-06 6454/week @ 2024-06-13 5924/week @ 2024-06-20 2631/week @ 2024-06-27

22,979 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–11MB
~75K SLoC