Skip to main content

Gather a bunch of small adjacent networks into larger ones.

Project description

Little Fluffy Clouds: Gather a bunch of small adjacent networks into larger ones.

Sometimes you find yourself staring at a bunch of networks that look like they could be combined if you could just kind of smoosh them together enough.

littlefluffyclouds is that smoosher.

AI generated picture of purple and red and yellow clouds with birds flying past them. Yes, AI generated. I suck at art and have zero budget to commission artwork for this fun little project. The project itself is 100% handwritten, except for the autocomplete parts that my non-AI IDE helped me with, which is OK because we only dislike machine-generated code if it's called AI and it's otherwise "just the way things are done".

For example, this AS has a huge number of small networks. In many cases, two /24 networks are adjacent and could be combined into a single /23. There's also a big /14 network with 252 smaller networks inside it. If you use that raw output in a command or a firewall rule, etc., then you'd have to add 7,945 networks. Wow! That's too many.

$ curl -s https://ip.guide/AS9121 | jq -r .routes.v4[]
2.17.224.0/22
2.17.228.0/22
2.17.232.0/22
2.17.236.0/22
2.20.24.0/22
23.55.52.0/22
[7,933 similar lines]
212.175.175.0/24
212.175.246.0/24
212.175.250.0/24
212.175.251.0/24
212.175.252.0/24
212.175.255.0/24

Instead, let's let littlefluffyclouds mash all those little clouds into a smaller number of big ones that cover the exact same collection of addresses:

$ curl -s https://ip.guide/AS9121 |
  jq -r .routes.v4[] |
  uv run littlefluffyclouds --stdin
2.17.224.0/20
2.20.24.0/22
23.55.52.0/22
62.248.0.0/17
78.160.0.0/11
81.212.0.0/14
85.96.0.0/12
88.224.0.0/11
93.155.104.0/22
95.0.0.0/12
176.52.176.0/22
193.110.209.0/24
194.54.32.0/19
195.174.0.0/15
212.156.0.0/16
212.174.0.0/15

The end result is 16 networks. Sixteen. That's just about 1/500th the original size with identical address space coverage. Yay, big clouds!

API

"But I don't want to use a command line," you might say. Neither did I! littlefluffyclouds makes that easy peasy lemon squeezy!

from ipaddress import IPv4Network as I
from littlefluffyclouds import gather
print(gather([
    I('10.0.8.0/24'),
    I('10.0.9.0/24'),
    I('10.0.10.0/24'),
    I('10.0.11.0/24')
]))

That prints [IPv4Network('10.0.8.0/22')]. Whoa! I know, right?

But... why?

Some differences with other packages which do the same thing:

  • It's often way faster. Like ridiculously faster. Think milliseconds versus minutes faster.
  • It's written with modern Python with typing and ruff and formatting and all that.
  • Its command line is optional. All the work is done in a handy API that you can call from your own project.
  • It gives correct results, even in pathological cases where little networks are intermingled with bigger ones. That case causes several other packages to only merge the big networks or the little ones, even when you could combine a bunch of little ones with one big one.

Authors

Little Fluffy Clouds is copyright 2025 by Kirk Strauser kirk@strauser.com.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Version history

v0.2.0, 2025-09-19: Add --stdin flag. License fix.
v0.1.0, 2025-09-17: Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

littlefluffyclouds-0.2.0.tar.gz (81.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

littlefluffyclouds-0.2.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file littlefluffyclouds-0.2.0.tar.gz.

File metadata

  • Download URL: littlefluffyclouds-0.2.0.tar.gz
  • Upload date:
  • Size: 81.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for littlefluffyclouds-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fb47add50cf4aaf21416e9f41065ba6333497f276622dd3ca1e5ab9296e867ed
MD5 c426d839a1fe02162352eee44385d44c
BLAKE2b-256 7ac474cf10f5db140e93133cf660c0d8a0e3e25d502dd668486f33090df62f5c

See more details on using hashes here.

File details

Details for the file littlefluffyclouds-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for littlefluffyclouds-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb512cc009efc0e894917c0d4c363bc17f728f4e73a1e7563693ae74464d127d
MD5 7a857065f2d261133186f76fcd2e3b46
BLAKE2b-256 18ef7174969f1f50453bff4d489b3259c8b97d13d1cdd870413dc503a8194bc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page