Skip to content

Commit 0fd5309

Browse files
authored
turn: introduced DEFAULT_MAX_RETRIES (#692)
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
1 parent b03ed50 commit 0fd5309

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

turn/src/relay/relay_range.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use util::vnet::net::*;
66
use super::*;
77
use crate::error::*;
88

9+
/// Default maximum number of retries when allocating a random port in the defined range.
10+
const DEFAULT_MAX_RETRIES: u16 = 10;
11+
912
/// `RelayAddressGeneratorRanges` can be used to only allocate connections inside a defined port range.
1013
pub struct RelayAddressGeneratorRanges {
1114
/// `relay_address` is the IP returned to the user when the relay is created.
@@ -48,7 +51,7 @@ impl RelayAddressGenerator for RelayAddressGeneratorRanges {
4851
requested_port: u16,
4952
) -> Result<(Arc<dyn Conn + Send + Sync>, SocketAddr)> {
5053
let max_retries = if self.max_retries == 0 {
51-
10
54+
DEFAULT_MAX_RETRIES
5255
} else {
5356
self.max_retries
5457
};

0 commit comments

Comments
 (0)