-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a server mode to gel-stream (#8282)
This adds a server mode to `gel-stream`, gated on a feature. We wrap up a significant amount of network and TLS complexity behind two simple concepts: the `Connector` and the `Acceptor`. OpenSSL and Rustls are supported for both client and server modes. Tests were added to ensure that they work with all combinations (which also shook out some additional bugs). In addition, synchronous lookup of TLS parameters by SNI is supported -- async lookup will probably be necessary in the future but is currently not implemented yet. In addition, `tests/certs` were regenerated as one of the certs wasn't v3, so rustls didn't like it. Note that client-side certificate validation is implemented, but there is no current way to read the accepted certificate on the server side. This will be added in a later patch. Accept and connect have similar APIs. Both also have TLS override forms where keys, verification modes and more may be specified. ``` let mut acceptor = Acceptor::new_tcp(SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 0)) .bind() .await?; let addr = acceptor.local_address()?; let accept_task = tokio::spawn(async move { let mut connection = acceptor.next().await.unwrap().unwrap(); let mut buf = String::new(); connection.read_to_string(&mut buf).await.unwrap(); assert_eq!(buf, "Hello, world!"); }); let connect_task = tokio::spawn(async move { let target = Target::new_resolved(addr); let mut stm = Connector::new(target).unwrap().connect().await.unwrap(); stm.write_all(b"Hello, world!").await?; Ok::<_, std::io::Error>(()) }); ```
- Loading branch information
Showing
43 changed files
with
2,922 additions
and
1,782 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.