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

#786 in Network programming

Download history 5800/week @ 2024-08-02 4590/week @ 2024-08-09 4535/week @ 2024-08-16 3095/week @ 2024-08-23 3423/week @ 2024-08-30 4275/week @ 2024-09-06 5523/week @ 2024-09-13 6149/week @ 2024-09-20 6472/week @ 2024-09-27 7456/week @ 2024-10-04 4205/week @ 2024-10-11 6480/week @ 2024-10-18 5879/week @ 2024-10-25 4688/week @ 2024-11-01 2990/week @ 2024-11-08 2156/week @ 2024-11-15

17,179 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
~62K SLoC