Skip to content

Incorrect remove on IpRange #25

@ntrippar

Description

@ntrippar

I'm trying to remove a host from a IpRange by doing a remove <ip>/32 and I'm getting this is returning way less hosts than it should. Here is the POC for this issue

use iprange::IpRange;
use ipnet::Ipv4Net;

let mut ip_range: IpRange<Ipv4Net> = IpRange::new();

ip_range.add("10.0.0.0/24".parse()?);

let remove: Ipv4Net = "10.0.0.50/32".parse()?;
ip_range.remove(remove);

let total_ip_count: usize = ip_range
    .iter()
    .map(|r| r.hosts().count())
    .sum();

println!("hosts: {}", total_ip_count);

this returns hosts: 243 and we should have 253

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions