|
1 | 1 | use std::{error::Error, path::PathBuf, thread, time::Duration}; |
2 | 2 |
|
| 3 | +use base64::prelude::*; |
3 | 4 | use clap::{Args, Command, Parser, Subcommand, ValueHint, builder::TypedValueParser}; |
4 | 5 | use clap_complete::{Generator, Shell, generate}; |
5 | 6 | use color_eyre::Result; |
@@ -401,6 +402,20 @@ pub(crate) async fn cli_exec_command(command: Vec<String>) -> Result<()> { |
401 | 402 | // Call the asynchronous connect method using the runtime. |
402 | 403 | rt.block_on(async move { |
403 | 404 | let mut builder = IrohSsh::builder().accept_incoming(true).accept_port(22); |
| 405 | + if let Ok(secret) = std::env::var("COMAN_IROH_SECRET") { |
| 406 | + let secret_key = BASE64_STANDARD.decode(secret).unwrap(); |
| 407 | + let secret_key: &[u8; 32] = secret_key[0..32].try_into().unwrap(); |
| 408 | + builder = builder.secret_key(secret_key); |
| 409 | + //TODO: for this feature: |
| 410 | + // - upload an ssh key and template to the ssh hook |
| 411 | + // - upload coman squash and mount to container |
| 412 | + // - use coman as entrypoint for container command (also add -pty to start command) |
| 413 | + // - generate secret key on client, set as env var on container |
| 414 | + // - wait for connection to endpoint to be available? |
| 415 | + // - drop into a local shell once connection is established? |
| 416 | + // - add connection to ssh config so it can be picked up by vscode et al? |
| 417 | + } |
| 418 | + |
404 | 419 | let server = builder.build().await.expect("couldn't create iroh server"); |
405 | 420 | println!("{}@{}", whoami::username(), server.node_id()); |
406 | 421 | loop { |
|
0 commit comments