use super::strings;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Entry {
pub ip_address: String,
pub hostnames: Vec<String>,
pub comment: Option<String>,
}
impl Entry {
pub fn new(ip_address: impl Into<String>, hostnames: &[&str]) -> Self {
Self {
ip_address: ip_address.into(),
hostnames: strings(hostnames),
comment: None,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Hosts {
pub entries: Vec<Entry>,
pub comment: Option<String>,
}
impl Default for Hosts {
fn default() -> Self {
Self {
entries: vec![
Entry::new("127.0.0.1", &["localhost"]),
Entry::new("::1", &["localhost", "ip6-localhost", "ip6-loopback"]),
Entry::new("fe00::", &["ip6-localnet"]),
Entry::new("ff00::", &["ip6-mcastprefix"]),
Entry::new("ff02::1", &["ip6-allnodes"]),
Entry::new("ff02::2", &["ip6-allrouters"]),
],
comment: None,
}
}
}