[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1622: Tolerate entries in geoip-cache that have no timestamp. If a (in trunk: . doc src/util/geoip)



Author: edmanm
Date: 2007-01-29 21:18:24 -0500 (Mon, 29 Jan 2007)
New Revision: 1622

Modified:
   trunk/
   trunk/doc/geoip-spec.txt
   trunk/src/util/geoip/geoipcacheitem.cpp
Log:
 r1644@adrastea:  edmanm | 2007-01-29 20:38:48 -0500
 Tolerate entries in geoip-cache that have no timestamp. If an entry does not
 have a timestamp, use the current date and time.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /vidalia/local/trunk [r1644] on 54b3572a-7227-0410-958f-53ecd705b71a

Modified: trunk/doc/geoip-spec.txt
===================================================================
--- trunk/doc/geoip-spec.txt	2007-01-29 20:07:55 UTC (rev 1621)
+++ trunk/doc/geoip-spec.txt	2007-01-30 02:18:24 UTC (rev 1622)
@@ -97,14 +97,15 @@
 
    We cache geographic information in an unsorted text file called
    "~/.vidalia/geoip-cache" (on Windows, the cache file is stored in
-   %APPDATA%\Vidalia\geoip-cache) along with a Unix timestamp, such
-   as:
+   %APPDATA%\Vidalia\geoip-cache) along with an optional Unix 
+   timestamp, such as:
 
        206.124.149.146,Bellevue,WA,US,47.6051,-122.1134:1159123625
 
-   We load the cache file on startup, discard all entries that are
-   over a month old, and write a new version. After that the cache
-   file is append-only.
+   If no timestamp is associated with a particular cache entry, the
+   current date and time will be used. We load the cache file on
+   startup, discard all entries that are over a month old, and write
+   a new version. After that the cache file is append-only.
 
    The requests are done over Tor, as ordinary socks requests to the
    local Tor client. Vidalia will query the local Tor client for its 

Modified: trunk/src/util/geoip/geoipcacheitem.cpp
===================================================================
--- trunk/src/util/geoip/geoipcacheitem.cpp	2007-01-29 20:07:55 UTC (rev 1621)
+++ trunk/src/util/geoip/geoipcacheitem.cpp	2007-01-30 02:18:24 UTC (rev 1622)
@@ -57,8 +57,9 @@
 
 /** Returns a GeoIpCacheItem from a string as read from the cache that was
  * written to disk. The format is:
- *                     <Geo IP Data>:<Timestamp>
+ *                     <Geo IP Data>[:<Timestamp>]
  *
+ * If no value for Timestamp is given, the current date and time will be used.
  * If the string cannot be parsed for valid cached GeoIP data, then an empty
  * GeoIpCacheItem object is returned. The calling method should call isEmpty()
  * on the returned GeoIpCacheItem object to ensure it got a valid object.
@@ -68,10 +69,13 @@
 {
   QDateTime timestamp;
   QStringList cacheData = cacheString.split(":");
- 
-  if (cacheData.size() >= 2) {
+
+  if (cacheData.size() >= 1) {
     GeoIp geoip = GeoIp::fromString(cacheData.at(0));
-    timestamp.setTime_t(cacheData.at(1).toUInt());
+    if (cacheData.size() >= 2)
+      timestamp.setTime_t(cacheData.at(1).toUInt());
+    else
+      timestamp = QDateTime::currentDateTime();
     return GeoIpCacheItem(geoip, timestamp);
   }
   return GeoIpCacheItem();