Skip to content

Commit

Permalink
Allow TlsListener::from() to specify a resolver.
Browse files Browse the repository at this point in the history
  • Loading branch information
hcldan committed Aug 6, 2024
1 parent f2ca2ad commit a559c50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions core/lib/src/tls/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ pub struct TlsListener<L> {
impl<L> TlsListener<L>
where L: Listener<Accept = <L as Listener>::Connection>,
{
pub async fn from(listener: L, config: TlsConfig) -> Result<TlsListener<L>> {
pub async fn from(
listener: L,
mut config: TlsConfig,
resolver: Option<DynResolver>
) -> Result<TlsListener<L>> {
config.resolver = resolver;

Ok(TlsListener {
default: Arc::new(config.server_config().await?),
listener,
Expand All @@ -41,8 +47,7 @@ impl<L: Bind> Bind for TlsListener<L>
async fn bind(rocket: &Rocket<Ignite>) -> Result<Self, Self::Error> {
let listener = L::bind(rocket).map_err(|e| Error::Bind(Box::new(e))).await?;
let mut config: TlsConfig = rocket.figment().extract_inner("tls")?;
config.resolver = DynResolver::extract(rocket);
Self::from(listener, config).await
Self::from(listener, config, DynResolver::extract(rocket)).await
}

fn bind_endpoint(rocket: &Rocket<Ignite>) -> Result<Endpoint, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/src/tls/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::fairing::{self, Info, Kind};

/// Proxy type to get PartialEq + Debug impls.
#[derive(Clone)]
pub(crate) struct DynResolver(Arc<dyn Resolver>);
pub struct DynResolver(Arc<dyn Resolver>);

pub struct Fairing<T: ?Sized>(PhantomData<T>);

Expand Down

0 comments on commit a559c50

Please sign in to comment.