Skip to content

Fixed hydration of the Network class with IPv6 addresses #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 11, 2025

Conversation

alkavan
Copy link
Contributor

@alkavan alkavan commented Mar 9, 2025

The IPv6 address 2b03:b0c0:2:d0::102e:d001 should have the CIDR notation 2b03:b0c0:2:d0::102e:d001/64, 2b03:b0c0:0002:00d0:0000:0000:0000:0000/64.

I'm not 100% sure what the netmask value can be, is it always int? or can it come as string? that's why the check.

I guess this also applies for 4.x versions, it's just that the field not have the constraint there and don't produce this error.

@alkavan
Copy link
Contributor Author

alkavan commented Mar 9, 2025

@GrahamCampbell opened PR here. Issue when building the network entity for droplets with IPv6.
The cidr field has string constraint in 5.x and the netmask is int value.

@alkavan alkavan changed the title For IPv6 networks the netmask is integer and the CIDR field is assign… For IPv6 the CIDR field assigned with wrong type and notation Mar 9, 2025
@alkavan alkavan changed the title For IPv6 the CIDR field assigned with wrong type and notation IPv6 the CIDR field assigned with wrong type and notation Mar 10, 2025
@alkavan alkavan force-pushed the 5.0 branch 2 times, most recently from 7fb3869 to 8d30f7b Compare March 10, 2025 04:55
For IPv6 networks the netmask is integer and the CIDR field is assigned with `int` to a field with `string` constraint. The netmask in this case represents the number for allow networks.

The IPv6 address `2b03:b0c0:2:d0::102e:d001` should have the CIDR notation `2b03:b0c0:2:d0::102e:d001/64` or `2b03:b0c0:0002:00d0:0000:0000:0000:0000/64`.

I'm not 100% sure what the netmask value can be on the api die, is it always int? or can it come as string? that's why the check for int.
@alkavan
Copy link
Contributor Author

alkavan commented Mar 10, 2025

Added missing test for networks in droplet build() function.

@alkavan
Copy link
Contributor Author

alkavan commented Mar 11, 2025

Refactored the fix to comply with phpstan issue, it's probably for the better, this resulted cleanup of some ignored errors, and manipulating object we are iterating on.

Probably similar @var notation can be done for other stuff as well.

* Tested multiple solutions, this is the nicest and most minimal one, and probably more correct since we are not manipulating values we iterate on.
* This also this resulted some cleanup on the baseline rules file.
@GrahamCampbell GrahamCampbell changed the title IPv6 the CIDR field assigned with wrong type and notation Fixed hydration of the Network class with IPv6 addresses Mar 11, 2025
@GrahamCampbell GrahamCampbell merged commit 88409b7 into DigitalOceanPHP:5.0 Mar 11, 2025
7 checks passed
@GrahamCampbell
Copy link
Member

Thanks for the PR. :)

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