Allow getting the compression used in a connection
This commit is contained in:
parent
cd40d25cb5
commit
c4ede3d585
|
|
@ -4,6 +4,7 @@ use libc::{c_int, c_void, c_long, c_ulong, c_char};
|
||||||
|
|
||||||
pub type SSL_CTX = c_void;
|
pub type SSL_CTX = c_void;
|
||||||
pub type SSL_METHOD = c_void;
|
pub type SSL_METHOD = c_void;
|
||||||
|
pub type COMP_METHOD = c_void;
|
||||||
pub type SSL = c_void;
|
pub type SSL = c_void;
|
||||||
pub type BIO = c_void;
|
pub type BIO = c_void;
|
||||||
pub type BIO_METHOD = c_void;
|
pub type BIO_METHOD = c_void;
|
||||||
|
|
@ -145,12 +146,15 @@ extern "C" {
|
||||||
pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int;
|
pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int;
|
||||||
pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int;
|
pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int;
|
||||||
pub fn SSL_get_SSL_CTX(ssl: *mut SSL) -> *mut SSL_CTX;
|
pub fn SSL_get_SSL_CTX(ssl: *mut SSL) -> *mut SSL_CTX;
|
||||||
|
pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const COMP_METHOD;
|
||||||
|
|
||||||
pub fn BIO_s_mem() -> *const BIO_METHOD;
|
pub fn BIO_s_mem() -> *const BIO_METHOD;
|
||||||
pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
|
pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
|
||||||
pub fn BIO_free_all(a: *mut BIO);
|
pub fn BIO_free_all(a: *mut BIO);
|
||||||
pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
|
pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
|
||||||
pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
|
pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
|
||||||
|
|
||||||
|
pub fn SSL_COMP_get_name(comp: *const COMP_METHOD) -> *const c_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "win32")]
|
#[cfg(target_os = "win32")]
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rt::mutex::NativeMutex;
|
use std::rt::mutex::NativeMutex;
|
||||||
|
use std::string;
|
||||||
use sync::one::{Once, ONCE_INIT};
|
use sync::one::{Once, ONCE_INIT};
|
||||||
|
|
||||||
use ssl::error::{SslError, SslSessionClosed, StreamError};
|
use ssl::error::{SslError, SslSessionClosed, StreamError};
|
||||||
|
|
@ -500,6 +501,21 @@ impl<S: Stream> SslStream<S> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the compression currently in use. The result will be
|
||||||
|
/// either None, indicating no compression is in use, or a string
|
||||||
|
/// with the compression name.
|
||||||
|
pub fn get_compression(&self) -> Option<String> {
|
||||||
|
let ptr = unsafe { ffi::SSL_get_current_compression(self.ssl.ssl) };
|
||||||
|
if ptr == ptr::null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let meth = unsafe { ffi::SSL_COMP_get_name(ptr) };
|
||||||
|
let s = unsafe { string::raw::from_buf(meth as *const u8) };
|
||||||
|
|
||||||
|
Some(s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Stream> Reader for SslStream<S> {
|
impl<S: Stream> Reader for SslStream<S> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue