diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index 88a07afbb..9762ab166 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -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 */ diff --git a/src/log.c b/src/log.c index 0093784c9..3dc6f1a81 100644 --- 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; }