Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@manach232
Copy link

Changed network definition with more fitting defaults
Combined ipv4_subnet and ipv4 into ipv4_cidr to be more consistent with other uses of ipv4
updated test.py and range.py for new network setup
renamed network.rm() to be consistent with network.destroy_by_name()

Changed network definition with more fitting defaults
Compined ipv4_subnet and ipv4 into ipv4_cidr to be more consistent with
other uses of ipv4
updated test.py and range.py for new network setup
renamed network.rm() to be consistent with network.destroy_by_name()
Copy link
Owner

@sn0ja sn0ja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution; changing the API to simplify handling of IPv4 addresses is a great idea. Also thank you for going through the hassle of writing comments and type hints.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to also change how ipv4 is used with Interfaces so the api is consistent in that matter. So that Interfaces work with the cidr representation as well instead of prefix_length and ipv4

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be wise also do this for ipv6 in general as well right?

Copy link
Owner

@sn0ja sn0ja Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but ipv6 is not even fully implemented yet, i open an issue for that #2

Comment on lines 2 to 6
import ipaddress
import jinja2
import re
import socket
import struct
Copy link
Owner

@sn0ja sn0ja Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need socket and struct for the IP parsing, maybe ipaddress offers the functionality you need?

added ipv6 cidr
changed ipv4 splitting logic
cleanup
Copy link
Owner

@sn0ja sn0ja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small change requests.
Thank you for your support :) 🐈

self.ipv6_prefix = ipv6_tuple[1]
else:
self.ipv6 = ""
self.ipv6_subnet = ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean self.ipv6_prefix = "" instead of self.ipv6_subnet = "" ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other components of cave (e.g. this line) use the ipv4 and prefix_length properties, so we cannot remove them.
Maybe change Interface to a normal class and do the calculation of ipv4 and prefix_length from ipv4_cidr in the constructor like done in network.py?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could then also include sanity checks in the constructor e.g. assert "/" in ipv4_cidr, this is not a clean solution but we are just building a prototype here for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to introduce a utility module to ease the introduction of functionalities, which are reused throughout cave? This would also ease the introduction of argument validation etc. in the future.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now it is not really necessary

network=mngt,
ipv4="10.10.0.3",
prefix_length=24,
ipv4_cidr="10.10.0.3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is here a /24 missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants