diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 7608ee4..07c6625 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -313,7 +313,21 @@ fn build() { let pubkey_file = "target/public_keys.json"; if !std::path::Path::new(pubkey_file).exists() { - panic!("No public key file. Please generate keys first."); + println!("No public keys found at {pubkey_file}. Generating keys automatically..."); + + let sk_out = ".local/secrets.json"; + let num_keys = 100; + + println!("Creating .local directory..."); + std::fs::create_dir_all(".local").expect("failed to create .local directory"); + + println!("Generating {num_keys} keypairs..."); + println!(" Public keys -> {pubkey_file}"); + println!(" Secret keys -> {sk_out}"); + message_tools::gen_keys::generate_keys_to_file(pubkey_file, sk_out, num_keys) + .expect("failed to generate keys"); + + println!("Key generation complete."); } let status = Command::new("mkdir") diff --git a/crates/server/bin/main.rs b/crates/server/bin/main.rs index 4abbb7e..f4bf5a3 100644 --- a/crates/server/bin/main.rs +++ b/crates/server/bin/main.rs @@ -65,11 +65,13 @@ async fn main() -> Result<()> { .route("/who", get(serve_path("./routes/who/index.html")?)) .route("/api/pubkey", get(async || select_key(&PUBLIC_KEYS))) .route("/contact", get(serve_path("./routes/contact/index.html")?)) + .route("/contact/message", get(serve_path("./routes/contact/message/index.html")?)) .route("/api/publish", post(publish_message)) .nest_service("/routes", ServeDir::new("./routes")); - // run our app with hyper, listening globally on port 3000 - let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + let addr = "0.0.0.0:3000"; + let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); + println!("Server running at http://{addr}"); axum::serve(listener, app).await.unwrap(); Ok(()) diff --git a/routes/contact/index.html b/routes/contact/index.html index c2ab9e4..cc50bfa 100644 --- a/routes/contact/index.html +++ b/routes/contact/index.html @@ -3,247 +3,147 @@
-