mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
tools: add script to dump geth peers
Added a script that calls admin_peers and displays the result.
This commit is contained in:
parent
6978ab48aa
commit
46f76d81aa
1 changed files with 21 additions and 0 deletions
21
scripts/dump_peers.sh
Normal file
21
scripts/dump_peers.sh
Normal 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}"
|
||||||
Loading…
Reference in a new issue