Update docs for rustls mentions

pull/166/head
Dominik Nakamura 4 years ago
parent 5a3dd8acfd
commit be05920e08
No known key found for this signature in database
GPG Key ID: E4C6A749B2491910
  1. 3
      README.md
  2. 20
      src/client.rs
  3. 12
      src/server.rs
  4. 2
      tests/connection_reset.rs

@ -54,7 +54,8 @@ Features
-------- --------
Tungstenite provides a complete implementation of the WebSocket specification. Tungstenite provides a complete implementation of the WebSocket specification.
TLS is supported on all platforms using native-tls. TLS is supported on all platforms using native-tls or rustls available through the `use-native-tls`
and `use-rustls` feature flags.
There is no support for permessage-deflate at the moment. It's planned. There is no support for permessage-deflate at the moment. It's planned.

@ -89,7 +89,7 @@ mod encryption {
stream::Mode, stream::Mode,
}; };
/// TLS support is nod compiled in, this is just standard `TcpStream`. /// TLS support is not compiled in, this is just standard `TcpStream`.
pub type AutoStream = TcpStream; pub type AutoStream = TcpStream;
pub fn wrap_stream(stream: TcpStream, _domain: &str, mode: Mode) -> Result<AutoStream> { pub fn wrap_stream(stream: TcpStream, _domain: &str, mode: Mode) -> Result<AutoStream> {
@ -116,15 +116,15 @@ use crate::{
/// equal to calling `connect()` function. /// equal to calling `connect()` function.
/// ///
/// The URL may be either ws:// or wss://. /// The URL may be either ws:// or wss://.
/// To support wss:// URLs, feature "tls" must be turned on. /// To support wss:// URLs, feature `use-native-tls` or `use-rustls` must be turned on.
/// ///
/// This function "just works" for those who wants a simple blocking solution /// This function "just works" for those who wants a simple blocking solution
/// similar to `std::net::TcpStream`. If you want a non-blocking or other /// similar to `std::net::TcpStream`. If you want a non-blocking or other
/// custom stream, call `client` instead. /// custom stream, call `client` instead.
/// ///
/// This function uses `native_tls` to do TLS. If you want to use other TLS libraries, /// This function uses `native_tls` or `rustls` to do TLS depending on the feature flags enabled. If
/// use `client` instead. There is no need to enable the "tls" feature if you don't call /// you want to use other TLS libraries, use `client` instead. There is no need to enable the "tls"
/// `connect` since it's the only function that uses native_tls. /// feature if you don't call `connect` since it's the only function that uses native_tls or rustls.
pub fn connect_with_config<Req: IntoClientRequest>( pub fn connect_with_config<Req: IntoClientRequest>(
request: Req, request: Req,
config: Option<WebSocketConfig>, config: Option<WebSocketConfig>,
@ -184,15 +184,15 @@ pub fn connect_with_config<Req: IntoClientRequest>(
/// Connect to the given WebSocket in blocking mode. /// Connect to the given WebSocket in blocking mode.
/// ///
/// The URL may be either ws:// or wss://. /// The URL may be either ws:// or wss://.
/// To support wss:// URLs, feature "tls" must be turned on. /// To support wss:// URLs, feature `use-native-tls` or `use-rustls` must be turned on.
/// ///
/// This function "just works" for those who wants a simple blocking solution /// This function "just works" for those who wants a simple blocking solution
/// similar to `std::net::TcpStream`. If you want a non-blocking or other /// similar to `std::net::TcpStream`. If you want a non-blocking or other
/// custom stream, call `client` instead. /// custom stream, call `client` instead.
/// ///
/// This function uses `native_tls` to do TLS. If you want to use other TLS libraries, /// This function uses `native_tls` or `rustls` to do TLS depending on the feature flags enabled. If
/// use `client` instead. There is no need to enable the "tls" feature if you don't call /// you want to use other TLS libraries, use `client` instead. There is no need to enable the "tls"
/// `connect` since it's the only function that uses native_tls. /// feature if you don't call `connect` since it's the only function that uses native_tls or rustls.
pub fn connect<Req: IntoClientRequest>(request: Req) -> Result<(WebSocket<AutoStream>, Response)> { pub fn connect<Req: IntoClientRequest>(request: Req) -> Result<(WebSocket<AutoStream>, Response)> {
connect_with_config(request, None, 3) connect_with_config(request, None, 3)
} }
@ -213,7 +213,7 @@ fn connect_to_some(addrs: &[SocketAddr], uri: &Uri, mode: Mode) -> Result<AutoSt
/// Get the mode of the given URL. /// Get the mode of the given URL.
/// ///
/// This function may be used to ease the creation of custom TLS streams /// This function may be used to ease the creation of custom TLS streams
/// in non-blocking algorithmss or for use with TLS libraries other than `native_tls`. /// in non-blocking algorithms or for use with TLS libraries other than `native_tls` or `rustls`.
pub fn uri_mode(uri: &Uri) -> Result<Mode> { pub fn uri_mode(uri: &Uri) -> Result<Mode> {
match uri.scheme_str() { match uri.scheme_str() {
Some("ws") => Ok(Mode::Plain), Some("ws") => Ok(Mode::Plain),

@ -17,9 +17,9 @@ use std::io::{Read, Write};
/// used by `accept()`. /// used by `accept()`.
/// ///
/// This function starts a server WebSocket handshake over the given stream. /// This function starts a server WebSocket handshake over the given stream.
/// If you want TLS support, use `native_tls::TlsStream` or `openssl::ssl::SslStream` /// If you want TLS support, use `native_tls::TlsStream`, `rustls::Stream` or
/// for the stream here. Any `Read + Write` streams are supported, including /// `openssl::ssl::SslStream` for the stream here. Any `Read + Write` streams are supported,
/// those from `Mio` and others. /// including those from `Mio` and others.
pub fn accept_with_config<S: Read + Write>( pub fn accept_with_config<S: Read + Write>(
stream: S, stream: S,
config: Option<WebSocketConfig>, config: Option<WebSocketConfig>,
@ -30,9 +30,9 @@ pub fn accept_with_config<S: Read + Write>(
/// Accept the given Stream as a WebSocket. /// Accept the given Stream as a WebSocket.
/// ///
/// This function starts a server WebSocket handshake over the given stream. /// This function starts a server WebSocket handshake over the given stream.
/// If you want TLS support, use `native_tls::TlsStream` or `openssl::ssl::SslStream` /// If you want TLS support, use `native_tls::TlsStream`, `rustls::Stream` or
/// for the stream here. Any `Read + Write` streams are supported, including /// `openssl::ssl::SslStream` for the stream here. Any `Read + Write` streams are supported,
/// those from `Mio` and others. /// including those from `Mio` and others.
pub fn accept<S: Read + Write>( pub fn accept<S: Read + Write>(
stream: S, stream: S,
) -> Result<WebSocket<S>, HandshakeError<ServerHandshake<S, NoCallback>>> { ) -> Result<WebSocket<S>, HandshakeError<ServerHandshake<S, NoCallback>>> {

@ -1,5 +1,5 @@
//! Verifies that the server returns a `ConnectionClosed` error when the connection //! Verifies that the server returns a `ConnectionClosed` error when the connection
//! is closedd from the server's point of view and drop the underlying tcp socket. //! is closed from the server's point of view and drop the underlying tcp socket.
#![cfg(any(feature = "use-native-tls", feature = "use-rustls"))] #![cfg(any(feature = "use-native-tls", feature = "use-rustls"))]
use std::{ use std::{

Loading…
Cancel
Save