#include "daemon/session2.h"
#include "daemon/worker.h"
-#include "daemon/http.h"
-
/** Makes a `nghttp2_nv`. `K` is the key, `KS` is the key length,
* `V` is the value, `VS` is the value length. */
#define MAKE_NV(K, KS, V, VS) \
}
}
-void http_protolayers_init(void)
+__attribute__((constructor))
+static void http_protolayers_init(void)
{
protolayer_globals[PROTOLAYER_TYPE_HTTP] = (struct protolayer_globals) {
.sess_size = sizeof(struct pl_http_sess_data),
+++ /dev/null
-/* Copyright (C) CZ.NIC, z.s.p.o. <knot-resolver@labs.nic.cz>
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-/** Initializes the protocol layers managed by http. */
-void http_protolayers_init(void);
#include "daemon/network.h"
#include "daemon/worker.h"
#include "daemon/tls.h"
-#include "daemon/http.h"
#include "daemon/session2.h"
#include "contrib/cleanup.h"
#include "lib/utils.h"
return PROTOLAYER_EVENT_PROPAGATE;
}
-void io_protolayers_init(void)
+__attribute__((constructor))
+static void io_protolayers_init(void)
{
protolayer_globals[PROTOLAYER_TYPE_UDP] = (struct protolayer_globals){
.event_wrap = pl_udp_event_wrap,
struct tls_client_ctx;
struct io_stream_data;
-/** Initializes the protocol layers managed by io. */
-void io_protolayers_init(void);
-
/** Bind address into a file-descriptor (only, no libuv). type is e.g. SOCK_DGRAM */
int io_bind(const struct sockaddr *addr, int type, const endpoint_flags_t *flags);
/** Initialize a UDP handle and start listening. */
#include "daemon/udp_queue.h"
#include "daemon/worker.h"
-#ifdef ENABLE_DOH2
-#include "daemon/http.h"
-#endif
-
#include "lib/defines.h"
#include "lib/dnssec.h"
#include "lib/log.h"
uv_strerror(ret));
}
- io_protolayers_init();
- tls_protolayers_init();
- proxy_protolayers_init();
-#ifdef ENABLE_DOH2
- http_protolayers_init();
-#endif
-
/* Start listening, in the sense of network_listen_fd(). */
if (start_listening(&the_args->fds) != 0) {
ret = EXIT_FAILURE;
return protolayer_continue(ctx);
}
-
-void proxy_protolayers_init(void)
+__attribute__((constructor))
+static void proxy_protolayers_init(void)
{
protolayer_globals[PROTOLAYER_TYPE_PROXYV2_DGRAM] = (struct protolayer_globals){
.iter_size = sizeof(struct pl_proxyv2_dgram_iter_data),
* the proxy is unencrypted. */
bool has_tls : 1;
};
-
-/** Initializes the protocol layers managed by the PROXYv2 "module". */
-void proxy_protolayers_init(void);
req->qsource.comm_flags.tls = true;
}
-void tls_protolayers_init(void)
+__attribute__((constructor))
+static void tls_protolayers_init(void)
{
protolayer_globals[PROTOLAYER_TYPE_TLS] = (struct protolayer_globals){
.sess_size = sizeof(struct pl_tls_sess_data),
/*! Generate new ephemeral TLS credentials. */
struct tls_credentials * tls_get_ephemeral_credentials(void);
-/*! Initializes the protocol layers managed by tls. */
-void tls_protolayers_init(void);
-
/* Session tickets, server side. Implementation in ./tls_session_ticket-srv.c */
/*! Opaque struct used by tls_session_ticket_* functions. */
req->qsource.comm_flags.tcp = true;
}
-int worker_init(void)
+__attribute__((constructor))
+static void worker_protolayers_init(void)
{
- if (kr_fails_assert(the_worker == NULL))
- return kr_error(EINVAL);
- kr_bindings_register(the_engine->L); // TODO move
-
- /* DNS protocol layers */
protolayer_globals[PROTOLAYER_TYPE_DNS_DGRAM] = (struct protolayer_globals){
.wire_buf_overhead_cb = pl_dns_dgram_wire_buf_overhead,
.wire_buf_max_overhead = KNOT_WIRE_MAX_PKTSIZE,
protolayer_globals[PROTOLAYER_TYPE_DNS_MULTI_STREAM].sess_init = pl_dns_stream_sess_init;
protolayer_globals[PROTOLAYER_TYPE_DNS_SINGLE_STREAM] = stream_common;
protolayer_globals[PROTOLAYER_TYPE_DNS_SINGLE_STREAM].sess_init = pl_dns_single_stream_sess_init;
+}
+
+int worker_init(void)
+{
+ if (kr_fails_assert(the_worker == NULL))
+ return kr_error(EINVAL);
+ kr_bindings_register(the_engine->L); // TODO move
/* Create main worker. */
the_worker = &the_worker_value;