Daily Lucky Numbers:
10
16
20
39
45
49

IPV4

Started by Duban Black, January 08, 2025, 08:46:44 AM

Previous topic - Next topic

Chen Zhen

So does that mod work for you with its latest update?

Chen Zhen

#16
I've attached version 1.2 which does do a single file edit to any template containing the file: "Display.template.php".
I didn't want to go that route because of the file parsing but using PHP mode it doesn't use any DOM manipulation.

If your theme is similar to the default SMF theme then the file parsing will pass.

Duban Black

The mod installed without problem, in both javascript and php versions it shows an IP in ipv4 format, but it is not the correct equivalent of ipv6, it shows another country, another internet operator, another ISP, etc.

Chen Zhen


I told you from the beginning that it's a bogus IP address.
There is no direct equivalent for all IPv6 to IPv4.

So what are you asking for now?
You want it to use a free API for a geo location query & then output a bogus IPv4 from that same geo location?

Why is this so important to you?


Chen Zhen

#19
I found a free up to date PHP library class for IP manipulation which we can try in this modification.
This is not fully tested & I have no idea if it converts the IP's to something close to the same location.
It would have to have currently known IP block locations stored in a file or accessed via an API (likely using Json objects).
I doubt it's any better than what was being used in v1.2 but you can try it out.

Failing that, I would have to find & put together code likely using free API's to get IP data which I don't have time to do at the moment.
My other projects are a priority & someone else has already been put on hold while I looked at this.
I do like a challenge but I just don't have the time to look into this any further at the moment.
Either way it does change the IP adequately, albeit apparently not to your standards due to geo location.

Perhaps the library I found will work for you, give it a try and let me know.

Chen Zhen

Quote from: Duban Black on March 12, 2025, 12:49:58 PMWhat I needed was not to create a fake ipv4, but that the ipv6 is transformed into ipv4, but that the IP information itself is the same, I need an equivalent.

I've tried to explain this to you a few times.
What you ask for is not entirely possible.
ISP's ran out of IPv4 addresses back on November 25, 2019.
Some still have blocks of them from the past but after that date all that's available is IPv6 addresses.

IPv4 ( 32 bit) ~ total number of possible IP's: 4,294,967,296  (588 million reserved)
IPv6 (128 bit) ~ total number of possible IP's: 340,282,366,920,938,000,000,000,000,000,000,000,000

So if I take a IPv6 address & try to convert it to IPv4, I am likely using an existing IPv4 address.
The best that can be done is to have a database store of known IP blocks and attempt to mock one from the same geo location.
At the moment I have no idea if someone or an entity has such a database store of freely available IP information such is required in this scenario via a quick API that can be tapped.

I don't see why one would bother?!
Just deal with the IPv6 addresses.. it's now the norm and the way it has to be.








Duban Black

#21
Yes, I understand, I consulted because in this forum the ipv4 and ipv6 show the same information, not a false one, I understand that you did not know if it was something that your hosting did and not a mod that you have installed here. But I wanted to have the same, just that. For my forum it is important not only because the ipv4 field is visually easier to manipulate and recognize, but because we have several rules associated with the IP.
But if it is not possible to replicate the same logic that your hosting uses, that's fine, we leave it like that.
In other forums I've been to like forumotion, it also shows only ipv4, all ip addresses are transformed to that format.

The version 1.3 in javascript API displays ip in ipv6 format

Chen Zhen

#22
I suspect they tap into an API, have a database store or files that contain up to date global IP information.
There are paid API's that allow access to such information which might be the case.
I've read that we can map a very limited amount of IPv6 to IPv4 but I don't know the accuracy of that mapping calculation.
The PHP class I introduced in v1.3 of this mod may use the proper mapping but I am not certain.

To make it work, one would need something that checks the geo location of the IPv6, attempt to map it to IPv4 & compare the geo location of the mapped IPv4 vs the original IPv6 geo location.
If the geo location fails to match or the IPv6 mapping fails altogether then it needs to pick a random (or somehow calculated mapping) IPv4 from a pool of IP's that correspond to that geo location.


Does PHP mode in the mod correspond to a closer geo location?

Does your IP that you see on this forum correspond to the correct geo location?

Duban Black

Quote from: Chen Zhen on March 13, 2025, 12:17:50 PMDoes PHP mode in the mod correspond to a closer geo location?
In version v1.3 in all modes (javascript, php, javascript api) shows ipv6


Quote from: Chen Zhen on March 13, 2025, 12:17:50 PMDoes your IP that you see on this forum correspond to the correct geo location?

Yes, in this forum the exact equivalent of ipv6 to ipv4 is shown.

Chen Zhen

I've attached an update that fixes the converted IP.

The IP-Lib class will map an IPv6 address to a corresponding IPv4 address if it can be mapped.
I made it so that if it can't be mapped then it returns a bogus IPv4 value.

So for example, in one of your images in this thread you included an IPv6 that has a geo location of somewhere in Mexico.
That specific IPv6 can't be mapped to a corresponding IPv4 address.
You can test it for yourself here: https://dnschecker.org/ipv6-to-ipv4.php



Quote from: Chen Zhen on March 13, 2025, 12:17:50 PMTo make it work, one would need something that checks the geo location of the IPv6, attempt to map it to IPv4 & compare the geo location of the mapped IPv4 vs the original IPv6 geo location.
If the geo location fails to match or the IPv6 mapping fails altogether then it needs to pick a random (or somehow calculated mapping) IPv4 from a pool of IP's that correspond to that geo location.
Someone would have to develop what I previously stated but for now this mod will return an IPv4 even if the orginal IPv6 can't be mapped but syncing the geo location is a crap shoot and highly unlikely.

Duban Black

I have tested the new version and it only transforms in the PHP version, in javascript and javascript api it shows the same.
But it happens because some ipv6 cannot be mapped.

I think it's ok if we leave it here, I really appreciate the effort and help you gave me with this.