tools: add script to dump geth peers

Added a script that calls admin_peers and displays the result.
This commit is contained in:
mehmetyavuzz43 2025-12-17 14:16:51 +01:00 committed by GitHub
parent 6978ab48aa
commit 46f76d81aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

21
scripts/dump_peers.sh Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
# Dumps the current list of peers from a running geth node.
RPC_URL="${RPC_URL:-http://127.0.0.1:8545}"
echo "Using RPC URL: ${RPC_URL}"
echo
payload='{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":1}'
response="$(curl -s -X POST "${RPC_URL}" -H "Content-Type: application/json" -d "${payload}")"
if [ -z "${response}" ]; then
echo "No response received. Is geth running with admin RPC enabled?"
exit 1
fi
echo "Peers response:"
echo "${response}"