Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements try_join for running multiple async #131

Merged
merged 2 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ version = "0.1.0"
[dependencies]
base64 = "0.9.3"
flate2 = "1.0.4"
futures = "0.1.24"
futures = "0.3.6"
hex = "0.3.2"
hyper = "0.13"
tokio = { version = "0.2", features = ["full"] }
libc = "0.2.43"
log = "0.4"
openssl = "0.10.15"
Expand All @@ -21,5 +20,6 @@ serde = "1.0.80"
serde_derive = "1.0.80"
serde_json = "1.0"
tempfile = "3.0.4"
tokio = {version = "0.2", features = ["full"]}
tokio-io = "0.1"
tss-esapi = "4.0.9-alpha.1"
4 changes: 3 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub(crate) enum Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::Ini(err) => write!(f, "Error loading configuration: {}", err),
Error::Ini(err) => {
write!(f, "Error loading configuration: {}", err)
}
Error::TPM(err) => write!(f, "TPM Error encountered: {}", err),
anything => write!(f, "Another error: {:?}", anything),
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::collections::HashMap;
use error::{Error, Result};

pub(crate) async fn response_function(
req: Request<Body>)
-> Result<Response<Body>> {
req: Request<Body>,
) -> Result<Response<Body>> {
let mut my_response: Response<Body> =
Response::new("Nothing here.".into());

Expand Down
17 changes: 15 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use log::*;

#[macro_use]
use futures::try_join;
use hyper;
use ini;
use pretty_env_logger;
Expand Down Expand Up @@ -44,6 +45,16 @@ async fn run() -> Result<()> {
// Get a context to work with the TPM
let mut ctx = tpm::get_tpm2_ctx()?;

// queue up future events
let server = runWebServer();
let revoker = runRevocationService();

// run future events
try_join!(server, revoker)?;
Ok(())
}

async fn runWebServer() -> Result<()> {
let cloudagent_ip =
config_get("/etc/keylime.conf", "cloud_agent", "cloudagent_ip")?;
let cloudagent_port =
Expand All @@ -61,10 +72,12 @@ async fn run() -> Result<()> {

info!("Listening on http://{}", addr);

// run server forever
//hyper::rt::run(server);
server.await?;
Ok(())
}

async fn runRevocationService() -> Result<()> {
// revoker.await?;
Ok(())
}

Expand Down