The %I must print the server ip address, but currently displays the host name of the server on squid error pages. This patch fixes %I to print the server ip address in the case of a direct connection to destination server or "[unknown]" otherwise.


%I shows hostname on SSL error page

The %I must print the server ip address, but currently displays the host name of
the server on squid error pages.
This patch fixes %I to print the server ip address in the case of a direct 
connection to destination server or "[unknown]" otherwise.

=== modified file 'src/errorpage.cc'
--- src/errorpage.cc	2011-07-29 13:12:29 +0000
+++ src/errorpage.cc	2011-08-30 16:45:05 +0000
@@ -875,42 +875,42 @@
 
     case 'h':
         mb.Printf("%s", getMyHostname());
         break;
 
     case 'H':
         if (request) {
             if (request->hier.host[0] != '\0') // if non-empty string.
                 p = request->hier.host;
             else
                 p = request->GetHost();
         } else if (!building_deny_info_url)
             p = "[unknown host]";
         break;
 
     case 'i':
         mb.Printf("%s", src_addr.NtoA(ntoabuf,MAX_IPSTRLEN));
         break;
 
     case 'I':
-        if (request && request->hier.host[0] != '\0') // if non-empty string
-            mb.Printf("%s", request->hier.host);
+        if (request && request->hier.tcpServer != NULL && request->hier.tcpServer->peerType == HIER_DIRECT)
+            p = request->hier.tcpServer->remote.NtoA(ntoabuf,MAX_IPSTRLEN);
         else if (!building_deny_info_url)
             p = "[unknown]";
         break;
 
     case 'l':
         if (building_deny_info_url) break;
         mb.append(error_stylesheet.content(), error_stylesheet.contentSize());
         do_quote = 0;
         break;
 
     case 'L':
         if (building_deny_info_url) break;
         if (Config.errHtmlText) {
             mb.Printf("%s", Config.errHtmlText);
             do_quote = 0;
         } else
             p = "[not available]";
         break;
 
     case 'm':

Reply via email to