From a88d9aa56638cd6e5c1a79e18d922d66b249d885 Mon Sep 17 00:00:00 2001 From: lumi Date: Sat, 25 Feb 2017 06:58:42 +0100 Subject: [PATCH] added more channel binding infrastructure --- src/client.rs | 5 +++-- src/transport.rs | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/client.rs b/src/client.rs index fff412e..6c20fbc 100644 --- a/src/client.rs +++ b/src/client.rs @@ -68,11 +68,12 @@ impl ClientBuilder { /// Connects to the server and returns a `Client` when succesful. pub fn connect(self) -> Result { let host = &self.host.unwrap_or(self.jid.domain.clone()); - // TODO: channel binding let mut transport = SslTransport::connect(host, self.port)?; C2S::init(&mut transport, &self.jid.domain, "before_sasl")?; let (sender_out, sender_in) = channel(); let (dispatcher_out, dispatcher_in) = channel(); + let mut credentials = self.credentials.expect("can't connect without credentials"); + credentials.channel_binding = transport.channel_bind(); let mut client = Client { jid: self.jid, transport: transport, @@ -81,7 +82,7 @@ impl ClientBuilder { sender_in: sender_in, dispatcher_in: dispatcher_in, }; - client.connect(self.credentials.expect("can't connect without credentials"))?; + client.connect(credentials)?; client.bind()?; Ok(client) } diff --git a/src/transport.rs b/src/transport.rs index d0e9242..502780b 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -35,6 +35,11 @@ pub trait Transport { /// Resets the stream. fn reset_stream(&mut self); + + /// Gets channel binding data. + fn channel_bind(&self) -> Option> { + None + } } /// A transport which uses STARTTLS. @@ -73,6 +78,11 @@ impl Transport for SslTransport { .. Default::default() }); } + + fn channel_bind(&self) -> Option> { + // TODO: channel binding + None + } } impl SslTransport {