Bitcoin Forum
May 02, 2024, 06:53:39 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Checking Remote Node Availability  (Read 2501 times)
ahs23 (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 1


View Profile
August 28, 2014, 09:17:47 PM
Merited by ABCbits (1)
 #1

At the bottom of this page there is a form that allows you to check if a Bitcoin node is up and responding: https://getaddr.bitnodes.io/

Can someone tell me how I can perform this same test against a remote node, without relying on this service?
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
1714676019
Hero Member
*
Offline Offline

Posts: 1714676019

View Profile Personal Message (Offline)

Ignore
1714676019
Reply with quote  #2

1714676019
Report to moderator
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
August 28, 2014, 09:18:32 PM
Merited by ABCbits (2)
 #2

Attempt to connect to the node using the bitcoin protocol.
ahs23 (OP)
Newbie
*
Offline Offline

Activity: 10
Merit: 1


View Profile
August 28, 2014, 09:35:32 PM
 #3

Right, but how?

I have bitcoind running locally, and was looking for a way to do this using it as the client, but I don't see any methods/arguments for this specifically. Do I have to manually craft a request?
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
August 28, 2014, 11:47:51 PM
Last edit: August 29, 2014, 12:01:24 AM by DeathAndTaxes
Merited by ABCbits (3)
 #4

There is no easy way to do this from a client.  You can use an entry in bitcoin.conf such as addnode=xxx.xxx.xxx.xxx to force a connection to a specific node.    Most likely is you want to do it in any automated manner you will need to custom code as this is pretty low level nuts and bolts and not exposed by clients.

At a protocol level you would send a outgoing "version" message to the remote node.  It should respond back with a version message.  If it does not then it is not reachable by inbound connection.
cr1776
Legendary
*
Offline Offline

Activity: 4018
Merit: 1299


View Profile
August 29, 2014, 12:04:09 AM
 #5

D&T beat me to it by mentioning addnode, but you could open the console, do an

addnode xxx.xxx.xxx.xxx add

Then you could look at something like this (assuming you are running *nix  (Unix, Linux, MacOS X):
netstat -an | grep "8333"


to show what IPs you are connected to.  Is the IP you were wondering about there?   (You might use "onetry" in the addnode too.)

You might want to do an
addnode xxx.xxx.xxx.xxx remove


when you are finished testing.

For automation, you might send the addnode automatically, then check the netstat with a shell script and grep, then remove that node.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1499


No I dont escrow anymore.


View Profile WWW
August 29, 2014, 05:52:26 AM
Merited by ABCbits (2)
 #6

Why not just use?

Code:
nmap IP -p8333

I just tested it on my node I know is running and it returned:

Code:
PORT     STATE  SERVICE
8333/tcp open unknown

Nmap done: 1 IP address (1 host up) scanned in 0.28 seconds

Which is not an 100% answer, but easier to do.

The IP "next to it" returns state closed. I assume there is no node running Wink

Im not really here, its just your imagination.
disclosure
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
August 29, 2014, 06:15:23 AM
 #7

You can run the same tool used on Bitnodes locally to probe a Bitcoin client. Change the destination IP and port in https://github.com/ayeowch/bitnodes/blob/master/protocol.py#L505 and run python protocol.py. Feel free to modify the script to accept command-line argument, e.g. python protocol.py IP PORT as needed.
Meuh6879
Legendary
*
Offline Offline

Activity: 1512
Merit: 1011



View Profile
August 29, 2014, 12:38:28 PM
 #8

Right, but how?

Like this :

Quote
2014-08-29 12:14:29 ProcessBlock: ACCEPTED
2014-08-29 12:15:44 CreateNewBlock(): total size 36332
2014-08-29 12:17:42 CreateNewBlock(): total size 94237
2014-08-29 12:19:40 CreateNewBlock(): total size 134848
2014-08-29 12:20:30 receive version message: /getaddr.bitnodes.io:0.1/: version 70001, blocks=313000
2014-08-29 12:21:39 CreateNewBlock(): total size 161266
2014-08-29 12:23:06 UpdateTip: new best=00000000000000002df72 progress=0.999997
2014-08-29 12:23:06 ProcessBlock: ACCEPTED
mmortal03
Legendary
*
Offline Offline

Activity: 1762
Merit: 1010


View Profile
February 08, 2016, 11:03:37 PM
 #9

You can run the same tool used on Bitnodes locally to probe a Bitcoin client. Change the destination IP and port in https://github.com/ayeowch/bitnodes/blob/master/protocol.py#L505 and run python protocol.py. Feel free to modify the script to accept command-line argument, e.g. python protocol.py IP PORT as needed.


Does anyone know what the services number means that is returned by the bitnodes protocol.py handshake?


Btw, I was able to get this to work with Python on Windows. Here's what worked for me:

Install Python 2.7 from Python.org
Install VCForPython27.msi from Microsoft.com
Download and extract bitnodes-master from GitHub

Where you extracted it on your computer, run:
pip install -r requirements
pip install win_inet_pton

Finally, add "include win_inet_pton", without quotes, near the top of protocol.py with the rest of the include lines

Now, on the commandline, you can run "python protocol.py", without quotes, editing the code under the main function of protocol.py with the IP address and port, as necessary.
mmortal03
Legendary
*
Offline Offline

Activity: 1762
Merit: 1010


View Profile
February 09, 2016, 03:09:28 PM
 #10

Also, @disclosure, what is the SOCKET_TIMEOUT variable set to on your "check node" feature on the website? Is it 15 seconds like it is in the source code? I noticed that I was getting spotty results on the web version with detecting my nodes, as the inbound connection would show up as a peer in the debug window, but would seem to timeout before all the information was sent, causing a false negative on your page. After playing around some with the source code locally, it seemed to me that a higher socket timeout might be appropriate. Either that, or this was just a coincidence, and something else was causing the spotty detection of my nodes on your site.
disclosure
Newbie
*
Offline Offline

Activity: 38
Merit: 0


View Profile
February 10, 2016, 10:28:06 PM
 #11

The services are documented in https://github.com/bitcoin/bitcoin/blob/605c17844ea32b6d237db6d83871164dc7d59dab/src/protocol.h#L227. I have increased the SOCKET_TIMEOUT from 15 to 30 for https://bitnodes.21.co/#join-the-network, so it's consistent with the timeout used by the crawler.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!