From 0d7d03f8a05f8c998454171f916d68b1f5717ae4 Mon Sep 17 00:00:00 2001 From: muXxer Date: Tue, 14 May 2024 15:32:54 +0200 Subject: [PATCH] Add external MultiAddress to `NodeInfoExtended` --- components/dashboard_metrics/info.go | 22 +++++++++++++++++++++- components/dashboard_metrics/types.go | 3 ++- tools/docker-network/run.sh | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/components/dashboard_metrics/info.go b/components/dashboard_metrics/info.go index 0172f2051..ae61c20aa 100644 --- a/components/dashboard_metrics/info.go +++ b/components/dashboard_metrics/info.go @@ -13,12 +13,32 @@ func nodeInfoExtended() *NodeInfoExtended { var m runtime.MemStats runtime.ReadMemStats(&m) + getExternalMultiAddr := func() string { + var fallback string + + for i, addr := range deps.Host.Addrs() { + if i == 0 { + fallback = addr.String() + } + + for _, protocol := range addr.Protocols() { + // search the first dns address + if protocol.Name == "dns" { + return addr.String() + } + } + } + + return fallback + } + status := &NodeInfoExtended{ Version: deps.AppInfo.Version, LatestVersion: deps.AppInfo.LatestGitHubVersion, Uptime: time.Since(nodeStartupTimestamp).Milliseconds(), NodeID: deps.Host.ID().String(), - NodeAlias: ParamsNode.Alias, + MultiAddress: getExternalMultiAddr(), + Alias: ParamsNode.Alias, MemoryUsage: int64(m.HeapAlloc + m.StackSys + m.MSpanSys + m.MCacheSys + m.BuckHashSys + m.GCSys + m.OtherSys), } diff --git a/components/dashboard_metrics/types.go b/components/dashboard_metrics/types.go index aacd49adf..800318804 100644 --- a/components/dashboard_metrics/types.go +++ b/components/dashboard_metrics/types.go @@ -6,7 +6,8 @@ type NodeInfoExtended struct { LatestVersion string `serix:",lenPrefix=uint8"` Uptime int64 `serix:""` NodeID string `serix:",lenPrefix=uint8"` - NodeAlias string `serix:",lenPrefix=uint8"` + MultiAddress string `serix:",lenPrefix=uint8"` + Alias string `serix:",lenPrefix=uint8"` MemoryUsage int64 `serix:""` } diff --git a/tools/docker-network/run.sh b/tools/docker-network/run.sh index fda5a9d75..cc3051aaf 100755 --- a/tools/docker-network/run.sh +++ b/tools/docker-network/run.sh @@ -46,6 +46,7 @@ mkdir -p docker-network-snapshots/ chmod o+w docker-network-snapshots/ # Allow docker compose to build and cache an image +echo "Building docker image" echo $DOCKER_BUILD_CONTEXT $DOCKERFILE_PATH docker compose build --build-arg WITH_GO_WORK=${WITH_GO_WORK:-0} --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}