infoservice.tor
Class TorDirectoryAgent

java.lang.Object
  extended by infoservice.tor.TorDirectoryAgent
All Implemented Interfaces:
java.lang.Runnable

public class TorDirectoryAgent
extends java.lang.Object
implements java.lang.Runnable

This class is responsible for fetching the information about the active tor nodes. This class is a singleton.


Field Summary
private static java.lang.String DEFAULT_DIRECTORY_FILE
          The filename where we can find the TOR nodes file on a TOR directory server.
private  byte[] m_currentCompressedTorNodesList
          Stores the compressed tor nodes list.
private  byte[] m_currentTorNodesList
          Stores the current tor nodes list.
private  long m_updateInterval
          Stores the cycle time (in milliseconds) for updating the tor nodes list.
private static TorDirectoryAgent ms_tdaInstance
          Stores the instance of TorDirectoryAgent (singleton).
 
Constructor Summary
private TorDirectoryAgent()
          Creates a new instance of TorDirectoryAgent.
 
Method Summary
 void addTorDirectoryServer(TorDirectoryServer a_torDirectoryServer)
          Adds a TorDirectoryServer to the database of known tor directory servers.
 byte[] getCompressedTorNodesList()
          Returns the compressed tor nodes list (same uncompressed data as obtained by the getTorNodesList() call).
static TorDirectoryAgent getInstance()
          Returns the instance of TorDirectoryAgent (singleton).
 byte[] getTorNodesList()
          Returns the current tor nodes list.
 void run()
          This is the implementation of the tor nodes list update thread.
 void startUpdateThread(long a_updateInterval)
          This starts the internal tor nodes list update thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DIRECTORY_FILE

private static final java.lang.String DEFAULT_DIRECTORY_FILE
The filename where we can find the TOR nodes file on a TOR directory server.

See Also:
Constant Field Values

ms_tdaInstance

private static TorDirectoryAgent ms_tdaInstance
Stores the instance of TorDirectoryAgent (singleton).


m_currentTorNodesList

private byte[] m_currentTorNodesList
Stores the current tor nodes list. If we don't have a topical list, this value is null.


m_currentCompressedTorNodesList

private byte[] m_currentCompressedTorNodesList
Stores the compressed tor nodes list. If we don't have a topical list, this value is null.


m_updateInterval

private long m_updateInterval
Stores the cycle time (in milliseconds) for updating the tor nodes list. Until the update thread is started, this value is -1.

Constructor Detail

TorDirectoryAgent

private TorDirectoryAgent()
Creates a new instance of TorDirectoryAgent. We do some initialization here.

Method Detail

getInstance

public static TorDirectoryAgent getInstance()
Returns the instance of TorDirectoryAgent (singleton). If there is no instance, a new one is created.

Returns:
The TorDirectoryAgent instance.

addTorDirectoryServer

public void addTorDirectoryServer(TorDirectoryServer a_torDirectoryServer)
Adds a TorDirectoryServer to the database of known tor directory servers. This method can be used to add default directory servers (the expire time should be set to a nearly infinite value).

Parameters:
a_torDirectoryServer - The tor directory server to add.

startUpdateThread

public void startUpdateThread(long a_updateInterval)
This starts the internal tor nodes list update thread. You have to call this method exactly once after the creation of this TorDirectoryAgent. After the update thread is started once, later calls of this method are ignored.

Parameters:
a_updateInterval - The cycle time in milliseconds for fetching the current list of the tor nodes.

getTorNodesList

public byte[] getTorNodesList()
Returns the current tor nodes list. If we don't have a topical list, the returned value is null.

Returns:
The current tor nodes list or null, if we don't have a topical list.

getCompressedTorNodesList

public byte[] getCompressedTorNodesList()
Returns the compressed tor nodes list (same uncompressed data as obtained by the getTorNodesList() call). If we don't have a topical list, the returned value is null.

Returns:
The compressed tor nodes list or null, if we don't have a topical list.

run

public void run()
This is the implementation of the tor nodes list update thread.

Specified by:
run in interface java.lang.Runnable