summaryrefslogtreecommitdiffstats
path: root/daemon/network.c
diff options
context:
space:
mode:
authorMarek Vavrusa <marek@vavrusa.com>2016-07-08 05:22:51 +0200
committerOndřej Surý <ondrej@sury.org>2016-08-05 11:47:14 +0200
commitf22f5226bebcc27dbc7667e1bdba2b91111baaf4 (patch)
tree75412d1fdebf29631953307f7ab97107a07e298b /daemon/network.c
parentActively link to gnutls (diff)
downloadknot-resolver-f22f5226bebcc27dbc7667e1bdba2b91111baaf4.tar.xz
knot-resolver-f22f5226bebcc27dbc7667e1bdba2b91111baaf4.zip
daemon: ported DNS/TLS preparation code to 1.1
Diffstat (limited to 'daemon/network.c')
-rw-r--r--daemon/network.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/daemon/network.c b/daemon/network.c
index 4ad0e45d..e0e46e35 100644
--- a/daemon/network.c
+++ b/daemon/network.c
@@ -130,6 +130,7 @@ static int insert_endpoint(struct network *net, const char *addr, struct endpoin
/** Open endpoint protocols. */
static int open_endpoint(struct network *net, struct endpoint *ep, struct sockaddr *sa, uint32_t flags)
{
+ int ret = 0;
if (flags & NET_UDP) {
ep->udp = malloc(sizeof(*ep->udp));
if (!ep->udp) {
@@ -137,7 +138,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad
}
memset(ep->udp, 0, sizeof(*ep->udp));
handle_init(udp, net->loop, ep->udp, sa->sa_family);
- int ret = udp_bind(ep->udp, sa);
+ ret = udp_bind(ep->udp, sa);
if (ret != 0) {
return ret;
}
@@ -150,13 +151,18 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad
}
memset(ep->tcp, 0, sizeof(*ep->tcp));
handle_init(tcp, net->loop, ep->tcp, sa->sa_family);
- int ret = tcp_bind(ep->tcp, sa);
+ if (flags & NET_TLS) {
+ ret = tcp_bind_tls(ep->tcp, sa);
+ ep->flags |= NET_TLS;
+ } else {
+ ret = tcp_bind(ep->tcp, sa);
+ }
if (ret != 0) {
return ret;
}
ep->flags |= NET_TCP;
}
- return kr_ok();
+ return ret;
}
/** Open fd as endpoint. */