mirror of
https://github.com/pcvolkmer/checkbar.git
synced 2025-04-19 11:06:50 +00:00
Check if tcp connection is ready
This commit is contained in:
parent
fa24ae712c
commit
f4a5ac568b
@ -1,6 +1,7 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
|
use tokio::io::Interest;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
use crate::checker::{CheckResult, CheckState};
|
use crate::checker::{CheckResult, CheckState};
|
||||||
@ -25,7 +26,21 @@ impl Checker<'_> {
|
|||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => CheckState::Up,
|
Ok(tcp_stream) => {
|
||||||
|
match tcp_stream
|
||||||
|
.ready(Interest::READABLE | Interest::WRITABLE)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(ready) => {
|
||||||
|
if !ready.is_empty() {
|
||||||
|
CheckState::Up
|
||||||
|
} else {
|
||||||
|
CheckState::Warn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => CheckState::Warn,
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => CheckState::Down,
|
_ => CheckState::Down,
|
||||||
};
|
};
|
||||||
return CheckResult {
|
return CheckResult {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user