flags.sock_type = SOCK_DGRAM;
ret = network_listen(net, str, port, flags);
}
- if (!kind && ret == 0) { /* common for normal TCP and TLS */
+ if (!kind && ret == 0) { /* common for TCP, DoT and DoH (v2) */
flags.sock_type = SOCK_STREAM;
ret = network_listen(net, str, port, flags);
}
}
bool tls = (port == KR_DNS_TLS_PORT);
- bool http = (port == KR_DNS_HTTP_PORT);
+ bool http = false;
if (port == KR_DNS_DOH_PORT) {
http = tls = true;
}
if (http) {
struct http_ctx *ctx = session_http_get_server_ctx(s);
if (!ctx) {
- if (!tls) { // TODO plain HTTP not supported yet
+ if (!tls) { /* Plain HTTP is not supported. */
session_close(s);
return;
}
_tcp_accept(master, status, true, false);
}
-static void http_accept(uv_stream_t *master, int status)
-{
- _tcp_accept(master, status, false, true);
-}
-
static void https_accept(uv_stream_t *master, int status)
{
_tcp_accept(master, status, true, true);
{
uv_connection_cb connection;
if (has_tls && has_http) {
+#ifdef NGHTTP2_VERSION_NUM
connection = https_accept;
+#else
+ kr_log_error("[ io ] kresd was compiled without libnghttp2 support");
+ return kr_error(ENOPROTOOPT);
+#endif
} else if (has_tls) {
connection = tls_accept;
} else if (has_http) {
- connection = http_accept;
+ return kr_error(EPROTONOSUPPORT);
} else {
connection = tcp_accept;
}
* Defines.
*/
#define KR_DNS_PORT 53
-#define KR_DNS_HTTP_PORT 80
#define KR_DNS_DOH_PORT 443
#define KR_DNS_TLS_PORT 853
#define KR_EDNS_VERSION 0