1
0
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:
Paul-Christian Volkmer 2023-02-26 12:54:37 +01:00
parent fa24ae712c
commit f4a5ac568b

View File

@ -1,6 +1,7 @@
use std::str::FromStr;
use reqwest::Url;
use tokio::io::Interest;
use tokio::net::TcpStream;
use crate::checker::{CheckResult, CheckState};
@ -25,7 +26,21 @@ impl Checker<'_> {
))
.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,
};
return CheckResult {