infoservice.tor
Class TorDirectoryServer

java.lang.Object
  extended by anon.infoservice.AbstractDatabaseEntry
      extended by infoservice.tor.TorDirectoryServer

public class TorDirectoryServer
extends AbstractDatabaseEntry

This is the implementation for an entry in the tor directory server database.


Field Summary
private  boolean m_bUserDefined
          Stores if this Entry was user defined and not automatic retrieved
private  long m_creationTimeStamp
          Stores the time when this TorDirectoryServer was created.
private  java.lang.String m_id
          Stores the ID of this TOR directory server.
private  TorDirectoryServerUrl m_url
          Stores the information how we can reach the directory server.
 
Fields inherited from class anon.infoservice.AbstractDatabaseEntry
XML_LAST_UPDATE
 
Constructor Summary
TorDirectoryServer(TorDirectoryServerUrl a_url, long a_timeValid, boolean a_userDefined)
          Creates a new TorDirectoryServer entry.
 
Method Summary
 byte[] downloadCompressedTorNodesInformation()
          This method connects to the tor directory server and downloads the tor nodes list.
 java.lang.String getId()
          Returns an ID for this TorDirectoryServer.
 long getLastUpdate()
          Returns the time in milliseconds when this db entry was created from the origin instance.
 long getVersionNumber()
          Returns the time when this TorDirectoryServer was created.
 boolean isUserDefined()
          Returns if this torDirectory Server was user defined
 
Methods inherited from class anon.infoservice.AbstractDatabaseEntry
getCreationTime, getExpireTime, isNewerThan, resetCreationTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_url

private TorDirectoryServerUrl m_url
Stores the information how we can reach the directory server.


m_id

private java.lang.String m_id
Stores the ID of this TOR directory server.


m_creationTimeStamp

private long m_creationTimeStamp
Stores the time when this TorDirectoryServer was created. This value is used to determine the more recent entry, if two entries are compared (higher version number -> more recent entry).


m_bUserDefined

private boolean m_bUserDefined
Stores if this Entry was user defined and not automatic retrieved

Constructor Detail

TorDirectoryServer

public TorDirectoryServer(TorDirectoryServerUrl a_url,
                          long a_timeValid,
                          boolean a_userDefined)
Creates a new TorDirectoryServer entry.

Parameters:
a_url - The URL where we can reach the directory server (host, port and filename).
a_timeValide - The period this TorDirectoryServer entry is valid and not outdated. The interval is given in milliseconds.
a_userDefined - Whether this TorDirectoryServer was defined in the config file (true) or was obtained via the list of running TOR directory servers (false). This is important, because user-defined TOR directory servers shall not be overwritten by one, we have obtained via the TOR directory server list.
Method Detail

downloadCompressedTorNodesInformation

public byte[] downloadCompressedTorNodesInformation()
This method connects to the tor directory server and downloads the tor nodes list. If this method is successful, the raw TOR nodes structure from the TOR directory server is returned. If there was an error while fetching the nodes list, null is returned.

Returns:
A byte[] with the plain information (already decompressed) about the running TOR nodes or null, if there was an error while fetching the list.

getId

public java.lang.String getId()
Returns an ID for this TorDirectoryServer. It's the complete URL of the tor nodes file (including protocol, host, port and filename, e.g. http://infoservice.inf.tu-dresden.de:80/torNodes). If this TorDirectoryServer is user-defined (in the configuration file), a (userdefined) is put before the ID.

Specified by:
getId in class AbstractDatabaseEntry
Returns:
A unique ID for this TorDirectoryServer.

getVersionNumber

public long getVersionNumber()
Returns the time when this TorDirectoryServer was created.

Specified by:
getVersionNumber in class AbstractDatabaseEntry
Returns:
A version number which is used to determine the more recent entry, if two entries are compared (higher version number -> more recent entry).

getLastUpdate

public long getLastUpdate()
Description copied from class: AbstractDatabaseEntry
Returns the time in milliseconds when this db entry was created from the origin instance.

Specified by:
getLastUpdate in class AbstractDatabaseEntry
Returns:
the time in milliseconds when this db entry was created from the origin instance

isUserDefined

public boolean isUserDefined()
Returns if this torDirectory Server was user defined

Overrides:
isUserDefined in class AbstractDatabaseEntry
Returns:
Whether this entry is user-defined.