Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: try to match port on epic protocol #225

Merged
merged 7 commits into from
Oct 13, 2024
20 changes: 11 additions & 9 deletions crates/lib/src/protocols/epic/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand Down
Loading