]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: add "option host" log-forward option
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 7 Mar 2025 09:29:12 +0000 (10:29 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 12 Mar 2025 09:51:35 +0000 (10:51 +0100)
add only the parsing part, options are currently unused

include/haproxy/proxy-t.h
src/log.c

index 88a07afbbda1a3cfb9e599196864ca5d5734d32c..9762ab166de91d871894c0ae299358184010af35 100644 (file)
@@ -172,7 +172,15 @@ enum PR_SRV_STATE_FILE {
 #define PR_O3_DONTPARSELOG       0x00000001 /* don't parse log messages */
 #define PR_O3_ASSUME_RFC6587_NTF 0x00000002 /* assume that we are going to receive just non-transparent framing messages */
 
-/* unused: 0x00000004 to  0x80000000 */
+/* unused: 0x00000004 to 0x00000008 */
+
+#define PR_O3_LOGF_HOST_REPLACE  0x00000010
+#define PR_O3_LOGF_HOST_FILL     0x00000020
+#define PR_O3_LOGF_HOST_KEEP     0x00000040
+#define PR_O3_LOGF_HOST_APPEND   0x00000080
+#define PR_O3_LOGF_HOST          0x000000F0
+
+/* unused: 0x00000100 to  0x80000000 */
 /* end of proxy->options3 */
 
 /* Cookie settings for pr->ck_opts */
index 0093784c9e3d95204730324fca5c0111e7cca8be..3dc6f1a81caebc2afeb273e93b45a22c141c660d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -6229,6 +6229,41 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
                if (err_code & ERR_CODE)
                        goto out;
 
+
+               if (strcmp(args[1], "host") == 0) {
+                       int value = 0;
+
+                       if (strcmp(args[2], "replace") == 0)
+                               value = PR_O3_LOGF_HOST_REPLACE;
+                       else if (strcmp(args[2], "fill") == 0)
+                               value = PR_O3_LOGF_HOST_FILL;
+                       else if (strcmp(args[2], "keep") == 0)
+                               value = PR_O3_LOGF_HOST_KEEP;
+                       else if (strcmp(args[2], "append") == 0)
+                               value = PR_O3_LOGF_HOST_APPEND;
+
+                       if (!value) {
+                               ha_alert("parsing [%s:%d] : option 'host' expects {replace|fill|keep|append}.\n", file, linenum);
+                               err_code |= ERR_ALERT | ERR_ABORT;
+                               goto out;
+                       }
+
+                       cfg_log_forward->options3 &= ~PR_O3_LOGF_HOST;
+                       cfg_log_forward->no_options3 &= ~PR_O3_LOGF_HOST;
+
+                       switch (kwm) {
+                               case KWM_STD:
+                                       cfg_log_forward->options3 |= value;
+                                       break;
+                               case KWM_NO:
+                                       cfg_log_forward->no_options3 |= value;
+                                       break;
+                               case KWM_DEF: /* already cleared */
+                                       break;
+                       }
+                       goto out;
+               }
+
                ha_alert("parsing [%s:%d] : unknown option '%s' in log-forward section.\n", file, linenum, args[1]);
                err_code |= ERR_ALERT | ERR_ABORT;
        }