Skip to content

Add IpUtils::isPrivateIp docs #18102

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 1 commit into from
Mar 21, 2023
Merged

Add IpUtils::isPrivateIp docs #18102

merged 1 commit into from
Mar 21, 2023

Conversation

danielburger1337
Copy link
Contributor

@carsonbot carsonbot added this to the 6.3 milestone Mar 20, 2023
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Mar 20, 2023
…r1337)

This PR was squashed before being merged into the 6.3 branch.

Discussion
----------

[HttpFoundation] Add IpUtils::isPrivateIp

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | symfony/symfony-docs#18102

This is only my second PR for this project, so I hope I followed all the guidelines correctly.
Recently I had more and more use cases where I had to make exceptions (mostly rate limiting) for private IP ranges.

Symfony currently does not provide an easy way to check if an IP is private or public but implements such logic internally (private constant) for the [NoPrivateNetworkHttpClient](https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php).

This PR intents to make the private subnet list reusable by adding it to [IpUtils](https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/HttpFoundation/IpUtils.php).

In the original PR of the NoPrivateNetworkHttpClient it was also briefly mentioned that this constant may have value when made public. #35566 (comment)

I think symfony should and always should have exposed this constant.

Commits
-------

6471582 [HttpFoundation] Add IpUtils::isPrivateIp
@OskarStark
Copy link
Contributor

OskarStark commented Mar 21, 2023

Thank you Daniel and congratulations on your first contribution to the Symfony documentation 🎉

@OskarStark OskarStark merged commit 3022f02 into symfony:6.3 Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants