allow incoming requests from arbitrary ports (#78)

closes #77
This commit is contained in:
Ferdinand Schober
2024-01-18 22:36:33 +01:00
committed by GitHub
parent b3caba99ab
commit 6674af8e63
3 changed files with 18 additions and 33 deletions

View File

@@ -70,10 +70,10 @@ pub struct Client {
/// This way any event consumer / producer backend does not
/// need to know anything about a client other than its handle.
pub handle: ClientHandle,
/// all socket addresses associated with a particular client
/// all ip addresses associated with a particular client
/// e.g. Laptops usually have at least an ethernet and a wifi port
/// which have different ip addresses
pub addrs: HashSet<SocketAddr>,
pub ips: HashSet<IpAddr>,
/// both active_addr and addrs can be None / empty so port needs to be stored seperately
pub port: u16,
/// position of a client on screen
@@ -134,15 +134,12 @@ impl ClientManager {
// store fix ip addresses
let fix_ips = ips.iter().cloned().collect();
// map ip addresses to socket addresses
let addrs = HashSet::from_iter(ips.into_iter().map(|ip| SocketAddr::new(ip, port)));
// store the client
let client = Client {
hostname,
fix_ips,
handle,
addrs,
ips,
port,
pos,
};
@@ -173,7 +170,7 @@ impl ClientManager {
.iter()
.position(|c| {
if let Some(c) = c {
c.active && c.client.addrs.contains(&addr)
c.active && c.client.ips.contains(&addr.ip())
} else {
false
}