feat: (tcp) proxy

This commit is contained in:
Mikaël Cluseau
2025-12-19 21:33:17 +01:00
parent 7acc9e9a3e
commit fb3f8942d4
5 changed files with 253 additions and 112 deletions

View File

@@ -1,6 +1,8 @@
use clap::{CommandFactory, Parser, Subcommand};
use eyre::{format_err, Result};
use log::{debug, error};
use std::net::SocketAddr;
use std::time::Duration;
use tokio::fs;
#[derive(Parser)]
@@ -65,6 +67,17 @@ enum Command {
#[arg(long, default_value = "/")]
chroot: std::path::PathBuf,
},
Proxy {
#[arg(long, short = 'l')]
listen: Vec<SocketAddr>,
targets: Vec<SocketAddr>,
/// target polling interval, in seconds
#[arg(long, default_value = "30")]
poll: u16,
/// connect or check timeout, in seconds
#[arg(long, default_value = "5")]
timeout: u16,
},
}
#[tokio::main(flavor = "current_thread")]
@@ -126,6 +139,20 @@ async fn main() -> Result<()> {
.install(layer, version)
.await
}
C::Proxy {
listen,
targets,
poll,
timeout,
} => Ok(dkl::proxy::Proxy {
listen_addrs: listen,
targets,
poll: Duration::from_secs(poll.into()),
timeout: Duration::from_secs(timeout.into()),
}
.run()
.await
.map(|_| ())?),
}
}