+
+
+/*********************************************************************
+ *
+ * Function : set_client_address
+ *
+ * Description : Sets the client address that will be used to enable,
+ * disable, or apply client tags.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ * 2 : headers = Client headers
+ *
+ * Returns : void.
+ *
+ *********************************************************************/
+void set_client_address(struct client_state *csp, const struct list *headers)
+{
+ if (csp->config->trust_x_forwarded_for)
+ {
+ const char *client_address;
+
+ client_address = get_header_value(headers, "X-Forwarded-For:");
+ if (client_address != NULL)
+ {
+ csp->client_address = strdup_or_die(client_address);
+ log_error(LOG_LEVEL_HEADER,
+ "Got client address %s from X-Forwarded-For header",
+ csp->client_address);
+ }
+ }
+
+ if (csp->client_address == NULL)
+ {
+ csp->client_address = strdup_or_die(csp->ip_addr_str);
+ }
+}
+
+#else
+#error Compiling client-tags.c without FEATURE_CLIENT_TAGS
+#endif /* def FEATURE_CLIENT_TAGS */