changeset 4621:78aeb8eae728

in some TLS MSGs, don't show port if it's the default
author corvid
date Mo, 04 Jul 2016 01:39:45 +0000
parents 2bf1d3a772e3
children 8ab62e98ae78
files src/IO/tls.c
diffstat 1 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/IO/tls.c	So Jul 03 21:34:10 2016 +0000
+++ b/src/IO/tls.c	Mo Jul 04 01:39:45 2016 +0000
@@ -947,8 +947,10 @@
             const char *version = mbedtls_ssl_get_version(ssl),
                        *cipher = mbedtls_ssl_get_ciphersuite(ssl);
 
-            MSG("%s:%d %s, cipher %s\n", URL_AUTHORITY(conn->url),
-                URL_PORT(conn->url), version, cipher);
+            MSG("%s", URL_AUTHORITY(conn->url));
+            if (URL_PORT(conn->url) != URL_HTTPS_PORT)
+               MSG(":%d", URL_PORT(conn->url));
+            MSG(" %s, cipher %s\n", version, cipher);
          }
          if (srv->cert_status == CERT_STATUS_USER_ACCEPTED ||
              (Tls_examine_certificate(conn->ssl, srv) != -1)) {
@@ -1101,10 +1103,11 @@
 static void Tls_cert_authorities_print_summary()
 {
    const int ca_len = dList_length(cert_authorities);
+   Dstr *ds = dStr_new("");
    int i, j;
 
    if (ca_len)
-      MSG("TLS: Trusted during this session:\n");
+      dStr_append(ds, "TLS: Trusted during this session:\n");
 
    for (i = 0; i < ca_len; i++) {
       CertAuth_t *ca = (CertAuth_t *)dList_nth_data(cert_authorities, i);
@@ -1118,17 +1121,21 @@
          ca_name += 3;
       else
          ca_name = ca->name;
-      MSG("- %s for: ", ca_name);
+      dStr_sprintfa(ds, "- %s for: ", ca_name);
 
       for (j = 0; j < servers_len; j++) {
          Server_t *s = dList_nth_data(ca->servers, j);
          bool_t ipv6 = a_Url_host_type(s->hostname) == URL_HOST_IPV6;
 
-         MSG("%s%s%s:%d ", ipv6?"[":"", s->hostname, ipv6?"]":"", s->port);
+         dStr_sprintfa(ds, "%s%s%s", ipv6?"[":"", s->hostname, ipv6?"]":"");
+         if (s->port != URL_HTTPS_PORT)
+            dStr_sprintfa(ds, ":%d", s->port);
+         dStr_append_c(ds, ' ');
       }
-      MSG("\n");
+      dStr_append_c(ds, '\n');
    }
-
+   MSG("%s", ds->str);
+   dStr_free(ds, 1);
 }
 
 /*
@@ -1189,7 +1196,8 @@
  */
 void a_Tls_freeall(void)
 {
-   Tls_cert_authorities_print_summary();
+   if (prefs.show_msg)
+      Tls_cert_authorities_print_summary();
 
    Tls_fd_map_remove_all();
    Tls_cert_authorities_freeall();