Rename Proxy::default to ::default_action
Signed-off-by: Jacob Kiers <code@kiers.eu>
This commit is contained in:
parent
01784ee3fd
commit
0c5153bbd6
@ -21,7 +21,7 @@ pub struct Proxy {
|
|||||||
pub protocol: String,
|
pub protocol: String,
|
||||||
pub tls: bool,
|
pub tls: bool,
|
||||||
pub sni: Option<HashMap<String, String>>,
|
pub sni: Option<HashMap<String, String>>,
|
||||||
pub default: String,
|
pub default_action: String,
|
||||||
pub upstream: HashMap<String, Upstream>,
|
pub upstream: HashMap<String, Upstream>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ impl Server {
|
|||||||
protocol: protocol.clone(),
|
protocol: protocol.clone(),
|
||||||
tls,
|
tls,
|
||||||
sni: sni.clone(),
|
sni: sni.clone(),
|
||||||
default: default.clone(),
|
default_action: default.clone(),
|
||||||
upstream: upstream.clone(),
|
upstream: upstream.clone(),
|
||||||
};
|
};
|
||||||
new_server.proxies.push(Arc::new(proxy));
|
new_server.proxies.push(Arc::new(proxy));
|
||||||
|
@ -37,17 +37,17 @@ async fn accept(inbound: TcpStream, proxy: Arc<Proxy>) -> Result<(), Box<dyn std
|
|||||||
info!("New connection from {:?}", inbound.peer_addr()?);
|
info!("New connection from {:?}", inbound.peer_addr()?);
|
||||||
|
|
||||||
let upstream_name = match proxy.tls {
|
let upstream_name = match proxy.tls {
|
||||||
false => proxy.default.clone(),
|
false => proxy.default_action.clone(),
|
||||||
true => {
|
true => {
|
||||||
let mut hello_buf = [0u8; 1024];
|
let mut hello_buf = [0u8; 1024];
|
||||||
inbound.peek(&mut hello_buf).await?;
|
inbound.peek(&mut hello_buf).await?;
|
||||||
let snis = get_sni(&hello_buf);
|
let snis = get_sni(&hello_buf);
|
||||||
if snis.is_empty() {
|
if snis.is_empty() {
|
||||||
proxy.default.clone()
|
proxy.default_action.clone()
|
||||||
} else {
|
} else {
|
||||||
match proxy.sni.clone() {
|
match proxy.sni.clone() {
|
||||||
Some(sni_map) => {
|
Some(sni_map) => {
|
||||||
let mut upstream = proxy.default.clone();
|
let mut upstream = proxy.default_action.clone();
|
||||||
for sni in snis {
|
for sni in snis {
|
||||||
let m = sni_map.get(&sni);
|
let m = sni_map.get(&sni);
|
||||||
if m.is_some() {
|
if m.is_some() {
|
||||||
@ -57,7 +57,7 @@ async fn accept(inbound: TcpStream, proxy: Arc<Proxy>) -> Result<(), Box<dyn std
|
|||||||
}
|
}
|
||||||
upstream
|
upstream
|
||||||
}
|
}
|
||||||
None => proxy.default.clone(),
|
None => proxy.default_action.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,9 +70,13 @@ async fn accept(inbound: TcpStream, proxy: Arc<Proxy>) -> Result<(), Box<dyn std
|
|||||||
None => {
|
None => {
|
||||||
warn!(
|
warn!(
|
||||||
"No upstream named {:?} on server {:?}",
|
"No upstream named {:?} on server {:?}",
|
||||||
proxy.default, proxy.name
|
proxy.default_action, proxy.name
|
||||||
);
|
);
|
||||||
return process(inbound, proxy.upstream.get(&proxy.default).unwrap().clone()).await;
|
return process(
|
||||||
|
inbound,
|
||||||
|
proxy.upstream.get(&proxy.default_action).unwrap().clone(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
// ToDo: Remove unwrap and check default option
|
// ToDo: Remove unwrap and check default option
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user