Implemented AutoTLS via RustTLS
This commit is contained in:
@@ -8,10 +8,10 @@ use std::sync::Arc;
|
||||
use furumi_client_core::FurumiClient;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
#[command(version, about = "Furumi-ng: mount remote filesystem via encrypted gRPC + FUSE")]
|
||||
struct Args {
|
||||
/// Server address to connect to
|
||||
#[arg(short, long, env = "FURUMI_SERVER", default_value = "http://[::1]:50051")]
|
||||
/// Server address to connect to (use https:// for encrypted connection)
|
||||
#[arg(short, long, env = "FURUMI_SERVER", default_value = "https://0.0.0.0:50051")]
|
||||
server: String,
|
||||
|
||||
/// Authentication Bearer token (leave empty if auth is disabled on server)
|
||||
@@ -21,6 +21,10 @@ struct Args {
|
||||
/// Mount point directory
|
||||
#[arg(short, long, env = "FURUMI_MOUNT")]
|
||||
mount: PathBuf,
|
||||
|
||||
/// Path to server's TLS CA certificate PEM file (required for https:// connections)
|
||||
#[arg(long, env = "FURUMI_TLS_CA")]
|
||||
tls_ca: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -32,6 +36,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
eprintln!("Error: Mount point {:?} does not exist or is not a directory", args.mount);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// Load TLS CA certificate if provided
|
||||
let tls_ca_pem = if let Some(ref ca_path) = args.tls_ca {
|
||||
let pem = std::fs::read(ca_path).unwrap_or_else(|e| {
|
||||
eprintln!("Error: Failed to read TLS CA cert {:?}: {}", ca_path, e);
|
||||
std::process::exit(1);
|
||||
});
|
||||
Some(pem)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Create a robust tokio runtime for the background gRPC work
|
||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||
@@ -39,7 +54,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.build()?;
|
||||
|
||||
let client = rt.block_on(async {
|
||||
FurumiClient::connect(&args.server, &args.token).await
|
||||
FurumiClient::connect(&args.server, &args.token, tls_ca_pem).await
|
||||
})?;
|
||||
|
||||
let fuse_fs = fs::FurumiFuse::new(client, rt.handle().clone());
|
||||
|
||||
Reference in New Issue
Block a user