diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-05-30 18:25:39 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-05-30 18:43:33 +0200 |
commit | 9f40e8f91ec6475308c265ea37b25033f616ce48 (patch) | |
tree | 9dcc4b8d87db637600435a7fda2beae628ce69ad /listen.c | |
parent | 618493e378e2239f0d30902e47adfa134e649fdc (diff) |
add support for enforcing HTTPS
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'listen.c')
-rw-r--r-- | listen.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -187,6 +187,7 @@ int uh_socket_bind(const char *host, const char *port, bool tls) l->fd.fd = sock; l->tls = tls; + l->addr = *(struct sockaddr_in6 *)p->ai_addr; list_add_tail(&l->list, &listeners); bound++; @@ -201,3 +202,21 @@ error: return bound; } + +int uh_first_tls_port(int family) +{ + struct listener *l; + int tls_port = -1; + + list_for_each_entry(l, &listeners, list) { + if (!l->tls || l->addr.sin6_family != family) + continue; + + if (tls_port != -1 && ntohs(l->addr.sin6_port) != 443) + continue; + + tls_port = ntohs(l->addr.sin6_port); + } + + return tls_port; +} |