rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Mars on October 01, 2009, 06:03:03 PM

Post by: Mars on October 01, 2009, 06:03:03 PM
found this url to get our ip
Post by: rejetto on October 03, 2009, 10:00:12 AM
thank you mars.

i still don't know how to tell a good one from a bad one.
i mean, sometimes in the past, i had to remove some of these URLs because they shown the wrong IP to some people.
i know little about this, i just had the person to watch the result of these URLs one-by-one, and report me what had a different result.

the code i use on the domains i have is this

Code: [Select]
function localAddress($ip) { return preg_match('°^( *127\.0\.0\.|192\.168|10\.|169\.254|172\.(1[6-9]|2\d|3[01])\.)°',$ip); }

foreach (split('\s*,\s*',getenv('HTTP_X_FORWARDED_FOR')) as $ip)
   if (preg_match('/[0-9.]+/', $ip) && !localAddress($ip)) die($ip);

the only thing i can imagine, is that the non-working services are not checking the x-forwarded-for field.
but i may be wrong about it, also because it should be a field used by http proxies, and HFS is not able to use any. so how could those people meet the problem?
guys, this is truly challenging :P

even if i don't know if this is the right point, yesterday i built a script to check what services are using this field.
all the services in the current list are, except, which is not.
also is not using it.
now i'm unsure if to add it or not.

now i would like to know if this is the criterion to know good services. :-\