9.1. Trace
----------
-filter trace [name <name>] [random-forwarding] [hexdump]
+filter trace [name <name>] [random-forwarding] [max-fwd <max>] [hexdump]
Arguments:
<name> is an arbitrary name that will be reported in
data. With this parameter, it only forwards a random
amount of the parsed data.
+ <max> is the maximum amount of data that can be forwarded at
+ a time. "max-fwd" option can be combined with the
+ random forwarding. <max> must be an positive integer.
+ 0 means there is no limit.
+
<hexdump> dumps all forwarded data to the server and the client.
This filter can be used as a base to develop new filters. It defines all
struct proxy *proxy;
char *name;
unsigned int flags;
+ unsigned int max_fwd;
};
#define FLT_TRACE(conf, fmt, ...) \
fconf->flags |= FLT_CFG_FL_HTX;
fconf->conf = conf;
- FLT_TRACE(conf, "filter initialized [quiet=%s - fwd random=%s - hexdump=%s]",
+ FLT_TRACE(conf, "filter initialized [quiet=%s - fwd random=%s - hexdump=%s - max fwd=%u]",
((conf->flags & TRACE_F_QUIET) ? "true" : "false"),
((conf->flags & TRACE_F_RAND_FWD) ? "true" : "false"),
- ((conf->flags & TRACE_F_HEXDUMP) ? "true" : "false"));
+ ((conf->flags & TRACE_F_HEXDUMP) ? "true" : "false"),
+ conf->max_fwd);
return 0;
}
ret = len;
}
}
+ if (conf->max_fwd && ret > conf->max_fwd)
+ ret = conf->max_fwd;
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"offset=%u - len=%u - forward=%d",
ret = len;
}
}
+ if (conf->max_fwd && ret > conf->max_fwd)
+ ret = conf->max_fwd;
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"offset=%u - len=%u - forward=%d",
if (ret && (conf->flags & TRACE_F_RAND_FWD))
ret = ha_random() % (ret+1);
+ if (conf->max_fwd && ret > conf->max_fwd)
+ ret = conf->max_fwd;
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"offset=%u - len=%u - forward=%d",
conf->flags |= TRACE_F_RAND_FWD;
else if (strcmp(args[pos], "hexdump") == 0)
conf->flags |= TRACE_F_HEXDUMP;
+ else if (strcmp(args[pos], "max-fwd") == 0) {
+ long long max;
+ if (!*args[pos + 1]) {
+ memprintf(err, "'%s' : '%s' option without value",
+ args[*cur_arg], args[pos]);
+ goto error;
+ }
+ max = atoll(args[pos + 1]);
+ if (max < 0 || max > UINT_MAX) {
+ memprintf(err, "'%s' : '%s' expect unsigned integer (0 to 4294967295 expected)",
+ args[*cur_arg], args[pos]);
+ goto error;
+ }
+ conf->max_fwd = max;
+ pos++;
+ }
else
break;
pos++;