use bytesname trait to explicitly convert &str/string to ascii lower-cased byte names of server / path
This commit is contained in:
parent
4d590f328f
commit
7bd9040637
10 changed files with 49 additions and 46 deletions
|
|
@ -1,7 +1,10 @@
|
|||
mod upstream;
|
||||
mod upstream_opts;
|
||||
|
||||
use crate::log::*;
|
||||
use crate::{
|
||||
log::*,
|
||||
utils::{BytesName, PathNameBytesExp, ServerNameBytesExp},
|
||||
};
|
||||
use rustc_hash::FxHashMap as HashMap;
|
||||
use std::{
|
||||
fs::File,
|
||||
|
|
@ -17,11 +20,6 @@ use tokio_rustls::rustls::{
|
|||
pub use upstream::{ReverseProxy, Upstream, UpstreamGroup};
|
||||
pub use upstream_opts::UpstreamOption;
|
||||
|
||||
// Server name (hostname or ip address) and path name representation in backends
|
||||
// For searching hashmap or key list by exact or longest-prefix matching
|
||||
pub type ServerNameBytesExp = Vec<u8>; // lowercase ascii bytes
|
||||
pub type PathNameBytesExp = Vec<u8>; // lowercase ascii bytes
|
||||
|
||||
/// Struct serving information to route incoming connections, like server name to be handled and tls certs/keys settings.
|
||||
pub struct Backend {
|
||||
pub app_name: String,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{PathNameBytesExp, UpstreamOption};
|
||||
use super::{BytesName, PathNameBytesExp, UpstreamOption};
|
||||
use crate::log::*;
|
||||
use rand::Rng;
|
||||
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
|
||||
|
|
@ -19,8 +19,7 @@ impl ReverseProxy {
|
|||
pub fn get<'a>(&self, path_str: impl Into<Cow<'a, str>>) -> Option<&UpstreamGroup> {
|
||||
// trie使ってlongest prefix match させてもいいけどルート記述は少ないと思われるので、
|
||||
// コスト的にこの程度で十分
|
||||
let path_lc = path_str.into().to_ascii_lowercase();
|
||||
let path_bytes = path_lc.as_bytes();
|
||||
let path_bytes = &(path_str.to_path_name_vec())[..];
|
||||
|
||||
let matched_upstream = self
|
||||
.upstream
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue