]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: Remove port (and SSH username) from 'Cache server' output line
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 7 Jan 2021 04:56:34 +0000 (05:56 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 7 Jan 2021 05:04:31 +0000 (06:04 +0100)
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/rpki.c
proto/rpki/ssh_transport.c
proto/rpki/tcp_transport.c

index 3ee46ae216a4483f1918771c6628e74f458bce2b..799cb8773b2587542eb7599769347ba6f6a6b933 100644 (file)
@@ -837,7 +837,7 @@ rpki_show_proto_info(struct proto *P)
     case RPKI_TR_TCP: transport_name = "Unprotected over TCP"; break;
     };
 
-    cli_msg(-1006, "  Cache server:     %s", rpki_get_cache_ident(cache));
+    cli_msg(-1006, "  Cache server:     %s", cf->hostname);
     cli_msg(-1006, "  Status:           %s", rpki_cache_state_to_str(cache->state));
     cli_msg(-1006, "  Transport:        %s", transport_name);
     cli_msg(-1006, "  Protocol version: %u", cache->version);
index 469eb199addbe157469f6f14bc857622350a404a..6333f367f20352a450e478ab4b13fb9dbd6eb802 100644 (file)
@@ -47,17 +47,15 @@ rpki_tr_ssh_ident(struct rpki_tr_sock *tr)
   struct rpki_cache *cache = tr->cache;
   struct rpki_config *cf = (void *) cache->p->p.cf;
   struct rpki_tr_ssh_config *ssh_cf = (void *) cf->tr_config.spec;
+  const char *username = ssh_cf->user;
 
   if (tr->ident != NULL)
     return tr->ident;
 
-  const char *username = ssh_cf->user;
-  const char *host = cf->hostname;
-  u16 port = cf->port;
-
-  size_t len = strlen(username) + 1 + strlen(host) + 1 + 5 + 1; /* <user> + '@' + <host> + ':' + <port> + '\0' */
+  /* Length: <user> + '@' + <host> + ' port ' + <port> + '\0' */
+  size_t len = strlen(username) + 1 + strlen(cf->hostname) + 1 + 5 + 1;
   char *ident = mb_alloc(cache->pool, len);
-  bsnprintf(ident, len, "%s@%s:%u", username, host, port);
+  bsnprintf(ident, len, "%s@%s:%u", username, cf->hostname, cf->port);
   tr->ident = ident;
 
   return tr->ident;
index 0d3c7e99bb5a88ebb74cd3d2f5de57eabc06533e..132f8e2dc90859c96af06477e8c8dd1af1a15489 100644 (file)
@@ -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: <host> + ':' + <port> + '\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;
 }