summaryrefslogtreecommitdiff
path: root/ext/net/ops_tls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/net/ops_tls.rs')
-rw-r--r--ext/net/ops_tls.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs
index b27426894..1e2b54533 100644
--- a/ext/net/ops_tls.rs
+++ b/ext/net/ops_tls.rs
@@ -990,6 +990,7 @@ pub struct ListenTlsArgs {
// TODO(kt3k): Remove this option at v2.0.
key_file: Option<String>,
alpn_protocols: Option<Vec<String>>,
+ reuse_port: bool,
}
#[op]
@@ -1001,6 +1002,10 @@ pub fn op_net_listen_tls<NP>(
where
NP: NetPermissions + 'static,
{
+ if args.reuse_port {
+ super::check_unstable(state, "Deno.listenTls({ reusePort: true })");
+ }
+
let cert_file = args.cert_file.as_deref();
let key_file = args.key_file.as_deref();
let cert = args.cert.as_deref();
@@ -1061,6 +1066,10 @@ where
let socket = Socket::new(domain, Type::STREAM, None)?;
#[cfg(not(windows))]
socket.set_reuse_address(true)?;
+ if args.reuse_port {
+ #[cfg(target_os = "linux")]
+ socket.set_reuse_port(true)?;
+ }
let socket_addr = socket2::SockAddr::from(bind_addr);
socket.bind(&socket_addr)?;
socket.listen(128)?;