summaryrefslogtreecommitdiff
path: root/listen.c
diff options
context:
space:
mode:
Diffstat (limited to 'listen.c')
-rw-r--r--listen.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/listen.c b/listen.c
index adf8b16..92ca680 100644
--- a/listen.c
+++ b/listen.c
@@ -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;
+}