feat: (tcp) proxy
This commit is contained in:
@@ -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(|_| ())?),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user