Summary | Wunderground doesn't use client IP when searching by IP |
Queue | Horde Framework Packages |
Queue Version | Git master |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org |
Requester | arjen+horde (at) de-korte (dot) org |
Created | 12/12/2011 (4953 days ago) |
Due | |
Updated | 12/14/2011 (4951 days ago) |
Assigned | 12/12/2011 (4953 days ago) |
Resolved | 12/14/2011 (4951 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | Yes |
New Attachment: Service_Weather_Base.diff
Add method to check validity/uniqueness of IP address before using.
Bug: 108572 files changed, 42 insertions(+), 3 deletions(-)
http://git.horde.org/horde-git/-/commit/c79abee4a9349b6fb0035a5d180b6a64a69f6d29
times. See attached patch.
Add method to check validity/uniqueness of IP address before using.
Bug: 108572 files changed, 42 insertions(+), 3 deletions(-)
http://git.horde.org/horde-git/-/commit/c79abee4a9349b6fb0035a5d180b6a64a69f6d29
Bug: 10857Actually use the ip address we pass into the method.Signed-off-by: Michael J Rubinsky <mrubinsk@horde.org>
1 files changed, 1 insertions(+), 1 deletions(-)
http://git.horde.org/horde-git/-/commit/a8e5006d4eb19ec694004b6cf51911ad25f54e0c
dependency for something so simple. The code to check the validity
of the IP address is pretty straightforward, so I'll just add this
check directly to the Service_Weather package.
protected function _getLocationByIp($ip)
{
if (empty($ip)) {
throw new Horde_Service_Weather_Exception('Error, trying
to lookup empty IP.');
}
// Check if the provided IP is from a reserved range of IPv4 addresses
// that should never appear on the public internet (see RFC3330) and
// for which no geolookup will ever be possible. In this
case, fallback
// to the server IP as a last resort (which is better than
nothing, but
// not much).
if ((sscanf($ip, "%d.%d.%d.%d", $a, $b, $c, $d) === 4) &&
(($a === 10) || // 10/8 -
Private-Use Networks
($a === 127) || // 127/8 - Loopback
($a === 169 && $b === 254) || // 169.254/16 - Link Local
($a === 172 && $b >= 16 && $b <= 31) || // 172.16/12 -
Private-Use Networks
($a === 192 && $b === 0 && $c === 2) || // 192.0.2/24 - Test-Net
($a === 192 && $b === 168))) { // 192.168/16 -
Private-Use Networks
Horde::logMessage('Using server IP instead of client IP
[' . $ip . '] (not globally unique)');
return $this->_makeRequest(self::API_URL . '/api/' .
$this->_apiKey
. '/geolookup/q/autoip.json');
} else {
return $this->_makeRequest(self::API_URL . '/api/' .
$this->_apiKey
. '/geolookup/q/autoip.json?geo_ip=' . $ip);
}
}
This indeed is simple enough. Besides the fact that Net_CheckIP2 is
broken when it comes to checking the Link Local addresses and it also
doesn't include the Loopback address. I'll prepare a patch later today.
dependency for something so simple. The code to check the validity of
the IP address is pretty straightforward, so I'll just add this check
directly to the Service_Weather package.
Identities' location pref, and Turba's My Contact is checked.
the Block's location setting first.
wouldn't use this at all, the locations are too far off to be useful
here.
Identities' location pref, and Turba's My Contact is checked.
standards and should really be done through the Horde_Autoloader.
Unfortunately, I'm not that fluent in PHP that I'm able to figure out
how to do this... :-(
New Attachment: WeatherUnderground.diff
_getLocationByIp. If the address is found to be local, use the server
IP address to determine the location, otherwise use the client IP
address. Most of the time, client and server will be at the same
location when the connection does is local. This is not perfect, but
it is the best we can do.
For me the geolookup based on client/server IP is not very useful by
the way. If a result is found, many times the location is so far off,
that it is not useable anyway (in The Netherlands, many lookups result
in a location near the AMS-IX, which is *way* off in many parts of the
country).
I wouldn't be too heartbroken if the WeatherUnderground driver
wouldn't use this at all, the locations are too far off to be useful
here.
address space when the client and the (web)server are connected
locally. This means that in this case we don't have to give up, but
rather should use the (web)server public IP instead.
New Attachment: timeobjects.diff
This probably could (should) be improved to not bluntly require
Net/CheckIP2, but rather use it when it is present and skip the check
if it isn't.
State ⇒ Assigned
State ⇒ Unconfirmed
New Attachment: Service_Weather.diff
Patch ⇒ Yes
Milestone ⇒
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ Wunderground doesn't use client IP when searching by IP
Queue ⇒ Horde Framework Packages
omits passing the client IP that is passed in _getLocationByIp.
Although this is valid (in terms of the Wunderground API), this will
cause the lookup to be based on the server IP, which might not be
where the client is located. The attached patch fixes this.
Another thing that pops up after applying this patch, is that the
driver will happily attempt to do geolookups for IP addresses from
reserved (RFC1918) or ZeroConf (RFC3330) address space that are known
to fail. Although this will be dealt with cleanly by Wunderground, we
could save the cost of looking this up by checking this beforehand
(through Net/CheckIP2 or someting similar). But this would probably
need to be done in timeobjects/lib/Driver/Weather.php, where this
might be handled for all drivers.