#ip-address #ip #reproducible #ipv6 #unique

ipgen

A library for generating unique and reproducible IP addresses

8 releases (3 stable)

1.0.2 Sep 27, 2022
1.0.1 Mar 7, 2021
0.0.5 Mar 7, 2021
0.0.4 Oct 1, 2016
0.0.2 Sep 30, 2016

#15 in #reproducible

Download history 64/week @ 2024-06-09 66/week @ 2024-06-16 56/week @ 2024-06-23 65/week @ 2024-06-30 51/week @ 2024-07-07 52/week @ 2024-07-14 61/week @ 2024-07-21 67/week @ 2024-07-28 104/week @ 2024-08-04 50/week @ 2024-08-11 66/week @ 2024-08-18 180/week @ 2024-08-25 34/week @ 2024-09-01 120/week @ 2024-09-08 20/week @ 2024-09-15 105/week @ 2024-09-22

283 downloads per month
Used in 2 crates

MIT/Apache

11KB
144 lines

Rust IPGen Library

Official implementation of the IPGen Spec in Rust

Build Status Latest Version Docs

IPGen is a library for generating unique and reproducible IP addresses in Rust. The IP addresses generated by this library are highly unique (depending on your subnet prefix), yet if you pass it the same input it will produce the same IP address. You can also generate the IP addresses using our command line tool.

Getting Started

Add ipgen as a dependency in your Cargo.toml file.

[dependencies]
ipgen = "1"

Use it in your program as follows:-

fn main() -> ipgen::Result<()> {
  // Compute subnet ID
  let subnet = ipgen::subnet("App 1")?; 
  assert_eq!(subnet, "ba3d");
  
  // Or compute an IPv6 address
  // Note you can also pass in an IPv4 network to generate an IPv4
  let network = "fd52:f6b0:3162::/48".parse()?;
  let ip = ipgen::ip("App 1", network)?;
  assert_eq!(ip.to_string(), "fd52:f6b0:3162:46a1:2a4f:89e8:8aed:1327");

  Ok(())
}

Dependencies

~480KB
~11K SLoC