Author Topic: Node mapping  (Read 688 times)

warmach on: May 11, 2016, 04:15:43 AM

  • Senior Fimker
  • ***
  • Posts: 227
    • View Profile
I was working on a script to map out the nodes on the FIM network.  The easy way is to just hit my local node API and getPeers.  I then do the same thing for each of those peers.  Repeat. Repeat. Repeat.

But what if the node has the API turned off.  Isn't having the API server off the default setting?  What about connecting to each server via 7884?  Do I have to use websockets?  Or can i GET/POST?  What kind of function calls are available on that port? 

I've only ever worked with the API on 7886.

Thanks!
Warmach's Forging Pool
http://fim.warmach.info/pool/
May the forge be with you...

Dirk Diggler #1 on: May 11, 2016, 02:39:10 PM

  • FIMK Staff
  • *****
  • Posts: 486
    • View Profile
    • Krypto Fin ry
Hi,

The easy way is to just hit my local node API and getPeers.

That is indeed the easy way but make sure to leave out the state or active param so you will get ALL known peers see http://wiki.nxtcrypto.org/wiki/The_Nxt_API_Examples#Get_Peer

I then do the same thing for each of those peers.  Repeat. Repeat. Repeat.

On a network as small as FIMK and this even is true for NXT usually each peer will at least know about each other peer in the network.
I say know about and not connected since not all peers are connected, but usually they do know about each other.

What about connecting to each server via 7884? 
Do I have to use websockets?

FIMK has two modes for p2p connections, the old HTTP JSON connectors and the newer websocket connectors.
Both are available and will probably remain working for a long time, it might in a future version be more efficient to turn off the HTTP channel but i dont foresee that anytime soon.

Or can i GET/POST?

You can never GET, you'll be blacklisted for at least 10 minutes, when developing such a scraper this will cost you a lot of time.
Best when trying to code such a thing is to target 7884 on some machine you have access to, if you accidentally send a wrong POST or too fast and you're blacklisted you can restart that FIMK and the blacklist will be gone.

What kind of function calls are available on that port?

Function calls are hidden (not in any documentation afaik) the list is here https://github.com/fimkrypto/fimk/blob/master/src/java/nxt/peer/PeerServlet.java#L62-L74. What you want is the GetPeers call documented here:

https://github.com/fimkrypto/fimk/blob/master/src/java/nxt/peer/GetPeers.java

And it should be done over POST, dont send too much requests or make a typo in the request since this API is protected against flooding or other misuse and it will blacklist you.
FIMK Developer | GPG fingerprint: CEF2 7C39 43BE 6800 504E  71BC 7E87 A7B0 AC34 E2D5 | mofowallet.com | blog

warmach #2 on: May 11, 2016, 05:58:11 PM

  • Senior Fimker
  • ***
  • Posts: 227
    • View Profile
Thanks for the info!
Warmach's Forging Pool
http://fim.warmach.info/pool/
May the forge be with you...