set default sni

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-03 01:51:47 -05:00
parent 5028eff519
commit 73ebf99243
No known key found for this signature in database

View file

@ -66,7 +66,7 @@ pub struct ForwardProxyCommand {
pub listen: String, pub listen: String,
#[clap(short, long)] #[clap(short, long)]
pub sni: String, pub sni: Option<String>,
#[clap(short, long)] #[clap(short, long)]
pub target: String, pub target: String,
@ -328,7 +328,11 @@ pub async fn forward_proxy(opts: ForwardProxyCommand) -> Result<(), Box<dyn std:
let listener = tokio::net::TcpListener::bind(&opts.listen).await?; let listener = tokio::net::TcpListener::bind(&opts.listen).await?;
log::info!("Listening on: {}", opts.listen); log::info!("Listening on: {}", opts.listen);
let sni = ServerName::try_from(opts.sni.as_str()).expect("Failed to parse SNI"); let sni = ServerName::try_from(match opts.sni {
Some(ref s) => s.as_str(),
None => opts.target.as_str(),
})
.expect("Failed to parse SNI");
loop { loop {
let (pt_stream, _) = match listener.accept().await { let (pt_stream, _) = match listener.accept().await {
Ok(s) => s, Ok(s) => s,