Update deps and remove nightly dependency

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2025-02-22 21:08:22 -06:00
parent 46456b0a61
commit 55339e6577
No known key found for this signature in database
5 changed files with 284 additions and 241 deletions

476
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ tls = ["axum-server/tls-rustls", "axum-server/rustls-pemfile", "axum-server/toki
[dependencies]
async-trait = "0.1.83"
axum-server = "0.7"
axum = "0.7"
axum = "0.8"
chrono = { version = "0.4.38", features = ["serde"] }
clap = { version = "4.5.20", features = ["derive"], optional = true }
dashmap = "6.1.0"

View file

@ -1,5 +1,4 @@
use axum::response::IntoResponse;
use serde_json::Value;
use crate::{delegate, evaluate::Disposition, APRequestInfo, Evaluator, HasAppState};

View file

@ -1,6 +1,4 @@
#![doc = include_str!("../README.md")]
#![feature(ip)]
#![feature(async_closure)]
#![warn(clippy::unwrap_used, clippy::expect_used)]
#![warn(unsafe_code)]
#![warn(missing_docs)]

View file

@ -22,6 +22,44 @@ impl<A: IntoResponse, B: IntoResponse> IntoResponse for Either<A, B> {
pub(crate) mod stream;
// pulled from https://doc.rust-lang.org/src/core/net/ip_addr.rs.html#1650
const fn is_unicast_local_v6(ip: &std::net::Ipv6Addr) -> bool {
(ip.segments()[0] & 0xfe00) == 0xfc00
}
const fn is_unicast_link_local_v6(ip: &std::net::Ipv6Addr) -> bool {
(ip.segments()[0] & 0xffc0) == 0xfe80
}
#[must_use]
pub const fn public_addressable(ip: IpAddr) -> Option<IpAddr> {
match ip {
IpAddr::V4(ip) => {
if !ip.is_loopback()
&& !ip.is_private()
&& !ip.is_link_local()
&& !ip.is_multicast()
&& !ip.is_documentation()
&& !ip.is_unspecified()
{
return Some(IpAddr::V4(ip));
}
}
IpAddr::V6(ip) => {
if !ip.is_loopback()
&& !ip.is_multicast()
&& !ip.is_unspecified()
&& !is_unicast_local_v6(&ip)
&& !is_unicast_link_local_v6(&ip)
{
return Some(IpAddr::V6(ip));
}
}
}
None
}
/// A Safe DNS resolver that only resolves to global addresses unless the requester itself is local.
pub struct SafeResolver(IpAddr);
@ -35,9 +73,9 @@ impl Resolve for SafeResolver {
Ok(Box::new(lookup)
as Box<dyn Iterator<Item = std::net::SocketAddr> + Send>)
} else {
Ok(Box::new(lookup.filter(|addr| match addr {
std::net::SocketAddr::V4(a) => a.ip().is_global(),
std::net::SocketAddr::V6(a) => a.ip().is_global(),
Ok(Box::new(lookup.filter_map(|addr| {
public_addressable(addr.ip())
.map(|ip| std::net::SocketAddr::new(ip, addr.port()))
}))
as Box<dyn Iterator<Item = std::net::SocketAddr> + Send>)
}