Created
February 5, 2020 18:03
-
-
Save michaeljfazio/c228ba598d7e9ff2d1499a402ea8231c to your computer and use it in GitHub Desktop.
Generate Peers List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function extract() | |
{ | |
while read line | |
do | |
arr=( $(echo $line | tr ';' ' ') ) | |
addr=${arr[15]::-1} | |
ip=$(echo $addr | cut -d: -f1) | |
port=$(echo $addr | cut -d: -f2) | |
id=${arr[13]::-1} | |
echo "$id:$ip:$port" | |
done | |
} | |
journalctl -u jormungandr.service --since "1 hour ago" 2> /dev/null | grep "connecting to peer" | extract | sort | uniq | while read line | |
do | |
id=$(echo $line | cut -d: -f1) | |
ip=$(echo $line | cut -d: -f2) | |
port=$(echo $line | cut -d: -f3) | |
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
echo "- address: \"/ip4/$ip/tcp/$port\"" | |
echo " id: \"$id\"" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!