mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-11-13 04:39:02 +08:00
Include Forwarded-For IP address in http.request-url event (closes #682)
This commit is contained in:
parent
7b2941518a
commit
ec23236b06
5 changed files with 24 additions and 13 deletions
|
@ -183,7 +183,11 @@ impl Servers {
|
||||||
|
|
||||||
// Parse proxy networks
|
// Parse proxy networks
|
||||||
let mut proxy_networks = Vec::new();
|
let mut proxy_networks = Vec::new();
|
||||||
let proxy_keys = if config.has_prefix(("server.listener", id, "proxy.trusted-networks")) {
|
let proxy_keys = if config
|
||||||
|
.value(("server.listener", id, "proxy.trusted-networks"))
|
||||||
|
.is_some()
|
||||||
|
|| config.has_prefix(("server.listener", id, "proxy.trusted-networks"))
|
||||||
|
{
|
||||||
("server.listener", id, "proxy.trusted-networks").as_key()
|
("server.listener", id, "proxy.trusted-networks").as_key()
|
||||||
} else {
|
} else {
|
||||||
"server.proxy.trusted-networks".as_key()
|
"server.proxy.trusted-networks".as_key()
|
||||||
|
|
|
@ -387,16 +387,16 @@ impl JmapInstance {
|
||||||
let instance = session.instance.clone();
|
let instance = session.instance.clone();
|
||||||
|
|
||||||
async move {
|
async move {
|
||||||
trc::event!(
|
|
||||||
Http(trc::HttpEvent::RequestUrl),
|
|
||||||
SpanId = session.session_id,
|
|
||||||
Url = req.uri().to_string(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let jmap = JMAP::from(jmap_instance);
|
let jmap = JMAP::from(jmap_instance);
|
||||||
|
|
||||||
// Obtain remote IP
|
// Obtain remote IP
|
||||||
let remote_ip = if !jmap.core.jmap.http_use_forwarded {
|
let remote_ip = if !jmap.core.jmap.http_use_forwarded {
|
||||||
|
trc::event!(
|
||||||
|
Http(trc::HttpEvent::RequestUrl),
|
||||||
|
SpanId = session.session_id,
|
||||||
|
Url = req.uri().to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
session.remote_ip
|
session.remote_ip
|
||||||
} else if let Some(forwarded_for) = req
|
} else if let Some(forwarded_for) = req
|
||||||
.headers()
|
.headers()
|
||||||
|
@ -435,6 +435,13 @@ impl JmapInstance {
|
||||||
.and_then(|h| h.parse::<IpAddr>().ok())
|
.and_then(|h| h.parse::<IpAddr>().ok())
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
trc::event!(
|
||||||
|
Http(trc::HttpEvent::RequestUrl),
|
||||||
|
SpanId = session.session_id,
|
||||||
|
RemoteIp = forwarded_for,
|
||||||
|
Url = req.uri().to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
forwarded_for
|
forwarded_for
|
||||||
} else {
|
} else {
|
||||||
trc::event!(
|
trc::event!(
|
||||||
|
|
|
@ -14,11 +14,11 @@ use utils::config::{utils::AsKey, Config};
|
||||||
|
|
||||||
use crate::{BlobBackend, Store, Stores};
|
use crate::{BlobBackend, Store, Stores};
|
||||||
|
|
||||||
pub struct CompositeBlob {
|
pub struct DistributedBlob {
|
||||||
pub stores: Vec<BlobBackend>,
|
pub stores: Vec<BlobBackend>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositeBlob {
|
impl DistributedBlob {
|
||||||
pub fn open(config: &mut Config, prefix: impl AsKey, stores: &Stores) -> Option<Self> {
|
pub fn open(config: &mut Config, prefix: impl AsKey, stores: &Stores) -> Option<Self> {
|
||||||
let prefix = prefix.as_key();
|
let prefix = prefix.as_key();
|
||||||
let store_ids = config
|
let store_ids = config
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl Stores {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "enterprise")]
|
#[cfg(feature = "enterprise")]
|
||||||
"sql-read-replica" | "composite-blob" => {
|
"sql-read-replica" | "distributed-blob" => {
|
||||||
composite_stores.push((store_id, protocol));
|
composite_stores.push((store_id, protocol));
|
||||||
}
|
}
|
||||||
unknown => {
|
unknown => {
|
||||||
|
@ -254,9 +254,9 @@ impl Stores {
|
||||||
self.lookup_stores.insert(id.to_string(), db.into());
|
self.lookup_stores.insert(id.to_string(), db.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"composite-blob" => {
|
"distributed-blob" => {
|
||||||
if let Some(db) =
|
if let Some(db) =
|
||||||
crate::backend::composite::distributed_blob::CompositeBlob::open(
|
crate::backend::composite::distributed_blob::DistributedBlob::open(
|
||||||
config, prefix, self,
|
config, prefix, self,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -209,7 +209,7 @@ pub enum BlobBackend {
|
||||||
#[cfg(feature = "s3")]
|
#[cfg(feature = "s3")]
|
||||||
S3(Arc<S3Store>),
|
S3(Arc<S3Store>),
|
||||||
#[cfg(feature = "enterprise")]
|
#[cfg(feature = "enterprise")]
|
||||||
Composite(Arc<backend::composite::distributed_blob::CompositeBlob>),
|
Composite(Arc<backend::composite::distributed_blob::DistributedBlob>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
Loading…
Reference in a new issue