mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-16 22:13:30 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
51877fc4c3 | |||
396bbdb348 | |||
a582c74d18 | |||
e8a21ac95f | |||
d706e7c614 | |||
0bffa0fd96 | |||
fb0ce1dc0b | |||
a67631fa9b | |||
636e10f786 | |||
0076db531a |
867
Cargo.lock
generated
867
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
25
Cargo.toml
25
Cargo.toml
@ -1,30 +1,31 @@
|
||||
[package]
|
||||
name = "echoip-slatecave"
|
||||
version = "1.2.0"
|
||||
version = "1.2.3"
|
||||
edition = "2021"
|
||||
authors = ["Slatian <baschdel@disroot.org>"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
lib-humus = { version="0.1", features=["axum-view+cookie"], git="https://codeberg.org/slatian/lib-humus.git" }
|
||||
lib-humus = { version="0.2", features=["axum-view+cookie"], git="https://codeberg.org/slatian/lib-humus.git" }
|
||||
|
||||
axum = { version = "0.6", features = ["macros", "headers"] }
|
||||
axum-extra = { version = "0.7", features = ["cookie"] }
|
||||
axum-client-ip = "0.4"
|
||||
axum = { version = "0.7", features = ["macros"] }
|
||||
axum-extra = { version = "0.9", features = ["cookie", "typed-header"] }
|
||||
axum-client-ip = "0.5"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
governor = "0.5"
|
||||
idna = "0.3"
|
||||
governor = "0.6"
|
||||
idna = "0.4"
|
||||
lazy_static = "1.4.0"
|
||||
parking_lot = "0.12"
|
||||
regex = "1.7"
|
||||
regex = "1.10"
|
||||
serde = { version = "1", features = ["derive","rc"] }
|
||||
tokio = { version = "1", features = ["macros","signal"] }
|
||||
tera = "1"
|
||||
toml = "0.7"
|
||||
toml = "0.8"
|
||||
tower = "0.4"
|
||||
tower-http = { version = "0.4", features = ["fs"] }
|
||||
trust-dns-proto = "0.22"
|
||||
trust-dns-resolver = { version = "0.22", features = ["dns-over-rustls","dns-over-https","dns-over-quic"] }
|
||||
tower-http = { version = "0.5", features = ["fs"] }
|
||||
trust-dns-proto = "0.23"
|
||||
trust-dns-resolver = { version = "0.23", features = ["dns-over-rustls","dns-over-https","dns-over-quic"] }
|
||||
maxminddb = "0.23"
|
||||
mime = "0.3"
|
||||
http = "1.0"
|
||||
|
@ -43,8 +43,8 @@ pub struct DnsResolverConfig {
|
||||
pub tls_dns_name: Option<Arc<str>>,
|
||||
#[serde(skip_serializing)] //Don't leak our bind address to the outside
|
||||
pub bind_address: Option<SocketAddr>,
|
||||
#[serde(default="default_true")]
|
||||
pub trust_nx_responses: bool,
|
||||
#[serde(default="default_true", alias="trust_nx_responses")]
|
||||
pub trust_negative_responses: bool,
|
||||
}
|
||||
|
||||
fn zero() -> i32 {
|
||||
@ -93,7 +93,7 @@ impl DnsResolverConfig {
|
||||
socket_addr: *server,
|
||||
protocol: self.protocol.clone().into(),
|
||||
tls_dns_name: self.tls_dns_name.clone().map(|s| s.to_string()),
|
||||
trust_nx_responses: self.trust_nx_responses,
|
||||
trust_negative_responses: self.trust_negative_responses,
|
||||
tls_config: None,
|
||||
bind_addr: self.bind_address,
|
||||
});
|
||||
|
39
src/main.rs
39
src/main.rs
@ -1,20 +1,21 @@
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::{
|
||||
self,
|
||||
Query,
|
||||
State,
|
||||
Extension,
|
||||
},
|
||||
headers,
|
||||
http::Request,
|
||||
handler::Handler,
|
||||
http::Request,
|
||||
middleware::{self, Next},
|
||||
response::Response,
|
||||
Router,
|
||||
routing::get,
|
||||
TypedHeader,
|
||||
};
|
||||
use axum_client_ip::SecureClientIp;
|
||||
use axum_extra::headers;
|
||||
use axum_extra::TypedHeader;
|
||||
use clap::Parser;
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
@ -228,7 +229,7 @@ async fn main() {
|
||||
let resolver = TokioAsyncResolver::tokio(
|
||||
resolver_config.to_trust_resolver_config(),
|
||||
Default::default()
|
||||
).unwrap();
|
||||
);
|
||||
dns_resolver_map.insert(key.clone(), resolver);
|
||||
dns_resolver_selectables.push(Selectable {
|
||||
id: key.clone(),
|
||||
@ -311,21 +312,21 @@ async fn main() {
|
||||
|
||||
println!("Starting Server on {} ...",listen_on);
|
||||
|
||||
axum::Server::bind(&listen_on)
|
||||
.serve(app.into_make_service_with_connect_info::<std::net::SocketAddr>())
|
||||
let listener = tokio::net::TcpListener::bind(&listen_on).await.unwrap();
|
||||
axum::serve(listener, app.into_make_service_with_connect_info::<std::net::SocketAddr>())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
||||
async fn settings_query_middleware<B>(
|
||||
async fn settings_query_middleware(
|
||||
Query(query): Query<SettingsQuery>,
|
||||
Extension(config): Extension<config::EchoIpServiceConfig>,
|
||||
Extension(derived_config): Extension<DerivedConfiguration>,
|
||||
cookie_header: Option<TypedHeader<headers::Cookie>>,
|
||||
user_agent_header: Option<TypedHeader<headers::UserAgent>>,
|
||||
mut req: Request<B>,
|
||||
next: Next<B>
|
||||
mut req: Request<Body>,
|
||||
next: Next
|
||||
) -> Response {
|
||||
let mut format = query.format;
|
||||
let mut dns_resolver_id = derived_config.default_resolver;
|
||||
@ -369,7 +370,7 @@ async fn not_found_handler(
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::NotFound,
|
||||
).await
|
||||
)
|
||||
}
|
||||
|
||||
async fn hello_world_handler(
|
||||
@ -382,9 +383,9 @@ async fn hello_world_handler(
|
||||
&settings,
|
||||
View::Message{
|
||||
title: "Hey There!".to_string(),
|
||||
message: "You,You are an awesome Creature!".to_string()
|
||||
message: "You are an awesome Creature!".to_string()
|
||||
},
|
||||
).await
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -428,7 +429,7 @@ async fn handle_default_route(
|
||||
result: result,
|
||||
user_agent: user_agent,
|
||||
}
|
||||
).await
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -455,7 +456,7 @@ async fn handle_search_request(
|
||||
return state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::Asn{asn: asn},
|
||||
).await
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,7 +495,7 @@ async fn handle_dns_resolver_route(
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::DnsResolverList,
|
||||
).await
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -508,12 +509,12 @@ async fn handle_dns_resolver_route_with_path(
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::DnsResolver{ config: resolver.clone() },
|
||||
).await
|
||||
)
|
||||
} else {
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::NotFound,
|
||||
).await
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -545,7 +546,7 @@ async fn handle_ip_request(
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::Ip{result: result}
|
||||
).await
|
||||
)
|
||||
}
|
||||
|
||||
async fn get_ip_result(
|
||||
@ -634,7 +635,7 @@ async fn handle_dig_request(
|
||||
state.templating_engine.render_view(
|
||||
&settings,
|
||||
View::Dig{ query: dig_query, result: dig_result}
|
||||
).await
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
use axum_client_ip::SecureClientIp;
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::Extension,
|
||||
http::{
|
||||
Request,
|
||||
@ -40,11 +41,11 @@ pub fn build_rate_limiting_state(
|
||||
Extension(arc_limiter)
|
||||
}
|
||||
|
||||
pub async fn rate_limit_middleware<B>(
|
||||
pub async fn rate_limit_middleware(
|
||||
SecureClientIp(address): SecureClientIp,
|
||||
Extension(arc_limiter): Extension<Arc<SimpleRateLimiter<IpAddr>>>,
|
||||
req: Request<B>,
|
||||
next: Next<B>
|
||||
req: Request<Body>,
|
||||
next: Next
|
||||
) -> Response {
|
||||
let limiter = Arc::clone(&arc_limiter);
|
||||
|
||||
|
@ -121,9 +121,9 @@ pub fn set_default_if_none<T>(opt_vec: &mut Option<Vec<T>>) {
|
||||
|
||||
pub fn add_record_to_lookup_result(result: &mut DnsLookupResult, record: &RData){
|
||||
match record {
|
||||
RData::AAAA(address) => opush(&mut result.aaaa, std::net::IpAddr::V6(*address)),
|
||||
RData::AAAA(address) => opush(&mut result.aaaa, std::net::IpAddr::V6(address.0)),
|
||||
RData::ANAME(aname) => opush(&mut result.aname, aname.to_string()),
|
||||
RData::A(address) => opush(&mut result.a, std::net::IpAddr::V4(*address)),
|
||||
RData::A(address) => opush(&mut result.a, std::net::IpAddr::V4(address.0)),
|
||||
RData::CAA(caa) => opush(&mut result.caa, caa.to_string()),
|
||||
RData::CNAME(cname) => opush(&mut result.cname, cname.to_string()),
|
||||
RData::MX(mx) => opush(&mut result.mx, MxRecord{
|
||||
|
@ -51,10 +51,10 @@ impl HumusView<QuerySettings, ResponseFormat> for View {
|
||||
|
||||
fn get_cookie_header(&self, settings: &QuerySettings) -> Option<String> {
|
||||
Some(
|
||||
Cookie::build("dns_resolver",settings.dns_resolver_id.to_string())
|
||||
Cookie::build(Cookie::new("dns_resolver",settings.dns_resolver_id.to_string()))
|
||||
.path("/")
|
||||
.same_site(cookie::SameSite::Strict)
|
||||
.finish()
|
||||
.build()
|
||||
.to_string()
|
||||
)
|
||||
}
|
||||
|
@ -16,12 +16,13 @@
|
||||
{% macro domain_name_links(name) %}
|
||||
<p>Look up <code>{{name}}</code></p>
|
||||
<ul class="link-list">
|
||||
<li><a target="_blank" href="https://www.shodan.io/domain/{{ name }}">… on shodan.io <small>(limited query's per day, wants an account)</small></a></li>
|
||||
<li><a target="_blank" href="https://search.censys.io/search?resource=hosts&sort=RELEVANCE&per_page=25&virtual_hosts=EXCLUDE&q={{ name }}">… on search.censys.io <small>(10 query's per day, wants an account)</small></a></li>
|
||||
<li><a target="_blank" href="https://www.virustotal.com/gui/domain/{{ name }}">… on virustotal.com</a></li>
|
||||
<li><a target="_blank" href="https://observatory.mozilla.org/analyze/{{ name }}">… on the Mozilla Observatory (http and tls checks)</a></li>
|
||||
<li><a target="_blank" href="https://internet.nl/site/{{ name }}">… on the Internet.nl Website test</a></li>
|
||||
<li><a target="_blank" href="https://client.rdap.org/?type=domain&object={{ name }}">… on client.rdap.org <small>(a modern whois, make sure to allow xhr to 3rd parties)</small></a></li>
|
||||
<li><a target="_blank" href="https://www.shodan.io/domain/{{ name | urlencode_strict }}">… on shodan.io <small>(limited query's per day, wants an account)</small></a></li>
|
||||
<li><a target="_blank" href="https://search.censys.io/search?resource=hosts&sort=RELEVANCE&per_page=25&virtual_hosts=EXCLUDE&q={{ name | urlencode_strict }}">… on search.censys.io <small>(10 query's per day, wants an account)</small></a></li>
|
||||
<li><a target="_blank" href="https://www.virustotal.com/gui/domain/{{ name | urlencode_strict }}">… on virustotal.com</a></li>
|
||||
<li><a target="_blank" href="https://observatory.mozilla.org/analyze/{{ name | urlencode_strict }}">… on the Mozilla Observatory (http and tls checks)</a></li>
|
||||
<li><a target="_blank" href="https://internet.nl/site/{{ name | urlencode_strict }}">… on the Internet.nl Website test</a></li>
|
||||
<li><a target="_blank" href="https://client.rdap.org/?type=domain&object={{ name | urlencode_strict }}">… on client.rdap.org <small>(a modern whois, make sure to allow xhr to 3rd parties)</small></a></li>
|
||||
<li><a target="_blank" href="https://crt.sh/?Identity={{ name | urlencode_strict }}&match==">… on crt.sh <small>(Certificate Transparancy Monitor)</small></a></li>
|
||||
</ul>
|
||||
{% endmacro domain_name_links %}
|
||||
|
||||
|
Reference in New Issue
Block a user