-
Notifications
You must be signed in to change notification settings - Fork 414
remove unnecessary network pings to 8.8.8.8 #1363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| use reqwest::Client; | ||
| use std::time::Duration; | ||
|
|
||
| pub async fn is_online() -> bool { | ||
| let target = "8.8.8.8".to_string(); | ||
| let interval = std::time::Duration::from_secs(1); | ||
| let options = pinger::PingOptions::new(target, interval, None); | ||
| let client = Client::builder() | ||
|
||
| .timeout(Duration::from_secs(8)) | ||
| .build() | ||
| .unwrap(); | ||
|
||
|
|
||
| if let Ok(stream) = pinger::ping(options) { | ||
| if let Some(message) = stream.into_iter().next() { | ||
| match message { | ||
| pinger::PingResult::Pong(_, _) => return true, | ||
| _ => return false, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| false | ||
| let url = "https://posthog.com/"; | ||
|
|
||
| match client.get(url).send().await { | ||
| Ok(resp) if resp.status().is_success() => true, | ||
| _ => false, | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cargo.toml syntax is invalid here. The workspace override must be expressed as an inline table (
reqwest = { workspace = true }); using the dotted key form without first declaring[dependencies.reqwest]will causecargo metadatato fail to parse the manifest.Prompt for AI agents