mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-11-10 09:32:19 +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
|
||||
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()
|
||||
} else {
|
||||
"server.proxy.trusted-networks".as_key()
|
||||
|
|
|
@ -387,16 +387,16 @@ impl JmapInstance {
|
|||
let instance = session.instance.clone();
|
||||
|
||||
async move {
|
||||
trc::event!(
|
||||
Http(trc::HttpEvent::RequestUrl),
|
||||
SpanId = session.session_id,
|
||||
Url = req.uri().to_string(),
|
||||
);
|
||||
|
||||
let jmap = JMAP::from(jmap_instance);
|
||||
|
||||
// Obtain remote IP
|
||||
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
|
||||
} else if let Some(forwarded_for) = req
|
||||
.headers()
|
||||
|
@ -435,6 +435,13 @@ impl JmapInstance {
|
|||
.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
|
||||
} else {
|
||||
trc::event!(
|
||||
|
|
|
@ -14,11 +14,11 @@ use utils::config::{utils::AsKey, Config};
|
|||
|
||||
use crate::{BlobBackend, Store, Stores};
|
||||
|
||||
pub struct CompositeBlob {
|
||||
pub struct DistributedBlob {
|
||||
pub stores: Vec<BlobBackend>,
|
||||
}
|
||||
|
||||
impl CompositeBlob {
|
||||
impl DistributedBlob {
|
||||
pub fn open(config: &mut Config, prefix: impl AsKey, stores: &Stores) -> Option<Self> {
|
||||
let prefix = prefix.as_key();
|
||||
let store_ids = config
|
||||
|
|
|
@ -213,7 +213,7 @@ impl Stores {
|
|||
}
|
||||
}
|
||||
#[cfg(feature = "enterprise")]
|
||||
"sql-read-replica" | "composite-blob" => {
|
||||
"sql-read-replica" | "distributed-blob" => {
|
||||
composite_stores.push((store_id, protocol));
|
||||
}
|
||||
unknown => {
|
||||
|
@ -254,9 +254,9 @@ impl Stores {
|
|||
self.lookup_stores.insert(id.to_string(), db.into());
|
||||
}
|
||||
}
|
||||
"composite-blob" => {
|
||||
"distributed-blob" => {
|
||||
if let Some(db) =
|
||||
crate::backend::composite::distributed_blob::CompositeBlob::open(
|
||||
crate::backend::composite::distributed_blob::DistributedBlob::open(
|
||||
config, prefix, self,
|
||||
)
|
||||
{
|
||||
|
|
|
@ -209,7 +209,7 @@ pub enum BlobBackend {
|
|||
#[cfg(feature = "s3")]
|
||||
S3(Arc<S3Store>),
|
||||
#[cfg(feature = "enterprise")]
|
||||
Composite(Arc<backend::composite::distributed_blob::CompositeBlob>),
|
||||
Composite(Arc<backend::composite::distributed_blob::DistributedBlob>),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Reference in a new issue