mirror of
https://git.mentality.rip/numas13/xash3d-master.git
synced 2025-02-02 10:14:24 +00:00
protocol: add Filter::contains_flags
This commit is contained in:
parent
c0ea55511a
commit
5d73c9878e
@ -347,9 +347,9 @@ impl MasterServer {
|
||||
|
||||
self.send_server_list(from, p.filter.key, &self.filtered_servers)?;
|
||||
|
||||
if !p.filter.flags_mask.contains(FilterFlags::NAT)
|
||||
|| p.filter.flags.contains(FilterFlags::NAT)
|
||||
{
|
||||
// NOTE: If NAT is not set in a filter then by default the client is announced
|
||||
// to filtered servers behind NAT.
|
||||
if p.filter.contains_flags(FilterFlags::NAT).unwrap_or(true) {
|
||||
self.send_client_to_nat_servers(from, &self.filtered_servers_nat)?;
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,15 @@ impl Filter<'_> {
|
||||
self.flags_mask.insert(flag);
|
||||
}
|
||||
|
||||
/// Test if all `other` flags are set in `flags_mask` and in `flags`.
|
||||
pub fn contains_flags(&self, other: FilterFlags) -> Option<bool> {
|
||||
if self.flags_mask.contains(other) {
|
||||
Some(self.flags.contains(other))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if a server matches the filter.
|
||||
pub fn matches(&self, _addr: SocketAddrV4, info: &ServerInfo) -> bool {
|
||||
!((info.flags & self.flags_mask) != self.flags
|
||||
|
Loading…
x
Reference in New Issue
Block a user