aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/IO/http.c2
-rw-r--r--src/IO/tls.c7
-rw-r--r--src/cache.c2
-rw-r--r--src/url.c16
-rw-r--r--src/url.h8
5 files changed, 20 insertions, 15 deletions
diff --git a/src/IO/http.c b/src/IO/http.c
index bc8489c9..d8fcf018 100644
--- a/src/IO/http.c
+++ b/src/IO/http.c
@@ -570,7 +570,7 @@ static void Http_connect_socket(ChainLink *Info)
memcpy(&sin6->sin6_addr, dh->data, dh->alen);
inet_ntop(dh->af, dh->data, buf, sizeof(buf));
if (a_Web_valid(S->web) && (S->web->flags & WEB_RootUrl))
- MSG("Connecting to %s:%u\n", buf, S->connect_port);
+ MSG("Connecting to [%s]:%u\n", buf, S->connect_port);
break;
}
#endif
diff --git a/src/IO/tls.c b/src/IO/tls.c
index 62e160b1..9ee82b90 100644
--- a/src/IO/tls.c
+++ b/src/IO/tls.c
@@ -946,8 +946,8 @@ static void Tls_connect(int fd, int connkey)
const char *version = mbedtls_ssl_get_version(ssl),
*cipher = mbedtls_ssl_get_ciphersuite(ssl);
- MSG("%s: %s, cipher %s\n", URL_AUTHORITY(conn->url), version,
- cipher);
+ MSG("%s:%d %s, cipher %s\n", URL_AUTHORITY(conn->url),
+ URL_PORT(conn->url), version, cipher);
}
if (srv->cert_status == CERT_STATUS_USER_ACCEPTED ||
(Tls_examine_certificate(conn->ssl, srv) != -1)) {
@@ -1121,8 +1121,9 @@ static void Tls_cert_authorities_print_summary()
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:%d ", s->hostname, s->port);
+ MSG("%s%s%s:%d ", ipv6?"[":"", s->hostname, ipv6?"]":"", s->port);
}
MSG("\n");
}
diff --git a/src/cache.c b/src/cache.c
index d58ae47b..dbf1a175 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -724,7 +724,7 @@ static void Cache_parse_header(CacheEntry_t *entry)
if (prefs.http_strict_transport_security &&
!dStrAsciiCasecmp(URL_SCHEME(entry->Url), "https") &&
- !a_Url_host_is_ip(URL_HOST(entry->Url)) &&
+ a_Url_host_type(URL_HOST(entry->Url)) == URL_HOST_NAME &&
(hsts = Cache_parse_field(header, "Strict-Transport-Security"))) {
a_Hsts_set(hsts, entry->Url);
dFree(hsts);
diff --git a/src/url.c b/src/url.c
index c8b3d08e..85ad1686 100644
--- a/src/url.c
+++ b/src/url.c
@@ -658,28 +658,26 @@ char *a_Url_string_strip_delimiters(const char *str)
}
/*
- * Is the provided hostname an IP address?
+ * What type of host is this?
*/
-bool_t a_Url_host_is_ip(const char *host)
+int a_Url_host_type(const char *host)
{
uint_t len;
if (!host || !*host)
- return FALSE;
+ return URL_HOST_ERROR;
len = strlen(host);
if (len == strspn(host, "0123456789.")) {
- _MSG("an IPv4 address\n");
- return TRUE;
+ return URL_HOST_IPV4;
}
if (strchr(host, ':') &&
(len == strspn(host, "0123456789abcdefABCDEF:."))) {
/* The precise format is shown in section 3.2.2 of rfc 3986 */
- MSG("an IPv6 address\n");
- return TRUE;
+ return URL_HOST_IPV6;
}
- return FALSE;
+ return URL_HOST_NAME;
}
/*
@@ -746,7 +744,7 @@ static const char *Url_host_find_public_suffix(const char *host)
const char *s;
uint_t dots;
- if (!host || !*host || a_Url_host_is_ip(host))
+ if (a_Url_host_type(host) != URL_HOST_NAME)
return host;
s = host;
diff --git a/src/url.h b/src/url.h
index 93d198f8..85066f2a 100644
--- a/src/url.h
+++ b/src/url.h
@@ -16,6 +16,12 @@
#define URL_HTTP_PORT 80
#define URL_HTTPS_PORT 443
+/* for a_Url_host_type() */
+#define URL_HOST_ERROR -1
+#define URL_HOST_NAME 0
+#define URL_HOST_IPV4 1
+#define URL_HOST_IPV6 2
+
/*
* Values for DilloUrl->flags.
* Specifies which which action to perform with an URL.
@@ -106,7 +112,7 @@ void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
char *a_Url_decode_hex_str(const char *str);
char *a_Url_encode_hex_str(const char *str);
char *a_Url_string_strip_delimiters(const char *str);
-bool_t a_Url_host_is_ip(const char *host);
+int a_Url_host_type(const char *host);
bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2);
#ifdef __cplusplus
}