+void Yaz_Proxy::HTTP_Forwarded(Z_GDU *z_gdu)
+{
+ if (z_gdu->which == Z_GDU_HTTP_Request)
+ {
+ Z_HTTP_Request *hreq = z_gdu->u.HTTP_Request;
+ const char *x_forwarded_for =
+ z_HTTP_header_lookup(hreq->headers, "X-Forwarded-For");
+ if (x_forwarded_for)
+ {
+ xfree(m_peername);
+ m_peername = (char*) xmalloc(strlen(x_forwarded_for)+5);
+ sprintf(m_peername, "tcp:%s", x_forwarded_for);
+
+ yaz_log(YLOG_LOG, "%sHTTP Forwarded from %s", m_session_str,
+ m_peername);
+ if (m_log_mask & PROXY_LOG_IP_CLIENT)
+ sprintf(m_session_str, "%ld:%d %.80s 0 ",
+ (long) time(0), m_session_no, m_peername);
+ else
+ sprintf(m_session_str, "%ld:%d 0 ",
+ (long) time(0), m_session_no);
+ }
+ }
+}
+
+void Yaz_Proxy::connect_stat(bool &block, int &reduce)
+{
+
+ m_parent->m_connect.cleanup(false);
+ m_parent->m_connect.add_connect(m_peername);
+
+ int connect_total = m_parent->m_connect.get_total(m_peername);
+ int max_connect = m_parent->m_max_connect;
+
+ if (max_connect && connect_total > max_connect)
+ {
+ yaz_log(YLOG_LOG, "%sconnect not accepted total=%d max=%d",
+ m_session_str, connect_total, max_connect);
+ block = true;
+ }
+ else
+ block = false;
+ yaz_log(YLOG_LOG, "%sconnect accepted total=%d", m_session_str,
+ connect_total);
+
+ int limit_connect = m_parent->m_limit_connect;
+ if (limit_connect)
+ reduce = connect_total / limit_connect;
+ else
+ reduce = 0;
+}
+