mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-17 06:23:29 +02:00
Replace lazy_static crate with "new" std::sync::LazyLock
This commit is contained in:
@ -17,7 +17,6 @@ use axum_client_ip::SecureClientIp;
|
||||
use axum_extra::headers;
|
||||
use axum_extra::TypedHeader;
|
||||
use clap::Parser;
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize,Serialize};
|
||||
use tower::ServiceBuilder;
|
||||
@ -34,6 +33,7 @@ use tokio::task;
|
||||
use std::collections::HashMap;
|
||||
use std::net::IpAddr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use lib_humus::TemplateEngineLoader;
|
||||
use lib_humus::read_toml_from_file;
|
||||
@ -443,6 +443,8 @@ async fn handle_default_route(
|
||||
)
|
||||
}
|
||||
|
||||
static ASN_REGEX: LazyLock<Regex> = LazyLock::new(|| { Regex::new(r"^[Aa][Ss][Nn]?\s*(\d{1,7})$").unwrap() });
|
||||
static VIA_REGEX: LazyLock<Regex> = LazyLock::new(|| { Regex::new(r"[Vv][Ii][Aa]\s+(\S+)").unwrap() });
|
||||
|
||||
async fn handle_search_request(
|
||||
search_query: String,
|
||||
@ -455,11 +457,6 @@ async fn handle_search_request(
|
||||
let mut search_query = search_query.trim().to_string();
|
||||
let mut settings = settings;
|
||||
|
||||
lazy_static!{
|
||||
static ref ASN_REGEX: Regex = Regex::new(r"^[Aa][Ss][Nn]?\s*(\d{1,7})$").unwrap();
|
||||
static ref VIA_REGEX: Regex = Regex::new(r"[Vv][Ii][Aa]\s+(\S+)").unwrap();
|
||||
}
|
||||
|
||||
//If someone asked for an asn, give an asn answer
|
||||
if let Some(asn_cap) = ASN_REGEX.captures(&search_query) {
|
||||
if let Some(asn) = asn_cap.get(1).map_or(None, |m| m.as_str().parse::<u32>().ok()) {
|
||||
|
Reference in New Issue
Block a user