Skip to content

Commit

Permalink
reduce memory usage when loading multiple duplicated ca/cert/key
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Apr 18, 2022
1 parent 409f113 commit c76dff0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kaminari/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kaminari"
version = "0.5.5"
version = "0.5.6"
edition = "2021"
authors = ["zephyr <[email protected]>"]
keywords = ["lightws", "network"]
Expand Down
27 changes: 27 additions & 0 deletions kaminari/src/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ impl MixConnect {
(Some(ws), Some(tls)) => Wss(WsConnect::new(TlsConnect::new(NopConnect {}, tls), ws)),
}
}

pub fn new_shared(conf: MixClientConf) -> Self {
use MixConnect::*;
let MixClientConf { ws, tls } = conf;
match (ws, tls) {
(None, None) => Plain(NopConnect {}),
(Some(ws), None) => Ws(WsConnect::new(NopConnect {}, ws)),
(None, Some(tls)) => Tls(TlsConnect::new_shared(NopConnect {}, tls)),
(Some(ws), Some(tls)) => Wss(WsConnect::new(
TlsConnect::new_shared(NopConnect {}, tls),
ws,
)),
}
}
}

impl<S: IOStream> AsyncConnect<S> for MixConnect {
Expand Down Expand Up @@ -80,6 +94,19 @@ impl MixAccept {
(Some(ws), Some(tls)) => Wss(WsAccept::new(TlsAccept::new(NopAccept {}, tls), ws)),
}
}

pub fn new_shared(conf: MixServerConf) -> Self {
use MixAccept::*;
let MixServerConf { ws, tls } = conf;
match (ws, tls) {
(None, None) => Plain(NopAccept {}),
(Some(ws), None) => Ws(WsAccept::new(NopAccept {}, ws)),
(None, Some(tls)) => Tls(TlsAccept::new_shared(NopAccept {}, tls)),
(Some(ws), Some(tls)) => {
Wss(WsAccept::new(TlsAccept::new_shared(NopAccept {}, tls), ws))
}
}
}
}

impl<S: IOStream> AsyncAccept<S> for MixAccept {
Expand Down

0 comments on commit c76dff0

Please sign in to comment.