Skip to content
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

Feature/internet extension #8

Merged
merged 4 commits into from
Oct 24, 2024
Merged

Feature/internet extension #8

merged 4 commits into from
Oct 24, 2024

Conversation

GautierDele
Copy link
Contributor

Doesn't contain user agent


public function ipv4(): string
{
return long2ip($this->randomizer->getInt(0, 1) === 0 ? $this->randomizer->getInt(-2147483648, -2) : $this->randomizer->getInt(16777216, 2147483647));
Copy link
Collaborator

Choose a reason for hiding this comment

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

The negative numbers ensures compatibility with 32 bits systems, but I think we should check all the positive numbers to ensure compatibility with 64 bits systems. Cause ip2long (invert of long2ip) always return positive numbers so a lot of 64 bits systems are storing IPs as int from 0 to 4294967295

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems you are right, the documentation is poor on that side, I don't know if I should be avoiding local ips, like in this case, what do you think ?

$res = [];

for ($i = 0; $i < 8; $i++) {
$res[] = dechex($this->randomizer->getInt(0, 65535));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you prefer this way to ensure compatibility, or to use inet_ntop with a randomizer, which is the prefered way of using IPv6 when PHP is compiled with IPv6 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did have a look at this but i'm not familiar enough with this function and documentation didn't help me on that, but this isn't a reason, will need to have a look

Copy link
Collaborator

@martinsoenen martinsoenen left a comment

Choose a reason for hiding this comment

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

Here are some questions about IPs

@GautierDele
Copy link
Contributor Author

@martinsoenen should be fixed 😉

@GautierDele GautierDele merged commit d4bf6fe into main Oct 24, 2024
4 checks passed
@GautierDele GautierDele deleted the feature/internet-extension branch October 24, 2024 13:21
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