fix: signature mismatch on odd send_join servers
This commit is contained in:
parent
caf9834e50
commit
a5f004d7e9
4 changed files with 38 additions and 24 deletions
|
@ -76,7 +76,7 @@ crossbeam = { version = "0.8.1", optional = true }
|
||||||
num_cpus = "1.13.0"
|
num_cpus = "1.13.0"
|
||||||
threadpool = "1.8.1"
|
threadpool = "1.8.1"
|
||||||
heed = { git = "https://github.com/timokoesters/heed.git", rev = "f6f825da7fb2c758867e05ad973ef800a6fe1d5d", optional = true }
|
heed = { git = "https://github.com/timokoesters/heed.git", rev = "f6f825da7fb2c758867e05ad973ef800a6fe1d5d", optional = true }
|
||||||
rocksdb = { version = "0.17.0", default-features = true, features = ["multi-threaded-cf", "zstd"], optional = true }
|
rocksdb = { version = "0.17.0", default-features = false, features = ["multi-threaded-cf", "zstd"], optional = true }
|
||||||
|
|
||||||
thread_local = "1.1.3"
|
thread_local = "1.1.3"
|
||||||
# used for TURN server authentication
|
# used for TURN server authentication
|
||||||
|
|
|
@ -60,15 +60,16 @@ pub async fn get_register_available_route(
|
||||||
body: Ruma<get_username_availability::Request<'_>>,
|
body: Ruma<get_username_availability::Request<'_>>,
|
||||||
) -> ConduitResult<get_username_availability::Response> {
|
) -> ConduitResult<get_username_availability::Response> {
|
||||||
// Validate user id
|
// Validate user id
|
||||||
let user_id = UserId::parse_with_server_name(body.username.to_lowercase(), db.globals.server_name())
|
let user_id =
|
||||||
.ok()
|
UserId::parse_with_server_name(body.username.to_lowercase(), db.globals.server_name())
|
||||||
.filter(|user_id| {
|
.ok()
|
||||||
!user_id.is_historical() && user_id.server_name() == db.globals.server_name()
|
.filter(|user_id| {
|
||||||
})
|
!user_id.is_historical() && user_id.server_name() == db.globals.server_name()
|
||||||
.ok_or(Error::BadRequest(
|
})
|
||||||
ErrorKind::InvalidUsername,
|
.ok_or(Error::BadRequest(
|
||||||
"Username is invalid.",
|
ErrorKind::InvalidUsername,
|
||||||
))?;
|
"Username is invalid.",
|
||||||
|
))?;
|
||||||
|
|
||||||
// Check if username is creative enough
|
// Check if username is creative enough
|
||||||
if db.users.exists(&user_id)? {
|
if db.users.exists(&user_id)? {
|
||||||
|
|
|
@ -655,7 +655,7 @@ async fn join_room_by_id_helper(
|
||||||
|
|
||||||
db.rooms.get_or_create_shortroomid(room_id, &db.globals)?;
|
db.rooms.get_or_create_shortroomid(room_id, &db.globals)?;
|
||||||
|
|
||||||
let pdu = PduEvent::from_id_val(event_id, join_event.clone())
|
let parsed_pdu = PduEvent::from_id_val(event_id, join_event.clone())
|
||||||
.map_err(|_| Error::BadServerResponse("Invalid join event PDU."))?;
|
.map_err(|_| Error::BadServerResponse("Invalid join event PDU."))?;
|
||||||
|
|
||||||
let mut state = HashMap::new();
|
let mut state = HashMap::new();
|
||||||
|
@ -695,14 +695,15 @@ async fn join_room_by_id_helper(
|
||||||
}
|
}
|
||||||
|
|
||||||
let incoming_shortstatekey = db.rooms.get_or_create_shortstatekey(
|
let incoming_shortstatekey = db.rooms.get_or_create_shortstatekey(
|
||||||
&pdu.kind,
|
&parsed_pdu.kind,
|
||||||
pdu.state_key
|
parsed_pdu
|
||||||
|
.state_key
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("Pdu is a membership state event"),
|
.expect("Pdu is a membership state event"),
|
||||||
&db.globals,
|
&db.globals,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
state.insert(incoming_shortstatekey, pdu.event_id.clone());
|
state.insert(incoming_shortstatekey, parsed_pdu.event_id.clone());
|
||||||
|
|
||||||
let create_shortstatekey = db
|
let create_shortstatekey = db
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -738,12 +739,12 @@ async fn join_room_by_id_helper(
|
||||||
|
|
||||||
// We append to state before appending the pdu, so we don't have a moment in time with the
|
// We append to state before appending the pdu, so we don't have a moment in time with the
|
||||||
// pdu without it's state. This is okay because append_pdu can't fail.
|
// pdu without it's state. This is okay because append_pdu can't fail.
|
||||||
let statehashid = db.rooms.append_to_state(&pdu, &db.globals)?;
|
let statehashid = db.rooms.append_to_state(&parsed_pdu, &db.globals)?;
|
||||||
|
|
||||||
db.rooms.append_pdu(
|
db.rooms.append_pdu(
|
||||||
&pdu,
|
&parsed_pdu,
|
||||||
utils::to_canonical_object(&pdu).expect("Pdu is valid canonical object"),
|
join_event,
|
||||||
iter::once(&*pdu.event_id),
|
iter::once(&*parsed_pdu.event_id),
|
||||||
db,
|
db,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -367,15 +367,27 @@ impl Database {
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("pdu cache capacity fits into usize"),
|
.expect("pdu cache capacity fits into usize"),
|
||||||
)),
|
)),
|
||||||
auth_chain_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
auth_chain_cache: Mutex::new(LruCache::new(
|
||||||
shorteventid_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
eventidshort_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
)),
|
||||||
shortstatekey_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
shorteventid_cache: Mutex::new(LruCache::new(
|
||||||
statekeyshort_cache: Mutex::new(LruCache::new((100_000.0 * config.conduit_cache_capacity_modifier) as usize)),
|
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
|
)),
|
||||||
|
eventidshort_cache: Mutex::new(LruCache::new(
|
||||||
|
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
|
)),
|
||||||
|
shortstatekey_cache: Mutex::new(LruCache::new(
|
||||||
|
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
|
)),
|
||||||
|
statekeyshort_cache: Mutex::new(LruCache::new(
|
||||||
|
(100_000.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
|
)),
|
||||||
our_real_users_cache: RwLock::new(HashMap::new()),
|
our_real_users_cache: RwLock::new(HashMap::new()),
|
||||||
appservice_in_room_cache: RwLock::new(HashMap::new()),
|
appservice_in_room_cache: RwLock::new(HashMap::new()),
|
||||||
lazy_load_waiting: Mutex::new(HashMap::new()),
|
lazy_load_waiting: Mutex::new(HashMap::new()),
|
||||||
stateinfo_cache: Mutex::new(LruCache::new((100.0 * config.conduit_cache_capacity_modifier) as usize)),
|
stateinfo_cache: Mutex::new(LruCache::new(
|
||||||
|
(100.0 * config.conduit_cache_capacity_modifier) as usize,
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
account_data: account_data::AccountData {
|
account_data: account_data::AccountData {
|
||||||
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
roomuserdataid_accountdata: builder.open_tree("roomuserdataid_accountdata")?,
|
||||||
|
|
Loading…
Add table
Reference in a new issue