extract client ip from connection state
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0bade5317f
commit
3ada847570
5 changed files with 36 additions and 0 deletions
|
@ -33,6 +33,7 @@ brotli_compression = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
axum-client-ip.workspace = true
|
||||
axum-extra.workspace = true
|
||||
axum.workspace = true
|
||||
base64.workspace = true
|
||||
|
|
|
@ -46,6 +46,7 @@ axum_dual_protocol = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
axum-client-ip.workspace = true
|
||||
axum-server-dual-protocol.optional = true
|
||||
axum-server-dual-protocol.workspace = true
|
||||
axum-server.workspace = true
|
||||
|
|
|
@ -4,6 +4,7 @@ use axum::{
|
|||
extract::{DefaultBodyLimit, MatchedPath},
|
||||
Router,
|
||||
};
|
||||
use axum_client_ip::SecureClientIpSource;
|
||||
use conduit::Server;
|
||||
use http::{
|
||||
header::{self, HeaderName},
|
||||
|
@ -46,6 +47,7 @@ pub(crate) fn build(server: &Arc<Server>) -> io::Result<Router> {
|
|||
.on_response(DefaultOnResponse::new().level(Level::DEBUG)),
|
||||
)
|
||||
.layer(axum::middleware::from_fn_with_state(Arc::clone(server), request::handle))
|
||||
.layer(SecureClientIpSource::ConnectInfo.into_extension())
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
HeaderName::from_static("origin-agent-cluster"), // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin-Agent-Cluster
|
||||
HeaderValue::from_static("?1"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue