diff --git a/diagnostics/bootnodes.go b/diagnostics/bootnodes.go new file mode 100644 index 000000000..fba098288 --- /dev/null +++ b/diagnostics/bootnodes.go @@ -0,0 +1,25 @@ +package diagnostics + +import ( + "encoding/json" + "net/http" + + "github.com/ledgerwatch/erigon/turbo/node" +) + +func SetupBootnodesAccess(metricsMux *http.ServeMux, node *node.ErigonNode) { + metricsMux.HandleFunc("/bootnodes", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Content-Type", "application/json") + + bootnodes := node.Node().Config().P2P.BootstrapNodesV5 + + btNodes := make([]string, 0, len(bootnodes)) + + for _, bootnode := range bootnodes { + btNodes = append(btNodes, bootnode.String()) + } + + json.NewEncoder(w).Encode(btNodes) + }) +} diff --git a/diagnostics/setup.go b/diagnostics/setup.go index 9e1601e02..022e7eb7e 100644 --- a/diagnostics/setup.go +++ b/diagnostics/setup.go @@ -26,5 +26,6 @@ func Setup(ctx *cli.Context, metricsMux *http.ServeMux, node *node.ErigonNode) { SetupHeaderDownloadStats(debugMux) SetupNodeInfoAccess(debugMux, node) SetupPeersAccess(ctx, debugMux, node) + SetupBootnodesAccess(debugMux, node) } diff --git a/turbo/node/node.go b/turbo/node/node.go index ed7d1d5db..43cc17d9b 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -38,6 +38,10 @@ func (eri *ErigonNode) Backend() *eth.Ethereum { return eri.backend } +func (eri *ErigonNode) Node() *node.Node { + return eri.stack +} + func (eri *ErigonNode) Close() { eri.stack.Close() }