mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Use only one regex for domain matching.
This commit is contained in:
parent
8755b0a76e
commit
567380d4aa
1 changed files with 2 additions and 3 deletions
|
@ -28,8 +28,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static!(
|
lazy_static!(
|
||||||
static ref RE: Regex = Regex::new(r"^[a-z\d\.-]*$").unwrap();
|
static ref RE_DOMAIN: Regex = Regex::new(r"^(?:[a-z\d\.-]*\.)?((?:[a-z\d-]*)\.(?:[a-z\d-]*))$").unwrap();
|
||||||
static ref RE_DOMAIN: Regex = Regex::new(r"(?:^[a-z\d\.-]*\.)?((?:[a-z\d-]*)\.(?:[a-z\d-]*))$").unwrap();
|
|
||||||
static ref RE_MANIFEST: Regex = Regex::new("(?m)URI=\"([^\"]+)\"").unwrap();
|
static ref RE_MANIFEST: Regex = Regex::new("(?m)URI=\"([^\"]+)\"").unwrap();
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
|
||||||
|
|
||||||
let host = res.unwrap();
|
let host = res.unwrap();
|
||||||
|
|
||||||
if !RE.is_match(host) || !RE_DOMAIN.is_match(host) {
|
if !RE_DOMAIN.is_match(host) {
|
||||||
return Err("Invalid host provided".into());
|
return Err("Invalid host provided".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue