un33k / node-ipware

Returns the real IP address of users in Node.js
MIT License
124 stars 17 forks source link

ip with port #10

Closed swrocket closed 8 years ago

swrocket commented 8 years ago

I tried to use the library and found a strange issue. My request has an x-forwarded-for header with a valid ip but it has a port specified (x-forwarded-for: "99.247.8.214:65263") I keep getting 127.0.0.1 instead of this ip and I'm thinking it's because the is_valid_ip method is returning false. Anyone run into this?

TIA

Andrew

un33k commented 8 years ago

@swrocket Unfortunately there is no standard when it comes to these header fields. I have not heard of this case yet. Do you have access to the proxy server that sets the header?

Alternatively, you can check to see if another field is also populated with the IP address (ONLY) and configure ipware to look at that field first.

swrocket commented 8 years ago

I don't have access to the proxy. The only IP is in that field. I was thinking that when the IP is sent into the is_valid_ip method, it gets checked for, and stripped of, a port if it's there. I'm going to try that on my local copy and see what happens

un33k commented 8 years ago

You need to consider IPv6 Addresses as well.

Example: IPv4 -- 10.10.1.1:8080 - You can slipt the address by : and grab the first part. IPv6 -- [1fff:0:a88:85a3::ac1f]:8001 -- notice that you have multiple :s.

On Thu, Mar 10, 2016 at 10:11 AM, Andrei Merisanu notifications@github.com wrote:

I don't have access to the proxy. The only IP is in that field. I was thinking that when the IP is sent into the is_valid_ip method, it gets checked for, and stripped of, a port if it's there. I'm going to try that on my local copy and see what happens

— Reply to this email directly or view it on GitHub https://github.com/un33k/node-ipware/issues/10#issuecomment-194895491.

swrocket commented 8 years ago

Good point I'll work on that