Skip to content

Commit 49af0b9

Browse files
committed
feat: timeout on endpoint check
1 parent b9f45e0 commit 49af0b9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
fmt::{Display, Formatter},
88
io,
99
net::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs},
10-
str::FromStr,
10+
str::FromStr, time::Duration,
1111
};
1212
use tokio::{
1313
io::{AsyncRead, AsyncWrite, AsyncWriteExt},
@@ -354,7 +354,12 @@ async fn create_endpoint(
354354
builder = builder.bind_addr_v6(addr);
355355
}
356356
let endpoint = builder.bind().await?;
357-
endpoint.online().await;
357+
358+
let _ = tokio::time::timeout(Duration::from_secs(30), async {
359+
if !(common.relay == RelayModeOption::Disabled) {
360+
endpoint.online().await;
361+
}
362+
}).await;
358363

359364
Ok(endpoint)
360365
}

tests/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn dumbpipe_bin() -> &'static str {
1919
///
2020
/// This assumes that the header lines are ASCII and can be parsed byte by byte.
2121
fn read_ascii_lines(mut n: usize, reader: &mut impl Read) -> io::Result<Vec<u8>> {
22-
let mut buf = [0u8; 1];
22+
let mut buf = [0u8; 1];
2323
let mut res = Vec::new();
2424
loop {
2525
if reader.read(&mut buf)? != 1 {

0 commit comments

Comments
 (0)