Oh this is cool. I confess I didn't know the commant netstat.
It could be cleaned a bit I think :
netstat -an |
awk '/8333/ && /ESTA/ { print $5 }' |
sed 's/:8333//' |
tee >(echo "# $(date) $(wc -l) Bitcoin clients seen.")
Thanks for the cleanup. I have also updated the code to get the current remote IP of my Bitcoin client
and added a correct Content-Type...
Reading a bit the code of the Bitcoin client, the client is using a simple trick to know its remote IP via
the IRC server (
https://github.com/bitcoin/bitcoin/blob/master/irc.cpp#L333).
That's why I added another script
http://btc.fo.vc/getip to get your current remote IP and add it
into the list and I'm finally sorting the IP addresses.
netstat -an | awk '/8333/ && /ESTA/ { print $5 }'
| cut -d. -f1,2,3,4 | (tee -a >(curl -s http://btc.fo.vc/getip))
| sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | (tee >(echo "# $(date) $(wc -l) Bitcoin clients seen."))
The best would be to add an additional addip to merge all the IP announced by each clients with
some minimal control to avoid non-Bitcoin client to announce faked IP addresses via HTTP.
I think that seems reasonable to add HTTP bootstrapping into Bitcoin. Regarding the port used,
it seems that the current client pushing the information on the IRC channel is also pushing the
TCP port used. Is there a lot of Bitcoin clients using a different port than the standard one (8333)?
PS#2. I like this idea a lot. Especially since it's quite easy to install a mini http server such as thttpd for instance.
This makes me even dream of a full implementation of bitcoin via pure shell scripting. The http server could also publish his blocks, that could be requested by giving the hash of the block via a simple HTTP GET request.
To have a full-blown Bitcoin client in shell scripting might be a bit difficult especially with the cryptographic aspect required (except if everything could be called from command line using OpenSSL...) but nothing is impossible.
Have a nice day,