ctf_pwn/io/util/timeout/
mod.rs1mod async_read_cache_timeout_ext;
2mod async_read_timeout_ext;
3mod read_exact_timeout;
4mod read_timeout;
5mod read_to_end_timeout;
6mod read_until_regex_timeout;
7mod read_until_timeout;
8
9pub use async_read_cache_timeout_ext::*;
10pub use async_read_timeout_ext::*;
11pub use read_exact_timeout::*;
12pub use read_timeout::*;
13pub use read_until_regex_timeout::*;
14pub use read_until_timeout::*;
15use std::io;
16use std::io::ErrorKind;
17
18use std::time::Duration;
19use tokio::time::Instant;
20
21pub(crate) fn get_deadline(timeout: Duration) -> Instant {
22 Instant::now()
23 .checked_add(timeout)
24 .unwrap_or_else(|| far_future())
25}
26
27pub(crate) fn far_future() -> Instant {
28 Instant::now() + Duration::from_secs(86400 * 365 * 30)
33}
34
35fn eof() -> io::Error {
36 io::Error::new(ErrorKind::UnexpectedEof, "EOF")
37}
38fn timeout() -> io::Error {
39 io::Error::new(ErrorKind::TimedOut, "Timeout")
40}