Reduce logs from info to debug
This commit is contained in:
parent
a1bd348977
commit
63f787f635
3 changed files with 26 additions and 25 deletions
|
@ -125,7 +125,7 @@ where
|
||||||
return Err(Error::bad_config("Federation is disabled."));
|
return Err(Error::bad_config("Federation is disabled."));
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Preparing to send request to {destination}");
|
debug!("Preparing to send request to {destination}");
|
||||||
|
|
||||||
let mut write_destination_to_cache = false;
|
let mut write_destination_to_cache = false;
|
||||||
|
|
||||||
|
@ -233,13 +233,13 @@ where
|
||||||
|
|
||||||
let url = reqwest_request.url().clone();
|
let url = reqwest_request.url().clone();
|
||||||
|
|
||||||
info!("Sending request to {destination} at {url}");
|
debug!("Sending request to {destination} at {url}");
|
||||||
let response = services()
|
let response = services()
|
||||||
.globals
|
.globals
|
||||||
.federation_client()
|
.federation_client()
|
||||||
.execute(reqwest_request)
|
.execute(reqwest_request)
|
||||||
.await;
|
.await;
|
||||||
info!("Received response from {destination} at {url}");
|
debug!("Received response from {destination} at {url}");
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
Ok(mut response) => {
|
Ok(mut response) => {
|
||||||
|
@ -255,12 +255,12 @@ where
|
||||||
.expect("http::response::Builder is usable"),
|
.expect("http::response::Builder is usable"),
|
||||||
);
|
);
|
||||||
|
|
||||||
info!("Getting response bytes from {destination}");
|
debug!("Getting response bytes from {destination}");
|
||||||
let body = response.bytes().await.unwrap_or_else(|e| {
|
let body = response.bytes().await.unwrap_or_else(|e| {
|
||||||
warn!("server error {}", e);
|
warn!("server error {}", e);
|
||||||
Vec::new().into()
|
Vec::new().into()
|
||||||
}); // TODO: handle timeout
|
}); // TODO: handle timeout
|
||||||
info!("Got response bytes from {destination}");
|
debug!("Got response bytes from {destination}");
|
||||||
|
|
||||||
if status != 200 {
|
if status != 200 {
|
||||||
warn!(
|
warn!(
|
||||||
|
@ -279,7 +279,7 @@ where
|
||||||
.expect("reqwest body is valid http body");
|
.expect("reqwest body is valid http body");
|
||||||
|
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
info!("Parsing response bytes from {destination}");
|
debug!("Parsing response bytes from {destination}");
|
||||||
let response = T::IncomingResponse::try_from_http_response(http_response);
|
let response = T::IncomingResponse::try_from_http_response(http_response);
|
||||||
if response.is_ok() && write_destination_to_cache {
|
if response.is_ok() && write_destination_to_cache {
|
||||||
services()
|
services()
|
||||||
|
@ -301,7 +301,7 @@ where
|
||||||
Error::BadServerResponse("Server returned bad 200 response.")
|
Error::BadServerResponse("Server returned bad 200 response.")
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
info!("Returning error from {destination}");
|
debug!("Returning error from {destination}");
|
||||||
Err(Error::FederationError(
|
Err(Error::FederationError(
|
||||||
destination.to_owned(),
|
destination.to_owned(),
|
||||||
RumaError::from_http_response(http_response),
|
RumaError::from_http_response(http_response),
|
||||||
|
@ -340,38 +340,38 @@ fn add_port_to_hostname(destination_str: &str) -> FedDest {
|
||||||
/// Implemented according to the specification at https://matrix.org/docs/spec/server_server/r0.1.4#resolving-server-names
|
/// Implemented according to the specification at https://matrix.org/docs/spec/server_server/r0.1.4#resolving-server-names
|
||||||
/// Numbers in comments below refer to bullet points in linked section of specification
|
/// Numbers in comments below refer to bullet points in linked section of specification
|
||||||
async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDest) {
|
async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDest) {
|
||||||
info!("Finding actual destination for {destination}");
|
debug!("Finding actual destination for {destination}");
|
||||||
let destination_str = destination.as_str().to_owned();
|
let destination_str = destination.as_str().to_owned();
|
||||||
let mut hostname = destination_str.clone();
|
let mut hostname = destination_str.clone();
|
||||||
let actual_destination = match get_ip_with_port(&destination_str) {
|
let actual_destination = match get_ip_with_port(&destination_str) {
|
||||||
Some(host_port) => {
|
Some(host_port) => {
|
||||||
info!("1: IP literal with provided or default port");
|
debug!("1: IP literal with provided or default port");
|
||||||
host_port
|
host_port
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
if let Some(pos) = destination_str.find(':') {
|
if let Some(pos) = destination_str.find(':') {
|
||||||
info!("2: Hostname with included port");
|
debug!("2: Hostname with included port");
|
||||||
let (host, port) = destination_str.split_at(pos);
|
let (host, port) = destination_str.split_at(pos);
|
||||||
FedDest::Named(host.to_owned(), port.to_owned())
|
FedDest::Named(host.to_owned(), port.to_owned())
|
||||||
} else {
|
} else {
|
||||||
info!("Requesting well known for {destination}");
|
debug!("Requesting well known for {destination}");
|
||||||
match request_well_known(destination.as_str()).await {
|
match request_well_known(destination.as_str()).await {
|
||||||
Some(delegated_hostname) => {
|
Some(delegated_hostname) => {
|
||||||
info!("3: A .well-known file is available");
|
debug!("3: A .well-known file is available");
|
||||||
hostname = add_port_to_hostname(&delegated_hostname).into_uri_string();
|
hostname = add_port_to_hostname(&delegated_hostname).into_uri_string();
|
||||||
match get_ip_with_port(&delegated_hostname) {
|
match get_ip_with_port(&delegated_hostname) {
|
||||||
Some(host_and_port) => host_and_port, // 3.1: IP literal in .well-known file
|
Some(host_and_port) => host_and_port, // 3.1: IP literal in .well-known file
|
||||||
None => {
|
None => {
|
||||||
if let Some(pos) = delegated_hostname.find(':') {
|
if let Some(pos) = delegated_hostname.find(':') {
|
||||||
info!("3.2: Hostname with port in .well-known file");
|
debug!("3.2: Hostname with port in .well-known file");
|
||||||
let (host, port) = delegated_hostname.split_at(pos);
|
let (host, port) = delegated_hostname.split_at(pos);
|
||||||
FedDest::Named(host.to_owned(), port.to_owned())
|
FedDest::Named(host.to_owned(), port.to_owned())
|
||||||
} else {
|
} else {
|
||||||
info!("Delegated hostname has no port in this branch");
|
debug!("Delegated hostname has no port in this branch");
|
||||||
if let Some(hostname_override) =
|
if let Some(hostname_override) =
|
||||||
query_srv_record(&delegated_hostname).await
|
query_srv_record(&delegated_hostname).await
|
||||||
{
|
{
|
||||||
info!("3.3: SRV lookup successful");
|
debug!("3.3: SRV lookup successful");
|
||||||
let force_port = hostname_override.port();
|
let force_port = hostname_override.port();
|
||||||
|
|
||||||
if let Ok(override_ip) = services()
|
if let Ok(override_ip) = services()
|
||||||
|
@ -402,7 +402,7 @@ async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDe
|
||||||
add_port_to_hostname(&delegated_hostname)
|
add_port_to_hostname(&delegated_hostname)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!("3.4: No SRV records, just use the hostname from .well-known");
|
debug!("3.4: No SRV records, just use the hostname from .well-known");
|
||||||
add_port_to_hostname(&delegated_hostname)
|
add_port_to_hostname(&delegated_hostname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,10 +410,10 @@ async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
info!("4: No .well-known or an error occured");
|
debug!("4: No .well-known or an error occured");
|
||||||
match query_srv_record(&destination_str).await {
|
match query_srv_record(&destination_str).await {
|
||||||
Some(hostname_override) => {
|
Some(hostname_override) => {
|
||||||
info!("4: SRV record found");
|
debug!("4: SRV record found");
|
||||||
let force_port = hostname_override.port();
|
let force_port = hostname_override.port();
|
||||||
|
|
||||||
if let Ok(override_ip) = services()
|
if let Ok(override_ip) = services()
|
||||||
|
@ -445,7 +445,7 @@ async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
info!("5: No SRV record found");
|
debug!("5: No SRV record found");
|
||||||
add_port_to_hostname(&destination_str)
|
add_port_to_hostname(&destination_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,7 @@ async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
info!("Actual destination: {actual_destination:?}");
|
debug!("Actual destination: {actual_destination:?}");
|
||||||
|
|
||||||
// Can't use get_ip_with_port here because we don't want to add a port
|
// Can't use get_ip_with_port here because we don't want to add a port
|
||||||
// to an IP address if it wasn't specified
|
// to an IP address if it wasn't specified
|
||||||
|
@ -500,9 +500,9 @@ async fn request_well_known(destination: &str) -> Option<String> {
|
||||||
.get(&format!("https://{destination}/.well-known/matrix/server"))
|
.get(&format!("https://{destination}/.well-known/matrix/server"))
|
||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
info!("Got well known response");
|
debug!("Got well known response");
|
||||||
let text = response.ok()?.text().await;
|
let text = response.ok()?.text().await;
|
||||||
info!("Got well known response text");
|
debug!("Got well known response text");
|
||||||
let body: serde_json::Value = serde_json::from_str(&text.ok()?).ok()?;
|
let body: serde_json::Value = serde_json::from_str(&text.ok()?).ok()?;
|
||||||
Some(body.get("m.server")?.as_str()?.to_owned())
|
Some(body.get("m.server")?.as_str()?.to_owned())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1530,6 +1530,7 @@ impl Service {
|
||||||
while let Some(result) = futures.next().await {
|
while let Some(result) = futures.next().await {
|
||||||
info!("Received new result");
|
info!("Received new result");
|
||||||
if let (Ok(get_keys_response), origin) = result {
|
if let (Ok(get_keys_response), origin) = result {
|
||||||
|
info!("Result is from {origin}");
|
||||||
if let Ok(key) = get_keys_response.server_key.deserialize() {
|
if let Ok(key) = get_keys_response.server_key.deserialize() {
|
||||||
let result: BTreeMap<_, _> = services()
|
let result: BTreeMap<_, _> = services()
|
||||||
.globals
|
.globals
|
||||||
|
|
|
@ -40,7 +40,7 @@ use tokio::{
|
||||||
select,
|
select,
|
||||||
sync::{mpsc, Mutex, Semaphore},
|
sync::{mpsc, Mutex, Semaphore},
|
||||||
};
|
};
|
||||||
use tracing::{error, info, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum OutgoingKind {
|
pub enum OutgoingKind {
|
||||||
|
@ -683,9 +683,9 @@ impl Service {
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: Debug,
|
||||||
{
|
{
|
||||||
info!("Waiting for permit");
|
debug!("Waiting for permit");
|
||||||
let permit = self.maximum_requests.acquire().await;
|
let permit = self.maximum_requests.acquire().await;
|
||||||
info!("Got permit");
|
debug!("Got permit");
|
||||||
let response = tokio::time::timeout(
|
let response = tokio::time::timeout(
|
||||||
Duration::from_secs(2 * 60),
|
Duration::from_secs(2 * 60),
|
||||||
server_server::send_request(destination, request),
|
server_server::send_request(destination, request),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue