summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorOto Šťáva <oto.stava@nic.cz>2023-03-21 07:35:19 +0100
committerOto Šťáva <oto.stava@nic.cz>2023-03-21 07:35:19 +0100
commitc3d535da0c3010101efe42a8b5cea9f33521731c (patch)
tree062a23bcd4b36e94e0ccdc05f151adbc7b2dd1e8 /daemon
parentdaemon/session2: documentation edits (diff)
downloadknot-resolver-c3d535da0c3010101efe42a8b5cea9f33521731c.tar.xz
knot-resolver-c3d535da0c3010101efe42a8b5cea9f33521731c.zip
daemon/session2: rename http flag to custom_emalf_handling
The session2 API as well as everything that uses it should be as independent of the underlying protocols as possible, providing functionality through firing different events. There was a left-over `struct session2::http` flag, which allowed the DoH layer to return a Bad Request reply. This has been renamed so that it does not mention HTTP apart from the example in the doc comments, in case another protocol needs to use this functionality at some point.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/http.c2
-rw-r--r--daemon/session2.h7
-rw-r--r--daemon/worker.c4
3 files changed, 6 insertions, 7 deletions
diff --git a/daemon/http.c b/daemon/http.c
index 8633c664..d028113b 100644
--- a/daemon/http.c
+++ b/daemon/http.c
@@ -877,7 +877,7 @@ static int pl_http_sess_init(struct protolayer_manager *manager,
struct sockaddr *peer = session2_get_peer(manager->session);
kr_log_debug(DOH, "[%p] h2 session created for %s\n", (void *)http->h2, kr_straddr(peer));
- manager->session->http = true;
+ manager->session->custom_emalf_handling = true;
ret = kr_ok();
diff --git a/daemon/session2.h b/daemon/session2.h
index 4f07cb49..392e1935 100644
--- a/daemon/session2.h
+++ b/daemon/session2.h
@@ -842,9 +842,10 @@ struct session2 {
* Set during protocol layer initialization by the stream-based layer. */
bool stream : 1;
- /** If true, the session contains a HTTP protocol layer.
- * Set during protocol layer initialization by the HTTP layer. */
- bool http : 1;
+ /** If true, the session contains a protocol layer with custom handling
+ * of malformed queries. This is used e.g. by the HTTP layer, which will
+ * return a Bad Request status on a malformed query. */
+ bool custom_emalf_handling : 1;
/** If true, a connection is established. Only applicable to sessions
* using connection-based protocols. One of the stream-based protocol
diff --git a/daemon/worker.c b/daemon/worker.c
index 996eb9be..db63f025 100644
--- a/daemon/worker.c
+++ b/daemon/worker.c
@@ -1351,9 +1351,7 @@ static int worker_submit(struct session2 *session, struct comm_info *comm, knot_
}
/* Badly formed query when using DoH leads to a Bad Request */
- /* TODO: Do not necessarily tie it to HTTP - it should probably be a
- * more generic flag */
- if (session->http && !is_outgoing && ret) {
+ if (session->custom_emalf_handling && !is_outgoing && ret) {
session2_event(session, PROTOLAYER_EVENT_MALFORMED, NULL);
return ret;
}