],
loggrep => {
qr/\[Host: foo.bar\]/ => 1,
- qr/\[Server: Perl\/[^\s]+\s*\]/ => 1,
+ qr/\{Server: Perl\/[^\s]+\s*\};/ => 1,
},
},
server => {
'match response header remove X-Header-Foo',
'match response header log "*Foo"',
],
- loggrep => { qr/ (?:done|last write \(done\)), \[X-Header-Foo: foo \(removed\)\s*\]/ => 1 },
+ loggrep => { qr/ (?:done|last write \(done\)), \{X-Header-Foo: foo \(removed\)\s*\};/ => 1 },
},
server => {
func => \&http_server,
-/* $OpenBSD: relay.c,v 1.173 2014/07/11 16:59:38 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.174 2014/07/13 00:32:08 benno Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
}
/* Pre-allocate log buffer */
+ con->se_haslog = 0;
con->se_log = evbuffer_new();
if (con->se_log == NULL) {
relay_close(con, "failed to allocate log buffer");
return ((int)a->se_id - b->se_id);
}
+void
+relay_log(struct rsession *con, char *msg)
+{
+ if (con->se_haslog && con->se_log != NULL) {
+ evbuffer_add(con->se_log, msg, strlen(msg));
+ }
+}
+
SPLAY_GENERATE(session_tree, rsession, se_nodes, relay_session_cmp);
-/* $OpenBSD: relay_http.c,v 1.28 2014/07/13 00:18:05 benno Exp $ */
+/* $OpenBSD: relay_http.c,v 1.29 2014/07/13 00:32:08 benno Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
struct kv *kv, *match, *kp, *mp, kvcopy, matchcopy, key;
int addkv, ret;
char buf[IBUF_READ_SIZE], *ptr;
+ char *msg = NULL;
+ const char *meth = NULL;
memset(&kvcopy, 0, sizeof(kvcopy));
memset(&matchcopy, 0, sizeof(matchcopy));
default:
break;
}
- if (kv_log(con->se_log, mp, con->se_label) == -1)
+ if (kv_log(con, mp, con->se_label, cre->dir)
+ == -1)
goto fail;
break;
default:
kv_free(&matchcopy);
}
+ /*
+ * log tag for request and response, request method
+ * and end of request marker ","
+ */
+ if ((con->se_log != NULL) &&
+ ((meth = relay_httpmethod_byid(desc->http_method)) != NULL) &&
+ (asprintf(&msg, " %s",meth) >= 0))
+ evbuffer_add(con->se_log, msg, strlen(msg));
+ free(msg);
+ relay_log(con, cre->dir == RELAY_DIR_REQUEST ? "" : ";");
ret = 0;
fail:
kv_free(&kvcopy);
-/* $OpenBSD: relay_udp.c,v 1.30 2014/07/09 16:42:05 reyk Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.31 2014/07/13 00:32:08 benno Exp $ */
/*
* Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org>
}
/* Pre-allocate log buffer */
+ con->se_haslog = 0;
con->se_log = evbuffer_new();
if (con->se_log == NULL) {
relay_close(con, "failed to allocate log buffer");
-/* $OpenBSD: relayd.c,v 1.129 2014/07/11 11:48:50 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.130 2014/07/13 00:32:08 benno Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
}
int
-kv_log(struct evbuffer *log, struct kv *kv, u_int16_t labelid)
+kv_log(struct rsession *con, struct kv *kv, u_int16_t labelid,
+ enum direction dir)
{
char *msg;
- if (log == NULL)
+ if (con->se_log == NULL)
return (0);
- if (asprintf(&msg, " [%s%s%s%s%s]",
+ if (asprintf(&msg, " %s%s%s%s%s%s%s",
+ dir == RELAY_DIR_REQUEST ? "[" : "{",
labelid == 0 ? "" : label_id2name(labelid),
labelid == 0 ? "" : ", ",
kv->kv_key == NULL ? "(unknown)" : kv->kv_key,
kv->kv_value == NULL ? "" : ": ",
- kv->kv_value == NULL ? "" : kv->kv_value) == -1)
+ kv->kv_value == NULL ? "" : kv->kv_value,
+ dir == RELAY_DIR_REQUEST ? "]" : "}") == -1)
return (-1);
- if (evbuffer_add(log, msg, strlen(msg)) == -1) {
+ if (evbuffer_add(con->se_log, msg, strlen(msg)) == -1) {
free(msg);
return (-1);
}
free(msg);
-
+ con->se_haslog = 1;
return (0);
}
-/* $OpenBSD: relayd.h,v 1.187 2014/07/12 14:34:13 reyk Exp $ */
+/* $OpenBSD: relayd.h,v 1.188 2014/07/13 00:32:08 benno Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
int se_retry;
int se_retrycount;
int se_connectcount;
+ int se_haslog;
struct evbuffer *se_log;
struct relay *se_relay;
struct ctl_natlook *se_cnl;
void kv_purge(struct kvtree *);
void kv_free(struct kv *);
struct kv *kv_inherit(struct kv *, struct kv *);
-int kv_log(struct evbuffer *, struct kv *, u_int16_t);
+void relay_log(struct rsession *, char *);
+int kv_log(struct rsession *, struct kv *, u_int16_t,
+ enum direction);
struct kv *kv_find(struct kvtree *, struct kv *);
int kv_cmp(struct kv *, struct kv *);
int rule_add(struct protocol *, struct relay_rule *, const char