From 17663b6a7c505226cfe9ccc0671611075a3dff57 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 7 Jan 2021 05:56:34 +0100 Subject: RPKI: Remove port (and SSH username) from 'Cache server' output line It was mixed-up if hostname is IPv6 address, and reporting separate values (like port) on separate lines fits better into key-value style of 'show protocols all' output. Also, the patch simplifies transport identification formatting (although it is unused now). Thanks to Alarig Le Lay for the suggestion. --- proto/rpki/tcp_transport.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'proto/rpki/tcp_transport.c') diff --git a/proto/rpki/tcp_transport.c b/proto/rpki/tcp_transport.c index 0d3c7e99..132f8e2d 100644 --- a/proto/rpki/tcp_transport.c +++ b/proto/rpki/tcp_transport.c @@ -43,24 +43,12 @@ rpki_tr_tcp_ident(struct rpki_tr_sock *tr) if (tr->ident != NULL) return tr->ident; - const char *host = cf->hostname; - ip_addr ip = cf->ip; - u16 port = cf->port; - - size_t colon_and_port_len = 6; /* max ":65535" */ - size_t ident_len; - if (host) - ident_len = strlen(host) + colon_and_port_len + 1; - else - ident_len = IPA_MAX_TEXT_LENGTH + colon_and_port_len + 1; - - char *ident = mb_alloc(cache->pool, ident_len); - if (host) - bsnprintf(ident, ident_len, "%s:%u", host, port); - else - bsnprintf(ident, ident_len, "%I:%u", ip, port); - + /* Length: + ':' + + '\0' */ + size_t len = strlen(cf->hostname) + 1 + 5 + 1; + char *ident = mb_alloc(cache->pool, len); + bsnprintf(ident, len, "%s:%u", cf->hostname, cf->port); tr->ident = ident; + return tr->ident; } -- cgit v1.2.3