Browse Source

protocol: add Filter::contains_flags

ipv6
Denis Drakhnia 7 months ago
parent
commit
5d73c9878e
  1. 6
      master/src/master_server.rs
  2. 9
      protocol/src/filter.rs

6
master/src/master_server.rs

@ -347,9 +347,9 @@ impl MasterServer { @@ -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)?;
}

9
protocol/src/filter.rs

@ -186,6 +186,15 @@ impl Filter<'_> { @@ -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…
Cancel
Save