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

IPV6 vs IPV4 already voted log #77

Open
kvnorde opened this issue Jan 9, 2024 · 7 comments
Open

IPV6 vs IPV4 already voted log #77

kvnorde opened this issue Jan 9, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@kvnorde
Copy link

kvnorde commented Jan 9, 2024

I think this poll script is a very nice script. However, it is now logged on IPV6. Can this also become IPV4 (optional)? IPV6 has the disadvantage that it changes every few hours (worldwide this is the case with IPV6). IPV4 doesn't have that problem. I would like to log on IPV4 (who has already voted).

Greets Kees.

@Jefferson49
Copy link
Owner

Jefferson49 commented Jan 9, 2024

Hi Kees,

very interesting question! Since I only saw IPv4 Iaddresses in my own installations, I thought that Sexy Polling uses IPv4 as a default.
It is interesting to learn that alternatively, IPv6 can show up.

I just had a look at the code. The IP address is extracted by the following code:

$server = Factory::getApplication()->input->server;
$REMOTE_ADDR = null;
if($server->get('HTTP_X_FORWARDED_FOR') !== null) { list($REMOTE_ADDR) = explode(',', $server->get('HTTP_X_FORWARDED_FOR')); }
elseif($server->get('HTTP_X_REAL_IP') !== null) { $REMOTE_ADDR = $server->get('HTTP_X_REAL_IP'); }
elseif($server->get('REMOTE_ADDR') !== null) { $REMOTE_ADDR = $server->get('REMOTE_ADDR'); }
else { $REMOTE_ADDR = 'Unknown'; }
$ip = $REMOTE_ADDR;

The related values seem to be extracted from the HTTP request headers and seem to be out of control of the Joomla API. I found the following source on stackoverflow, which says that it is decided by the browser, which version of IP will be used:
https://stackoverflow.com/questions/31233216/how-show-ipv4-only-with-remote-addr-in-php

@kvnorde
Copy link
Author

kvnorde commented Jan 9, 2024

Thanks for your quick response!

I don't think it's browser related.
For example, if I look at this site:
https://www.watzijnmijnips.nl/

Then I see that both versions (can) be shown.
The problem with IPV6 is that the IP address changes every few hours (that's how IPV6 was invented) and there is therefore little point in logging on IPV6. IPV4 remains the same and does not change every few hours.

Is it possible to build IPV4 into the script, or at least make it optional (or, for example, give a choice whether you want to log IPV4 or IPV6)?

Thanks again for the quick response, nice script!

@Jefferson49
Copy link
Owner

Jefferson49 commented Jan 9, 2024

For example, if I look at this site: https://www.watzijnmijnips.nl/

In my case, it looks like this, e.g. only IPv4 is used:
ip

My understanding is that it depends on the browser, server, proxy, etc., which version of IP is used. As a result, either IPv4, or IPv6, or both in parallel is used.

The problem with IPV6 is that the IP address changes every few hours (that's how IPV6 was invented) and there is therefore little point in logging on IPV6

Yes, I can understand this issue about IPv6 changing. How I understand your request is that you want to get the IPv4 address in case IPv4/IPv6 are used in parallel.

If there was an API in Joomla (e.g. something like ->server->getIP(string $IPversion) ), I could retrieve the IP in a certain version. However, Joomla and PHP seemingly only offer the variables shown above, e.g. the provided values from the HTTP request headers like $REMOTE_ADDR.

I am not an expert for those HTTP request header values. If you can give me a hint how I can get IPv4 out of these values if IPv4/IPv6 is used in parallel, I will try.

@kvnorde
Copy link
Author

kvnorde commented Jan 10, 2024

I have searched the internet for a while, but I have not yet been able to find a solution on how to specifically read an IPV4 address. I think it should be possible because in the example I sent IPV4 and IPV6 are also specified separately.

Unfortunately, my PHP knowledge does not go so far that I immediately have an answer/solution for it.

@Jefferson49
Copy link
Owner

Jefferson49 commented Jan 13, 2024

I spent some time to check this issue in more depth. In order to check the behavior I found a possibility in my network to switch between IPv4 and IPv6 and the combination of both. With debugging on the Joomla server, I tried to identify how PHP handles these situations.

The result of these examination was that PHP always offers information in IPv4 only or IPv6 only and seemingly never a mixture of IPv4/IPv6 information.

Another way to see this is to use a phpinfo file and check for the values of the PHP Variables "$_SERVER['HTTP ...".

PHP Variables

Therefore, it looks like it is not possible to solve this issue.

@Jefferson49
Copy link
Owner

Some additional idea: Maybe, you can identify an option to configure your server to use IPv4?

@kvnorde
Copy link
Author

kvnorde commented Jan 15, 2024

My provider uses an IPV4 and an IPV6 address as standard. They cannot (or do not want to) change this. And if they want to change it, they have to do it for everyone to make it work properly :)

I think it's nice that you think so well about a solution.
I still find it strange that the website https://www.watzijnmijnips.nl/ provides 2 IP addresses (1 IPV4 and 1 IPV6).
WatZijnMijnIPs.nl
Uw IP-adressen:
IPv4 | XX.XX.XXX.XXX
IPv6 | XXXX:XXXX:XXXX:X:XXXX:XXXX:XXXX:XXXX

So you would think that there should be a possibility to read IPV4 and IPV6. But I wouldn't dare say how :)

@Jefferson49 Jefferson49 added enhancement New feature or request Joomla 4 Issue occurs while using plugin in Joomla 4 Joomla 3 Issue occurs while using plugin in Joomla 3 Joomla 5 Issue occurs while using plugin in Joomla 5 and removed Joomla 4 Issue occurs while using plugin in Joomla 4 Joomla 3 Issue occurs while using plugin in Joomla 3 Joomla 5 Issue occurs while using plugin in Joomla 5 labels Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants