You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2021/10/21 19:12:01 UTC

[qpid-dispatch] branch main updated: DISPATCH-2257: test address and disable ipv6 if it is an ipv4 address

This is an automated email from the ASF dual-hosted git repository.

gsim pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/main by this push:
     new fe30749  DISPATCH-2257: test address and disable ipv6 if it is an ipv4 address
fe30749 is described below

commit fe3074977eecfe30e6d0084cc7051f7fdeb21cb3
Author: Gordon Sim <gs...@redhat.com>
AuthorDate: Wed Oct 20 17:49:30 2021 +0100

    DISPATCH-2257: test address and disable ipv6 if it is an ipv4 address
---
 src/http-libwebsockets.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/http-libwebsockets.c b/src/http-libwebsockets.c
index 3f156b4..02d7994 100644
--- a/src/http-libwebsockets.c
+++ b/src/http-libwebsockets.c
@@ -299,6 +299,21 @@ static const struct lws_protocol_vhost_options mime_types[] = {
     { NULL, NULL, "*", "application/octet-stream" }
 };
 
+static int is_ipv6_address(qd_http_server_t *hs, const char* host, const char* port)
+{
+    int result = 0;
+    struct addrinfo *addr;
+    struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM};
+    int code = getaddrinfo(host, port, &hints, &addr);
+    if (code) {
+        qd_log(hs->log, QD_LOG_ERROR, "getaddrinfo(%s, %s) failed with %s", host, port, gai_strerror(code));
+    } else {
+        result = addr->ai_family == AF_INET6;
+        freeaddrinfo(addr);
+    }
+    return result;
+}
+
 static void listener_start(qd_lws_listener_t *hl, qd_http_server_t *hs) {
     log_init();                 /* Update log flags at each listener */
 
@@ -346,6 +361,10 @@ static void listener_start(qd_lws_listener_t *hl, qd_http_server_t *hs) {
     info.keepalive_timeout = 1;
     info.ssl_cipher_list = CIPHER_LIST;
     info.options |= LWS_SERVER_OPTION_VALIDATE_UTF8;
+    if (!is_ipv6_address(hs, config->host, config->port)) {
+        qd_log(hs->log, QD_LOG_NOTICE, "Disabling ipv6 on %s", config->host_port);
+        info.options |= LWS_SERVER_OPTION_DISABLE_IPV6;
+    }
     if (config->ssl_profile) {
         info.ssl_cert_filepath = config->ssl_certificate_file;
         info.ssl_private_key_filepath = config->ssl_private_key_file;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org