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,
#[clap(short, long)]
pub sni: String,
pub sni: Option<String>,
#[clap(short, long)]
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?;
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 {
let (pt_stream, _) = match listener.accept().await {
Ok(s) => s,