|
|
|
|
@ -3,6 +3,8 @@ use get_profile_information::v1::ProfileField;
@@ -3,6 +3,8 @@ use get_profile_information::v1::ProfileField;
|
|
|
|
|
use http::header::{HeaderValue, AUTHORIZATION, HOST}; |
|
|
|
|
use log::{info, warn}; |
|
|
|
|
use regex::Regex; |
|
|
|
|
#[cfg(feature = "conduit_bin")] |
|
|
|
|
use rocket::{get, post, put}; |
|
|
|
|
use rocket::{response::content::Json, State}; |
|
|
|
|
use ruma::{ |
|
|
|
|
api::{ |
|
|
|
|
@ -29,10 +31,6 @@ use std::{
@@ -29,10 +31,6 @@ use std::{
|
|
|
|
|
net::{IpAddr, SocketAddr}, |
|
|
|
|
time::{Duration, SystemTime}, |
|
|
|
|
}; |
|
|
|
|
#[cfg(feature = "conduit_bin")] |
|
|
|
|
use { |
|
|
|
|
rocket::{get, post, put} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(globals))] |
|
|
|
|
pub async fn send_request<T: OutgoingRequest>( |
|
|
|
|
@ -231,7 +229,15 @@ async fn find_actual_destination(
@@ -231,7 +229,15 @@ async fn find_actual_destination(
|
|
|
|
|
let mut host = None; |
|
|
|
|
|
|
|
|
|
let destination_str = destination.as_str().to_owned(); |
|
|
|
|
let actual_destination = "https://".to_owned() |
|
|
|
|
#[cfg(not(feature = "tor"))] |
|
|
|
|
let protocol = "https://"; |
|
|
|
|
#[cfg(feature = "tor")] |
|
|
|
|
let protocol = if globals.tor_federation_enabled() && destination_str.ends_with(".onion") { |
|
|
|
|
"http://" |
|
|
|
|
} else { |
|
|
|
|
"https://" |
|
|
|
|
}; |
|
|
|
|
let actual_destination = protocol.to_owned() |
|
|
|
|
+ &match get_ip_with_port(destination_str.clone()) { |
|
|
|
|
Some(host_port) => { |
|
|
|
|
// 1: IP literal with provided or default port
|
|
|
|
|
@ -600,9 +606,7 @@ pub async fn send_transaction_message_route<'a>(
@@ -600,9 +606,7 @@ pub async fn send_transaction_message_route<'a>(
|
|
|
|
|
let users = namespaces |
|
|
|
|
.get("users") |
|
|
|
|
.and_then(|users| users.as_sequence()) |
|
|
|
|
.map_or_else( |
|
|
|
|
Vec::new, |
|
|
|
|
|users| { |
|
|
|
|
.map_or_else(Vec::new, |users| { |
|
|
|
|
users |
|
|
|
|
.iter() |
|
|
|
|
.map(|users| { |
|
|
|
|
@ -613,8 +617,7 @@ pub async fn send_transaction_message_route<'a>(
@@ -613,8 +617,7 @@ pub async fn send_transaction_message_route<'a>(
|
|
|
|
|
}) |
|
|
|
|
.filter_map(|o| o) |
|
|
|
|
.collect::<Vec<_>>() |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
let aliases = namespaces |
|
|
|
|
.get("aliases") |
|
|
|
|
.and_then(|users| users.get("regex")) |
|
|
|
|
|