set default sni
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
5028eff519
commit
73ebf99243
1 changed files with 6 additions and 2 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue