Skip to content

Tracker Daemon

danrobi11 edited this page Nov 10, 2020 · 1 revision

The MuWire Tracker Daemon or mwtrackerd for short is a project to enable anyone to create a website indexing MuWire hashes similar to how torrent sites work. The daemon will track the availability of a file on the MuWire network, enabling the site operator to remove any entries that are no longer available.

The daemon does not have a GUI, but exposes a JSON-RPC interface. The methods to the interface are documented below.

Building and running

Type ./gradlew clean tracker:bootRun

The first time the daemon runs it will launch a setup wizard which will ask you about the ports of your i2p router, what port and network interface you want to use for the JSON-RPC endpoint.

Let's say you have selected port 12345 on localhost. To verify your daemon is up and running, you can issue the following command:

curl  -d '{"id":0,"method":"status"}' http://localhost:12345/tracker

If everything is fine, you should see a response like

{"jsonrpc":"2.0","id":0,"result":{"status":"Running","connections":20,"swarms":0}}

How does it work

The daemon "tracks" hashes of files in two ways:

  1. by issuing queries in the MuWire network
  2. by pinging hosts that may have the file.

JSON-RPC API

"status"

This method returns an object that contains the current status of the daemon, the number of connections to the MuWire network and how many swarms it is tracking.

"track"

This method takes as a parameter the string representation of the hash of the file to be tracked and starts tracking it. It returns null. Example use:

curl  -d '{"id":0,"method":"track", "params":["hnInliLVsFQNR26fr~pvs7qnmT~~l787nCK9dQshkpg="]}' http://localhost:12345/tracker
{"jsonrpc":"2.0","id":0,"result":null}

"forget"

This method is the opposite of the track method. It takes as a parameter the hash of the file and forgets all about it. It returns true if any swarms were forgotten and false if the file wasn't tracked to begin with. Example use:

curl  -d '{"id":0,"method":"forget", "params":["RZnnD8-r1MBWlAKePRYYyudvHSI6naHuNR2gZ5sHIJQ="]}' http://localhost:12345/tracker
{"jsonrpc":"2.0","id":0,"result":true}

"info"

This method returns information about a file that is being tracked, like who are the seeders and who are the leechers, also how many "unknown" hosts are in the swarm. Unknown hosts are those who have not been queried yet.

Example use:

curl  -d '{"id":0,"method":"info", "params":["RZnnD8-r1MBWlAKePRYYyudvHSI6naHuNR2gZ5sHIJQ="]}' http://localhost:12345/tracker
{"jsonrpc":"2.0","id":0,"result":{"seeders":[],"leechers":[],"unknown":1}}

Spring Boot Attenuator

mwtrackerd uses Spring Boot and exposes an Attenuator endpoint that shows information such as memory usage, cpu usage and so on. To find out more google for "Spring Boot Attenuator"

Configuration options

The configuration for the daemon is split in three files, all of which reside in $HOME/.mwtrackerd. They are:

  • MuWire.properties - the only property that matters in this file is the nickname with which your tracker identifies itself to the MuWire network.
  • i2p.properties - i2cp properties to pass to the router, also the host:port of the i2p router to connect to.
  • tracker.properties - properties specific to the tracker. Read below for more information.

In the tracker.properties the following properties are currently recognized:

  • tracker.jsonRpc.iface - the network interface to bind the JSON-RPC endpoint to.
  • tracker.jsonRpc.port - the port to listen on for JSON-RPC requests
  • tracker.swarmParameters.queryInterval - how often to kick off queries for the tracked files on the MuWire network. Value is in hours. Default is 1 hour.
  • tracker.swarmParameters.pingParallel - how many hosts to ping at the same time. Default is 5
  • tracker.swarmParameters.pingInterval - do not ping the same host more often than this interval. Value is in minutes, default is 15.
  • tracker.swarmParameters.expiry - how long to wait before declaring a host is dead if it hasn't responded to our pings. Value is in minutes. Default is 60
  • tracker.swarmParameters.pingTimeout - how long to wait for a response to a ping before counting it as failed. Value is in seconds, default is 20
  • tracker.swarmParameters.maxFailures - do not consider a host to be dead until they have failed to respond to our pings this many times. Default is 3.
Clone this wiki locally