Skip to content

Commit b87ef98

Browse files
committed
endpoint: allow override server configuration
1 parent 5d3a103 commit b87ef98

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

quinn-proto/src/endpoint.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ where
109109
self.transmits.pop_front()
110110
}
111111

112+
/// Replace the server configuration, affecting new incoming connections only
113+
pub fn set_server_config(&mut self, server_config: Option<Arc<ServerConfig<S>>>) {
114+
self.server_config = server_config;
115+
}
116+
112117
/// Process `EndpointEvent`s emitted from related `Connection`s
113118
///
114119
/// In turn, processing this event may return a `ConnectionEvent` for the same `Connection`.

quinn/src/endpoint.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ use futures_channel::mpsc;
1717
use futures_util::StreamExt;
1818
use fxhash::FxHashMap;
1919
use once_cell::sync::OnceCell;
20-
use proto::{self as proto, generic::ClientConfig, ConnectError, ConnectionHandle, DatagramEvent};
20+
use proto::{
21+
self as proto,
22+
generic::{ClientConfig, ServerConfig},
23+
ConnectError, ConnectionHandle, DatagramEvent,
24+
};
2125

2226
use crate::{
2327
broadcast::{self, Broadcast},
@@ -116,6 +120,18 @@ where
116120
Ok(())
117121
}
118122

123+
/// Set the server configuration overriding the existing one.
124+
/// If this endpoint has been built without a server configuration, it does nothing.
125+
///
126+
/// Useful for e.g. refreshing TLS certificates without disrupting existing connections.
127+
pub fn set_server_config(&self, server_config: Option<ServerConfig<S>>) {
128+
self.inner
129+
.lock()
130+
.unwrap()
131+
.inner
132+
.set_server_config(server_config.map(Arc::new))
133+
}
134+
119135
/// Get the local `SocketAddr` the underlying socket is bound to
120136
pub fn local_addr(&self) -> io::Result<SocketAddr> {
121137
self.inner.lock().unwrap().socket.local_addr()

0 commit comments

Comments
 (0)