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

GetCurrentIpAddress() MapToIpv4() turns ipv6 in nonsense IPv4 addresses #6771

Closed
danFbach opened this issue Jul 17, 2023 · 1 comment
Closed

Comments

@danFbach
Copy link
Contributor

danFbach commented Jul 17, 2023

nopCommerce version: 4.6.3

I'm wondering if there is a reason that the WebHelper function GetCurrentIpAddress() uses MapToIpv4() on all IP addresses?

I've built a plugin that uses IP Quality Score's API to check user's IP addresses and when users connect with IPv6, the MapToIPv4() function translates them into nonsensical IPv4 address, like 0.0.0.9 (obviously invalid) or 250.204.72.95 (reserved IP space, not used), neither of which are valid IPv4 addresses.

in the database:
ActivityLog.IpAddress is varchar(200)
Customer.LastIpAddress is longtext
ForumPost.IPAddress is varchar(100)
Log.IpAddress is varchar(200)
Order.CustomerIp is longtext

I'm not sure if there are others, but considering these entities as example, i highly doubt any entities were made with an IP property specifically long enough for IPv4 (15 characters.)

The longest an IPv6 address can be is 39 characters. Or in the worst, highly unlikely, case IPv4 mapped to IPv6, it can be 45 characters long. So, even this shouldn't produce a problem for the given database entities.

I could see a change to this possibly making problems for plugins expecting an IPv4 address - but they should be compensating for that on their own if they require it.

@RomanovM RomanovM assigned exileDev and skoshelev and unassigned exileDev Jul 17, 2023
@skoshelev skoshelev added this to the Version 4.70 milestone Aug 15, 2023
skoshelev added a commit that referenced this issue Aug 16, 2023
Bringing one type of IP addresses to another did not make sense, since the end result of such a conversion gave an invalid result
@skoshelev
Copy link
Contributor

Hi @danFbach. I looked at the implementation of the MapToIpv4 method and agree with you that such an operation is not capable of giving any real result. Thank you for your help

Closed #6771

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

No branches or pull requests

4 participants