More refactoring
This commit is contained in:
parent
e553b4da14
commit
fd7920d551
@ -1,7 +1,5 @@
|
||||
// Box<dyn AsyncWrite + Unpin + Send>, Box<dyn AsyncRead + Unpin + Send>
|
||||
|
||||
#[cfg(feature = "websocket")]
|
||||
use crate::websocket::{from_ws, to_ws_new, AsyncReadAndWrite};
|
||||
use crate::websocket::{from_ws, to_ws_new, WsRd, WsWr};
|
||||
use crate::{
|
||||
common::IN_BUFFER_SIZE,
|
||||
in_out::{StanzaRead::*, StanzaWrite::*},
|
||||
@ -10,19 +8,11 @@ use crate::{
|
||||
};
|
||||
use anyhow::{bail, Result};
|
||||
#[cfg(feature = "websocket")]
|
||||
use futures_util::{
|
||||
stream::{SplitSink, SplitStream},
|
||||
SinkExt, TryStreamExt,
|
||||
};
|
||||
use futures_util::{SinkExt, TryStreamExt};
|
||||
use log::trace;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, BufReader};
|
||||
#[cfg(feature = "websocket")]
|
||||
use tokio_tungstenite::{tungstenite::Message::*, WebSocketStream};
|
||||
|
||||
#[cfg(feature = "websocket")]
|
||||
type WsWr = SplitSink<WebSocketStream<Box<dyn AsyncReadAndWrite + Unpin + Send>>, tokio_tungstenite::tungstenite::Message>;
|
||||
#[cfg(feature = "websocket")]
|
||||
type WsRd = SplitStream<WebSocketStream<Box<dyn AsyncReadAndWrite + Unpin + Send>>>;
|
||||
use tokio_tungstenite::tungstenite::Message::{Close, Ping, Pong, Text};
|
||||
|
||||
pub enum StanzaWrite {
|
||||
AsyncWrite(Box<dyn AsyncWrite + Unpin + Send>),
|
||||
|
@ -1,7 +1,3 @@
|
||||
use anyhow::bail;
|
||||
use log::info;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub mod common;
|
||||
pub mod slicesubsequence;
|
||||
pub mod stanzafilter;
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::common::incoming::{shuffle_rd_wr_filter, CloneableConfig, ServerCerts};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use crate::{
|
||||
common::{first_bytes_match, to_str, IN_BUFFER_SIZE},
|
||||
@ -6,11 +7,10 @@ use crate::{
|
||||
in_out::{StanzaRead, StanzaWrite},
|
||||
slicesubsequence::SliceSubsequence,
|
||||
stanzafilter::{StanzaFilter, StanzaReader},
|
||||
*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use die::Die;
|
||||
use log::{error, trace};
|
||||
use log::{error, info, trace};
|
||||
use rustls::{ServerConfig, ServerConnection};
|
||||
|
||||
use std::sync::Arc;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use futures::StreamExt;
|
||||
|
||||
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
|
||||
use futures_util::stream::{SplitSink, SplitStream};
|
||||
use tokio_tungstenite::{tungstenite::protocol::WebSocketConfig, WebSocketStream};
|
||||
|
||||
#[cfg(feature = "incoming")]
|
||||
pub mod incoming;
|
||||
@ -9,6 +9,9 @@ pub mod incoming;
|
||||
#[cfg(feature = "outgoing")]
|
||||
pub mod outgoing;
|
||||
|
||||
pub type WsWr = SplitSink<WebSocketStream<Box<dyn AsyncReadAndWrite + Unpin + Send>>, tokio_tungstenite::tungstenite::Message>;
|
||||
pub type WsRd = SplitStream<WebSocketStream<Box<dyn AsyncReadAndWrite + Unpin + Send>>>;
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc7395
|
||||
|
||||
fn ws_cfg(max_stanza_size_bytes: usize) -> Option<WebSocketConfig> {
|
||||
|
Loading…
Reference in New Issue
Block a user