Reimplement the websocket transport. (#1150)

* Begin reimplementing the websocket transport.

* Add TLS support.

* Add support for redirects during handshake.

* Cosmetics.

* Remove unused error cases in tls module.

Left-overs from a previous implementation.

* No libp2p-websocket for wasm targets.

* Change tls::Config to make the server optional.

* Update transports/websocket/src/lib.rs

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

* Duplicate config methods.

As per PR review feedback.
This commit is contained in:
Toralf Wittner
2019-06-04 11:47:20 +02:00
committed by Pierre Krieger
parent 34e7e35310
commit e56c4c10ed
11 changed files with 889 additions and 799 deletions

View File

@ -88,7 +88,6 @@ where
A: Read,
B: Read,
{
#[inline]
fn read(&mut self, buf: &mut [u8]) -> Result<usize, IoError> {
match self {
EitherOutput::First(a) => a.read(buf),
@ -102,7 +101,6 @@ where
A: AsyncWrite,
B: AsyncWrite,
{
#[inline]
fn shutdown(&mut self) -> Poll<(), IoError> {
match self {
EitherOutput::First(a) => a.shutdown(),
@ -116,7 +114,6 @@ where
A: Write,
B: Write,
{
#[inline]
fn write(&mut self, buf: &[u8]) -> Result<usize, IoError> {
match self {
EitherOutput::First(a) => a.write(buf),
@ -124,7 +121,6 @@ where
}
}
#[inline]
fn flush(&mut self) -> Result<(), IoError> {
match self {
EitherOutput::First(a) => a.flush(),
@ -302,7 +298,6 @@ where
type Item = ListenerEvent<EitherFuture<AInner, BInner>>;
type Error = EitherError<AStream::Error, BStream::Error>;
#[inline]
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
match self {
EitherListenStream::First(a) => a.poll()
@ -331,7 +326,6 @@ where
type Item = EitherOutput<AInner, BInner>;
type Error = EitherError<AFuture::Error, BFuture::Error>;
#[inline]
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match self {
EitherFuture::First(a) => a.poll().map(|v| v.map(EitherOutput::First)).map_err(EitherError::A),