Skip to content

Commit

Permalink
Merge pull request #230 from c410-f3r/misc
Browse files Browse the repository at this point in the history
Update RNG
  • Loading branch information
c410-f3r authored Sep 23, 2024
2 parents 8df918b + 926fcfc commit 5879ce6
Show file tree
Hide file tree
Showing 40 changed files with 468 additions and 397 deletions.
2 changes: 1 addition & 1 deletion .scripts/internal-tests-0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $rt test-with-features wtx pool
$rt test-with-features wtx postgres
$rt test-with-features wtx proptest
$rt test-with-features wtx quick-protobuf
$rt test-with-features wtx rand
$rt test-with-features wtx rand_chacha
$rt test-with-features wtx ring
$rt test-with-features wtx rust_decimal
$rt test-with-features wtx schema-manager
Expand Down
53 changes: 28 additions & 25 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions wtx-fuzz/web_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

use tokio::runtime::Builder;
use wtx::{
misc::{BytesStream, NoStdRng},
misc::{simple_seed, BytesStream, Xorshift64},
web_socket::{FrameBufferVec, FrameMutVec, OpCode, WebSocketBuffer, WebSocketServerOwned},
};

libfuzzer_sys::fuzz_target!(|data: (OpCode, &[u8])| {
Builder::new_current_thread().enable_all().build().unwrap().block_on(async move {
let Ok(mut ws) = WebSocketServerOwned::new(
(),
NoStdRng::default(),
Xorshift64::from(simple_seed()),
BytesStream::default(),
WebSocketBuffer::default(),
) else {
Expand Down
2 changes: 2 additions & 0 deletions wtx-instances/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ pb-rs = { default-features = false, version = "0.10" }
[dependencies]
argon2 = { default-features = false, version = "0.5" }
quick-protobuf = { default-features = false, version = "0.8" }
rand_chacha = { default-features = false, version = "0.3" }
rand_core = { default-features = false, feature = ["getrandom"], version = "0.6" }
serde = { default-features = false, version = "1.0" }
serde_json = { default-features = false, features = ["alloc"], version = "1.0" }
tokio = { default-features = false, features = ["macros", "rt-multi-thread"], version = "1.0" }
Expand Down
6 changes: 3 additions & 3 deletions wtx-instances/generic-examples/client-api-framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use wtx::{
},
data_transformation::dnsn::SerdeJson,
http::client_framework::ClientFrameworkTokio,
misc::{NoStdRng, Uri},
misc::{simple_seed, Uri, Xorshift64},
web_socket::{FrameBufferVec, HeadersBuffer, WebSocketBuffer, WebSocketClient},
};

Expand Down Expand Up @@ -97,7 +97,7 @@ async fn http_pair(
async fn web_socket_pair() -> wtx::Result<
Pair<
PkgsAux<GenericThrottlingApi, SerdeJson, WsParams>,
(FrameBufferVec, WebSocketClient<(), NoStdRng, TcpStream, WebSocketBuffer>),
(FrameBufferVec, WebSocketClient<(), Xorshift64, TcpStream, WebSocketBuffer>),
>,
> {
let mut fb = FrameBufferVec::default();
Expand All @@ -107,7 +107,7 @@ async fn web_socket_pair() -> wtx::Result<
&mut fb,
[],
&mut HeadersBuffer::default(),
NoStdRng::default(),
Xorshift64::from(simple_seed()),
TcpStream::connect(uri.hostname_with_implied_port()).await?,
&uri,
WebSocketBuffer::default(),
Expand Down
2 changes: 2 additions & 0 deletions wtx-instances/generic-examples/grpc-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use wtx::{
server_framework::{post, Router, ServerFrameworkBuilder, State},
ReqResBuffer, StatusCode,
},
misc::{simple_seed, Xorshift64},
};
use wtx_instances::grpc_bindings::wtx::{GenericRequest, GenericResponse};

Expand All @@ -28,6 +29,7 @@ async fn main() -> wtx::Result<()> {
.listen_tls(
(wtx_instances::CERT, wtx_instances::KEY),
&wtx_instances::host_from_args(),
Xorshift64::from(simple_seed()),
|error| eprintln!("{error}"),
)
.await
Expand Down
4 changes: 2 additions & 2 deletions wtx-instances/generic-examples/http2-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ use tokio::net::TcpStream;
use wtx::{
http::{Method, ReqResBuffer, Request},
http2::{Http2Buffer, Http2ErrorCode, Http2Params, Http2Tokio},
misc::{from_utf8_basic, NoStdRng, Uri},
misc::{from_utf8_basic, simple_seed, Uri, Xorshift64},
};

#[tokio::main]
async fn main() -> wtx::Result<()> {
let uri = Uri::new("http://www.example.com");
let (frame_reader, mut http2) = Http2Tokio::connect(
Http2Buffer::new(NoStdRng::default()),
Http2Buffer::new(Xorshift64::from(simple_seed())),
Http2Params::default(),
TcpStream::connect(uri.hostname_with_implied_port()).await?.into_split(),
)
Expand Down
4 changes: 2 additions & 2 deletions wtx-instances/generic-examples/http2-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ extern crate wtx_instances;
use wtx::{
http::{LowLevelServer, ReqResBuffer, Request, Response, StatusCode},
http2::{Http2Buffer, Http2Params},
misc::{StdRng, TokioRustlsAcceptor},
misc::{simple_seed, TokioRustlsAcceptor, Xorshift64},
};

#[tokio::main]
async fn main() -> wtx::Result<()> {
LowLevelServer::tokio_http2(
&wtx_instances::host_from_args(),
|| Ok(((), Http2Buffer::new(StdRng::default()), Http2Params::default())),
|| Ok(((), Http2Buffer::new(Xorshift64::from(simple_seed())), Http2Params::default())),
|error| eprintln!("{error}"),
handle,
|| Ok(((), ReqResBuffer::empty())),
Expand Down
4 changes: 2 additions & 2 deletions wtx-instances/generic-examples/web-socket-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tokio::{
net::TcpStream,
};
use wtx::{
misc::{StdRng, Uri},
misc::{simple_seed, Uri, Xorshift64},
web_socket::{
FrameBufferVec, FrameMutVec, HeadersBuffer, OpCode, WebSocketBuffer, WebSocketClient,
},
Expand All @@ -27,7 +27,7 @@ async fn main() -> wtx::Result<()> {
fb,
[],
&mut HeadersBuffer::default(),
StdRng::default(),
Xorshift64::from(simple_seed()),
TcpStream::connect(uri.hostname_with_implied_port()).await?,
&uri.to_ref(),
WebSocketBuffer::default(),
Expand Down
4 changes: 2 additions & 2 deletions wtx-instances/generic-examples/web-socket-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::net::TcpStream;
use tokio_rustls::server::TlsStream;
use wtx::{
http::LowLevelServer,
misc::{StdRng, TokioRustlsAcceptor},
misc::{TokioRustlsAcceptor, Xorshift64},
web_socket::{FrameBufferVec, OpCode, WebSocketBuffer, WebSocketServer},
};

Expand All @@ -35,7 +35,7 @@ async fn main() -> wtx::Result<()> {

async fn handle(
fb: &mut FrameBufferVec,
mut ws: WebSocketServer<(), StdRng, TlsStream<TcpStream>, &mut WebSocketBuffer>,
mut ws: WebSocketServer<(), Xorshift64, TlsStream<TcpStream>, &mut WebSocketBuffer>,
) -> wtx::Result<()> {
loop {
let mut frame = ws.read_frame(fb).await?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
//! The `CorsMiddleware` middleware inserts permissive CORS headers in every response.
use wtx::http::server_framework::{get, CorsMiddleware, Router, ServerFrameworkBuilder};
use wtx::{
http::server_framework::{get, CorsMiddleware, Router, ServerFrameworkBuilder},
misc::{simple_seed, Xorshift64},
};

#[tokio::main]
async fn main() -> wtx::Result<()> {
let router = Router::new(wtx::paths!(("/hello", get(hello))), (), CorsMiddleware::permissive())?;
ServerFrameworkBuilder::new(router)
.without_aux()
.listen("0.0.0.0:9000", |error: wtx::Error| eprintln!("{error:?}"))
.listen("0.0.0.0:9000", Xorshift64::from(simple_seed()), |error: wtx::Error| {
eprintln!("{error:?}")
})
.await?;
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! Different types of redirects.
use wtx::http::{
server_framework::{get, Redirect, Router, ServerFrameworkBuilder, StateClean},
ReqResBuffer, StatusCode,
use wtx::{
http::{
server_framework::{get, Redirect, Router, ServerFrameworkBuilder, StateClean},
ReqResBuffer, StatusCode,
},
misc::{simple_seed, Xorshift64},
};

#[tokio::main]
Expand All @@ -11,7 +14,9 @@ async fn main() -> wtx::Result<()> {
Router::paths(wtx::paths!(("/permanent", get(permanent)), ("/temporary", get(temporary))))?;
ServerFrameworkBuilder::new(router)
.without_aux()
.listen(&wtx_instances::host_from_args(), |error| eprintln!("{error}"))
.listen(&wtx_instances::host_from_args(), Xorshift64::from(simple_seed()), |error| {
eprintln!("{error}")
})
.await
}

Expand Down
Loading

0 comments on commit 5879ce6

Please sign in to comment.