Skip to main content

zond_engine/core/models/
localhost.rs

1// Copyright (c) 2026 Erik Lening (hollowpointer) and Contributors
2//
3// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4// If a copy of the MPL was not distributed with this file, You can obtain one at
5// https://mozilla.org/MPL/2.0/.
6
7//! # Local Host Info Model
8//!
9//! Information about the *local machine* (where the program is running),
10//! rather than remote hosts discovered on the network.
11//!
12//! This includes:
13//! * Active network services (ports opened by local processes).
14//! * Firewall status.
15
16use std::collections::HashSet;
17use std::net::IpAddr;
18
19/// Represents a group of services running on a specific local IP address.
20#[derive(Debug, Clone)]
21pub struct IpServiceGroup {
22    pub ip_addr: IpAddr,
23    pub tcp_services: Vec<Service>,
24    pub udp_services: Vec<Service>,
25}
26
27impl IpServiceGroup {
28    pub fn new(ip_addr: IpAddr, tcp_services: Vec<Service>, udp_services: Vec<Service>) -> Self {
29        Self {
30            ip_addr,
31            tcp_services,
32            udp_services,
33        }
34    }
35}
36
37#[derive(Debug, Clone)]
38pub struct Service {
39    pub name: String,
40    pub local_addr: IpAddr,
41    pub local_ports: HashSet<u16>,
42}
43
44impl Service {
45    pub fn new(name: String, local_addr: IpAddr, local_ports: HashSet<u16>) -> Self {
46        Self {
47            name,
48            local_addr,
49            local_ports,
50        }
51    }
52}
53
54#[derive(Debug, Clone, PartialEq, Eq)]
55pub enum FirewallStatus {
56    Active,
57    Inactive,
58    NotDetected,
59}