From f784831f5507abf7d81859c146b0b7641d4c912d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= <petr.spacek@nic.cz>
Date: Wed, 3 Apr 2019 15:12:38 +0200
Subject: [PATCH] doh: remember source transport

---
 daemon/lua/kres-gen.lua   | 1 +
 lib/resolve.h             | 1 +
 modules/http/http_doh.lua | 4 ++++
 3 files changed, 6 insertions(+)

diff --git a/daemon/lua/kres-gen.lua b/daemon/lua/kres-gen.lua
index 1b7571fbd..4989c02c7 100644
--- a/daemon/lua/kres-gen.lua
+++ b/daemon/lua/kres-gen.lua
@@ -166,6 +166,7 @@ struct kr_rplan {
 struct kr_request_qsource_flags {
 	_Bool tcp : 1;
 	_Bool tls : 1;
+	_Bool http : 1;
 };
 struct kr_request {
 	struct kr_context *ctx;
diff --git a/lib/resolve.h b/lib/resolve.h
index 60d80bb29..ae695b913 100644
--- a/lib/resolve.h
+++ b/lib/resolve.h
@@ -179,6 +179,7 @@ struct kr_context
 struct kr_request_qsource_flags {
 	bool tcp:1; /**< true if the request is on TCP (or TLS); only meaningful if (dst_addr). */
 	bool tls:1; /**< true if the request is on TLS; only meaningful if (dst_addr). */
+	bool http:1; /**< true if the request is on HTTP; only meaningful if (dst_addr). */
 };
 
 /**
diff --git a/modules/http/http_doh.lua b/modules/http/http_doh.lua
index 4088ad07b..68ee3b177 100644
--- a/modules/http/http_doh.lua
+++ b/modules/http/http_doh.lua
@@ -92,6 +92,10 @@ local function serve_doh(h, stream)
 	local function init_cb(req)
 		req.qsource.addr = convert_sockaddr(stream:peername())
 		req.qsource.dst_addr = convert_sockaddr(stream:localname())
+		req.qsource.flags.tcp = true
+		req.qsource.flags.tls = (stream.connection:checktls() ~= nil)
+		print(req.qsource.flags.tls)
+		req.qsource.flags.http = true
 	end
 
 	-- resolve query
-- 
GitLab