From 34008b6ffa1295a6dfd8f5bb8fd488975b212f60 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 19 Aug 2024 14:23:14 +0200 Subject: [PATCH] chore(daemon): sort listeners (#10480) --- cmd/ipfs/kubo/daemon.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/ipfs/kubo/daemon.go b/cmd/ipfs/kubo/daemon.go index 1999605dc..b66e61374 100644 --- a/cmd/ipfs/kubo/daemon.go +++ b/cmd/ipfs/kubo/daemon.go @@ -818,7 +818,17 @@ func printLibp2pPorts(node *core.IpfsNode) { addrMap[host][protocol] = struct{}{} } } - for host, protocolsSet := range addrMap { + + // Produce a sorted host:port list + hosts := make([]string, 0, len(addrMap)) + for host := range addrMap { + hosts = append(hosts, host) + } + sort.Strings(hosts) + + // Print listeners + for _, host := range hosts { + protocolsSet := addrMap[host] protocols := make([]string, 0, len(protocolsSet)) for protocol := range protocolsSet { protocols = append(protocols, protocol)