diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 12b0a887..df998ff0 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(unsafe_destructor, core, io, std_misc, path, os, unique)] +#![feature(unsafe_destructor, core, io, std_misc, net, path, os, unique)] #![cfg_attr(test, feature(net, fs))] #![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/openssl")] diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index ecf12905..06e37aac 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -5,6 +5,7 @@ use std::io; use std::io::prelude::*; use std::ffi::AsOsStr; use std::mem; +use std::net; use std::num::FromPrimitive; use std::num::Int; use std::path::Path; @@ -437,6 +438,17 @@ pub struct SslStream { buf: Vec } +impl SslStream { + /// Create a new independently owned handle to the underlying socket. + pub fn try_clone(&self) -> io::Result> { + Ok(SslStream { + stream: try!(self.stream.try_clone()), + ssl: self.ssl.clone(), + buf: self.buf.clone(), + }) + } +} + impl fmt::Debug for SslStream where S: fmt::Debug { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "SslStream {{ stream: {:?}, ssl: {:?} }}", self.stream, self.ssl)