Fix: match port on epic protocol (#225)

This commit is contained in:
Cain 2024-10-13 20:09:57 +01:00 committed by GitHub
parent 344622629e
commit e4baf07e48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,22 +122,24 @@ impl EpicProtocol {
let attributes = session
.get("attributes")
.ok_or(PacketBad.context("Expected attributes field missing in sessions."))?;
if attributes
let address_match = attributes
.get("ADDRESSBOUND_s")
.and_then(Value::as_str)
.map_or(false, |v| {
v.contains(&address) || v.contains(&port.to_string())
})
.map_or(false, |v| v == address || v == format!("0.0.0.0:{}", port))
|| attributes
.get("ADDRESS_s")
.and_then(Value::as_str)
.map_or(false, |v| v.contains(&address))
{
.get("GAMESERVER_PORT_1")
.and_then(Value::as_u64)
.map_or(false, |v| v == port as u64);
if address_match {
return Ok(session);
}
}
return Err(PacketBad.context("Servers were provided but the specified one couldn't be find amonst them."));
return Err(
PacketBad.context("Servers were provided but the specified one couldn't be found amongst them.")
);
}
Err(PacketBad.context("Expected session field to be an array."))