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

#639 in Network programming

Download history 5721/week @ 2024-09-11 4868/week @ 2024-09-18 6887/week @ 2024-09-25 7711/week @ 2024-10-02 4412/week @ 2024-10-09 5015/week @ 2024-10-16 7043/week @ 2024-10-23 5191/week @ 2024-10-30 4040/week @ 2024-11-06 2725/week @ 2024-11-13 2991/week @ 2024-11-20 2693/week @ 2024-11-27 2231/week @ 2024-12-04 2849/week @ 2024-12-11 3041/week @ 2024-12-18 953/week @ 2024-12-25

9,479 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