]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Report ICAP server clock skew based on the Date header in OPTIONS response.
authorwessels <>
Wed, 14 Dec 2005 01:38:05 +0000 (01:38 +0000)
committerwessels <>
Wed, 14 Dec 2005 01:38:05 +0000 (01:38 +0000)
To make this work I added timestamp() and ttl() methods to ICAPOptions
and renamed the private members.

src/ICAP/ICAPOptions.cc
src/ICAP/ICAPOptions.h
src/ICAP/ICAPServiceRep.cc

index 57172d2c46f240ec3ccee77a05989c3c7ce5190f..16deaf302ca97b323b8194e80d9f4f77aa2c4c63 100644 (file)
@@ -5,7 +5,7 @@
 
 ICAPOptions::ICAPOptions(): error("unconfigured"), method(ICAP::methodNone),
         max_connections(-1), allow204(false),
-        preview(-1), ttl(-1), transfer_ext(NULL)
+        preview(-1), theTTL(-1), transfer_ext(NULL)
 {
     transfers.preview = transfers.ignore = transfers.complete = NULL;
     transfers.other = TRANSFER_NONE;
@@ -104,7 +104,7 @@ bool ICAPOptions::fresh() const
 time_t ICAPOptions::expire() const
 {
     Must(valid());
-    return ttl >= 0 ? timestamp + ttl : -1;
+    return theTTL >= 0 ? theTimestamp + theTTL : -1;
 }
 
 void ICAPOptions::configure(const HttpReply *reply)
@@ -134,12 +134,12 @@ void ICAPOptions::configure(const HttpReply *reply)
 
     cfgIntHeader(h, "Max-Connections", max_connections);
 
-    cfgIntHeader(h, "Options-TTL", ttl);
+    cfgIntHeader(h, "Options-TTL", theTTL);
 
-    timestamp = httpHeaderGetTime(h, HDR_DATE);
+    theTimestamp = httpHeaderGetTime(h, HDR_DATE);
 
-    if (timestamp < 0)
-        timestamp = squid_curtime;
+    if (theTimestamp < 0)
+        theTimestamp = squid_curtime;
 
     if (httpHeaderGetByNameListMember(h, "Allow", "204", ',').size())
         allow204 = true;
index cf22aed25ec2ff2ee4e9043cbf36f5d73a32d14c..e95246307b70643f259b896d8155b8484c748883 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPOptions.h,v 1.2 2005/11/21 23:46:27 wessels Exp $
+ * $Id: ICAPOptions.h,v 1.3 2005/12/13 18:38:05 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -57,6 +57,9 @@ public:
     bool valid() const;
     bool fresh() const;
     time_t expire() const;
+    time_t timestamp() const { return theTimestamp; };
+
+    int ttl() const { return theTTL; };
 
     typedef enum { TRANSFER_NONE, TRANSFER_PREVIEW, TRANSFER_IGNORE, TRANSFER_COMPLETE } transfer_type;
     transfer_type getTransferExt(const char *);
@@ -88,8 +91,8 @@ public:
     transfers;
 
 protected:
-    int ttl;
-    time_t timestamp;
+    int theTTL;
+    time_t theTimestamp;
 
     //  The list of pairs "file extension <-> transfer type"
 
index dfda856ca0f4e6d6dd4dbbbca72649478607cf90..2df5da6b6c2d49f331bb44893b81f30a964a71b0 100644 (file)
@@ -288,6 +288,16 @@ void ICAPServiceRep::changeOptions(ICAPOptions *newOptions)
         debugs(93,1, "WARNING: Squid is configured to use ICAP method " << ICAP::methodStr(method) <<
                "for service " << uri.buf() <<
                "but OPTIONS response declares the method is " << ICAP::methodStr(theOptions->method));
+
+
+    /*
+     *  Check the ICAP server's date header for clock skew
+     */
+    int skew = abs((int)(theOptions->timestamp() - squid_curtime));
+
+    if (skew > theOptions->ttl())
+        debugs(93, 1, host.buf() << "'s clock is skewed by " << skew << " seconds!");
+
 }
 
 static