I am sending a new patch which does not touch the current ">la"
formating code but instead adjust the "la" formatting code to follow
rules as discussed by Amos.
Please look in the cf.data.per documentation and the
LFT_CLIENT_LOCAL_USED_IP/LFT_CLIENT_LOCAL_USED_PORT enum names I am using...
On 09/01/2011 12:08 AM, Amos Jeffries wrote:
%>la to always display tcpClient->local with a config documentation note
about it being external IPs in intercepted traffic.
%la to display cache.caddr with a config documentation note that it is
the squid receiving *_port details as known by Squid (caddr also used by
icp_port and htcp_port on their messages).
Amos
%la for intercepted connections
This patch adjusts the %la logformat code handling for intercepted connections
based on the following rules:
- If the corresponding http_port or https_port option has an explicit
listening host name or IP address, then log the IP address.
- Otherwise, log a dash character.
Also adjusts %lp logformat code handling for intercepted connections to always
log the port number from the corresponding http_port or https_port option.
=== modified file 'src/AccessLogEntry.h'
--- src/AccessLogEntry.h 2011-08-20 08:21:11 +0000
+++ src/AccessLogEntry.h 2011-08-27 14:38:03 +0000
@@ -39,6 +39,7 @@
#if ICAP_CLIENT
#include "adaptation/icap/Elements.h"
#endif
+#include "ProtoPort.h"
/* forward decls */
class HttpReply;
@@ -148,6 +149,7 @@
const char *ssluser;
#endif
+ http_port_list *port;
} cache;
=== modified file 'src/cf.data.pre'
--- src/cf.data.pre 2011-08-30 09:10:14 +0000
+++ src/cf.data.pre 2011-09-06 14:54:38 +0000
@@ -2897,6 +2897,13 @@
>la Local IP address the client connected to
>lp Local port number the client connected to
+ la Local IP address the client connection uses.
+ This tag includes the direct client connections
+ plus the intercepted connections.
+ lp Local port number the client connection uses.
+ This tag includes the direct client connetions
+ plus the intercepted connections.
+
<a Server IP address of the last server or peer connection
<A Server FQDN or peer name
<p Server port number of the last server or peer connection
=== modified file 'src/client_side.cc'
--- src/client_side.cc 2011-08-29 03:47:54 +0000
+++ src/client_side.cc 2011-09-06 14:40:39 +0000
@@ -640,7 +640,10 @@
al.cache.caddr.SetNoAddr();
- if (getConn() != NULL) al.cache.caddr = getConn()->log_addr;
+ if (getConn() != NULL) {
+ al.cache.caddr = getConn()->log_addr;
+ al.cache.port = cbdataReference(getConn()->port);
+ }
al.cache.requestSize = req_sz;
al.cache.requestHeadersSize = req_sz;
=== modified file 'src/format/Format.cc'
--- src/format/Format.cc 2011-08-25 12:32:02 +0000
+++ src/format/Format.cc 2011-09-06 15:49:38 +0000
@@ -365,14 +365,30 @@
}
break;
- case LFT_CLIENT_LOCAL_IP_OLD_31:
+ case LFT_CLIENT_LOCAL_USED_IP:
+ if (al->tcpClient != NULL) {
+ if ((al->request->flags.spoof_client_ip || al->request->flags.intercepted) && al->cache.port) {
+ if (!al->cache.port->s.IsAnyAddr())
+ out = al->cache.port->s.NtoA(tmp, sizeof(tmp));
+ } else
+ out = al->tcpClient->local.NtoA(tmp, sizeof(tmp));
+ }
+ break;
case LFT_CLIENT_LOCAL_IP:
if (al->tcpClient != NULL) {
out = al->tcpClient->local.NtoA(tmp,sizeof(tmp));
}
break;
- case LFT_CLIENT_LOCAL_PORT_OLD_31:
+ case LFT_CLIENT_LOCAL_USED_PORT:
+ if (al->tcpClient != NULL) {
+ if ((al->request->flags.spoof_client_ip || al->request->flags.intercepted) && al->cache.port)
+ outint = al->cache.port->s.GetPort();
+ else
+ outint = al->tcpClient->local.GetPort();
+ doint = 1;
+ }
+ break;
case LFT_CLIENT_LOCAL_PORT:
if (al->tcpClient != NULL) {
outint = al->tcpClient->local.GetPort();
=== modified file 'src/format/Tokens.cc'
--- src/format/Tokens.cc 2011-08-29 11:46:04 +0000
+++ src/format/Tokens.cc 2011-09-06 15:49:38 +0000
@@ -62,9 +62,9 @@
static struct TokenTableEntry TokenTable2C[] = {
{">la", LFT_CLIENT_LOCAL_IP},
- {"la", LFT_CLIENT_LOCAL_IP_OLD_31},
+ {"la", LFT_CLIENT_LOCAL_USED_IP},
{">lp", LFT_CLIENT_LOCAL_PORT},
- {"lp", LFT_CLIENT_LOCAL_PORT_OLD_31},
+ {"lp", LFT_CLIENT_LOCAL_USED_PORT},
/*{ "lA", LFT_LOCAL_NAME }, */
{"<la", LFT_SERVER_LOCAL_IP},
@@ -496,12 +496,12 @@
type = LFT_HTTP_SENT_STATUS_CODE;
break;
- case LFT_CLIENT_LOCAL_IP_OLD_31:
+ case LFT_CLIENT_LOCAL_USED_IP:
debugs(46, 0, "WARNING: The \"la\" formatting code is deprecated. Use the \">la\" instead.");
type = LFT_CLIENT_LOCAL_IP;
break;
- case LFT_CLIENT_LOCAL_PORT_OLD_31:
+ case LFT_CLIENT_LOCAL_USED_PORT:
debugs(46, 0, "WARNING: The \"lp\" formatting code is deprecated. Use the \">lp\" instead.");
type = LFT_CLIENT_LOCAL_PORT;
break;
=== modified file 'src/format/Tokens.h'
--- src/format/Tokens.h 2011-08-25 12:32:02 +0000
+++ src/format/Tokens.h 2011-09-06 15:49:38 +0000
@@ -35,9 +35,9 @@
LFT_SERVER_PORT,
LFT_CLIENT_LOCAL_IP,
- LFT_CLIENT_LOCAL_IP_OLD_31,
+ LFT_CLIENT_LOCAL_USED_IP,
LFT_CLIENT_LOCAL_PORT,
- LFT_CLIENT_LOCAL_PORT_OLD_31,
+ LFT_CLIENT_LOCAL_USED_PORT,
/*LFT_LOCAL_NAME, */
LFT_SERVER_LOCAL_IP,
=== modified file 'src/log/access_log.cc'
--- src/log/access_log.cc 2011-08-21 00:12:49 +0000
+++ src/log/access_log.cc 2011-08-27 14:36:50 +0000
@@ -596,6 +596,7 @@
HTTPMSGUNLOCK(aLogEntry->icap.reply);
HTTPMSGUNLOCK(aLogEntry->icap.request);
#endif
+ cbdataReferenceDone(aLogEntry->cache.port);
}
int