using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.ObjectModel; using System.Net; namespace Tor { /// /// A class containing information regarding a router within a circuit. /// [Serializable] public sealed class Router { private Bytes bandwidth; private string digest; private int dirPort; private RouterFlags flags; private string identity; private IPAddress ipAddress; private string nickname; private int orPort; private DateTime publication; /// /// Initializes a new instance of the class. /// /// The circuit containing the router. internal Router() { this.bandwidth = Bytes.Empty; this.digest = null; this.dirPort = -1; this.flags = RouterFlags.None; this.identity = null; this.ipAddress = null; this.nickname = null; this.orPort = -1; this.publication = DateTime.MinValue; } #region Properties /// /// Gets the bandwidth of the router. /// public Bytes Bandwidth { get { return bandwidth; } internal set { bandwidth = value; } } /// /// Gets the digest of the router. This is the hash of the most recent descriptor, encoded in base64. /// public string Digest { get { return digest; } internal set { digest = value; } } /// /// Gets the current directory port of the router. /// public int DIRPort { get { return dirPort; } internal set { dirPort = value; } } /// /// Gets the flags assigned against the router. /// public RouterFlags Flags { get { return flags; } internal set { flags = value; } } /// /// Gets the encoded hash identity of the router, encoded in base 64 with trailing equal symbols removed. /// public string Identity { get { return identity; } internal set { identity = value; } } /// /// Gets the IP address of the router. /// public IPAddress IPAddress { get { return ipAddress; } internal set { ipAddress = value; } } /// /// Gets the nickname of the router. /// public string Nickname { get { return nickname; } internal set { nickname = value; } } /// /// Gets the current OR port of the router. /// public int ORPort { get { return orPort; } internal set { orPort = value; } } /// /// Gets the publication time of the most recent descriptor. /// public DateTime Publication { get { return publication; } internal set { publication = value; } } #endregion } /// /// A class containing a read-only collection of objects. /// public sealed class RouterCollection : ReadOnlyCollection { /// /// Initializes a new instance of the class. /// /// The list of routers. internal RouterCollection(IList list) : base(list) { } } }