|
1 | | -use std::{collections::HashMap, io, net::SocketAddr, time::Duration}; |
| 1 | +use std::{collections::HashMap, io, net::SocketAddr, num::NonZeroU64, time::Duration}; |
2 | 2 |
|
3 | 3 | use base64::prelude::{BASE64_STANDARD, Engine as _}; |
4 | 4 | use bytes::{Buf, Bytes, BytesMut}; |
@@ -184,6 +184,14 @@ pub struct FluentTcpConfig { |
184 | 184 | #[configurable(metadata(docs::examples = 65536))] |
185 | 185 | receive_buffer_bytes: Option<usize>, |
186 | 186 |
|
| 187 | + /// The timeout, in seconds, before a TLS handshake is aborted if it has not completed. |
| 188 | + /// |
| 189 | + /// This bounds how long a connection can hold its slot against `connection_limit` |
| 190 | + /// before the TLS handshake finishes, protecting against clients that open a |
| 191 | + /// connection but never complete (or never start) a handshake. |
| 192 | + #[configurable(metadata(docs::type_unit = "seconds"))] |
| 193 | + tls_handshake_timeout_secs: Option<NonZeroU64>, |
| 194 | + |
187 | 195 | #[configurable(derived)] |
188 | 196 | tls: Option<TlsSourceConfig>, |
189 | 197 |
|
@@ -216,6 +224,7 @@ impl FluentTcpConfig { |
216 | 224 | tls_client_metadata_key, |
217 | 225 | self.receive_buffer_bytes, |
218 | 226 | None, |
| 227 | + self.tls_handshake_timeout_secs, |
219 | 228 | cx, |
220 | 229 | self.acknowledgements, |
221 | 230 | self.connection_limit, |
@@ -277,6 +286,7 @@ impl GenerateConfig for FluentConfig { |
277 | 286 | permit_origin: None, |
278 | 287 | tls: None, |
279 | 288 | receive_buffer_bytes: None, |
| 289 | + tls_handshake_timeout_secs: None, |
280 | 290 | acknowledgements: Default::default(), |
281 | 291 | connection_limit: Some(2), |
282 | 292 | }), |
@@ -1167,6 +1177,7 @@ mod tests { |
1167 | 1177 | keepalive: None, |
1168 | 1178 | permit_origin: None, |
1169 | 1179 | receive_buffer_bytes: None, |
| 1180 | + tls_handshake_timeout_secs: None, |
1170 | 1181 | acknowledgements: true.into(), |
1171 | 1182 | connection_limit: None, |
1172 | 1183 | }), |
@@ -1240,6 +1251,7 @@ mod tests { |
1240 | 1251 | keepalive: None, |
1241 | 1252 | permit_origin: None, |
1242 | 1253 | receive_buffer_bytes: None, |
| 1254 | + tls_handshake_timeout_secs: None, |
1243 | 1255 | acknowledgements: false.into(), |
1244 | 1256 | connection_limit: None, |
1245 | 1257 | }), |
@@ -1298,6 +1310,7 @@ mod tests { |
1298 | 1310 | keepalive: None, |
1299 | 1311 | permit_origin: None, |
1300 | 1312 | receive_buffer_bytes: None, |
| 1313 | + tls_handshake_timeout_secs: None, |
1301 | 1314 | acknowledgements: false.into(), |
1302 | 1315 | connection_limit: None, |
1303 | 1316 | }), |
@@ -1527,6 +1540,7 @@ mod integration_tests { |
1527 | 1540 | keepalive: None, |
1528 | 1541 | permit_origin: None, |
1529 | 1542 | receive_buffer_bytes: None, |
| 1543 | + tls_handshake_timeout_secs: None, |
1530 | 1544 | acknowledgements: false.into(), |
1531 | 1545 | connection_limit: None, |
1532 | 1546 | }), |
|
0 commit comments