-
Notifications
You must be signed in to change notification settings - Fork 204
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
Get correct User IP when has proxy #197
Conversation
RT, we should match all pattern and use the last IP string as user IP.
I just found a problem that, when the correct user IP is an IPv6 address, the regular expressions |
Since Mibew uses symfony, can't we just do something like this to access the user's IP? Or does Mibew not have that part of symfony? |
@snewell92 remote ip is get in function get_remote_host : function get_remote_host()
{
$ext_addr = $_SERVER['REMOTE_ADDR'];
$has_proxy = isset($_SERVER['HTTP_X_FORWARDED_FOR'])
&& $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR'];
if ($has_proxy) {
$ext_addr = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')';
}
return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $ext_addr;
} It will return (PS: I'm not a professional PHP developer, maybe we should use |
I just found if user more than one proxy, it will be like this: |
|
@faf In regards to 3. Ah, I understand. Global |
@faf Yes , You are right, the code is wrong. I am use IPv4 ip in China, but my site have some IPv6 visitor in some times, so I can merge the test code and wait for a IPv6 user then test it. Change the code chat.php#L584 maybe couldn't fix this problem completely, should we also change the get user ip code at UsersProcessor.php#L268-L273 and UsersProcessor.php#L440-L445? |
@everyx Sure thing. :) I've just created the branch with the appropriate changes. Please, check it if you could. |
@faf Great, I'll test it on this saturday |
@faf I just test my comment code, it's works for me with IPv4 and IPv6, but I check your last commit in ipv6 branch, please check my comment, I think it should have a minimal bug fix :) |
@everyx, Thanks, it fixed now. Do you need any additional time for tests? |
@faf I just find a very strict problem, I got a visitor's address like |
@everyx Ok, fixed. :) |
Closed due to correction of the appropriate issue. |
RT, we should match all pattern and use the last IP string as user IP.
This will also fix Mibew/google-maps-plugin#2