Init
This commit is contained in:
82
TorWebClient/TorClient/ORConnections/Enumerators/ORReason.cs
Normal file
82
TorWebClient/TorClient/ORConnections/Enumerators/ORReason.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Tor
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumerator containing the different reasons for a <c>ORStatus.Closed</c> or <c>ORStatus.Failed</c> state.
|
||||
/// </summary>
|
||||
public enum ORReason
|
||||
{
|
||||
/// <summary>
|
||||
/// The reason was not provided or could not be determined.
|
||||
/// </summary>
|
||||
[Description(null)]
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection has shut down cleanly.
|
||||
/// </summary>
|
||||
[Description("DONE")]
|
||||
Done,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection received an <c>ECONNREFUSED</c> when connecting to the target OR.
|
||||
/// </summary>
|
||||
[Description("CONNECTREFUSED")]
|
||||
ConnectRefused,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection connected to the OR, but the identity was not what was expected.
|
||||
/// </summary>
|
||||
[Description("IDENTITY")]
|
||||
Identity,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection received an <c>ECONNRESET</c> or similar IO error from OR.
|
||||
/// </summary>
|
||||
[Description("CONNECTRESET")]
|
||||
ConnectReset,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection received an <c>ETIMEOUT</c> or similar IO eerror from the OR, or the connection
|
||||
/// has been terminated for being open for too long.
|
||||
/// </summary>
|
||||
[Description("TIMEOUT")]
|
||||
Timeout,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection received an <c>ENOTCONN</c>, <c>ENETUNREACH</c>, <c>ENETDOWN</c>, <c>EHOSTUNREACH</c> or
|
||||
/// similar error while connecting to the OR.
|
||||
/// </summary>
|
||||
[Description("NOROUTE")]
|
||||
NoRoute,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection received a different IO error.
|
||||
/// </summary>
|
||||
[Description("IOERROR")]
|
||||
IOError,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection does not have enough system resources to connect to the OR.
|
||||
/// </summary>
|
||||
[Description("RESOURCELIMIT")]
|
||||
ResourceLimit,
|
||||
|
||||
/// <summary>
|
||||
/// No pluggable transport was available.
|
||||
/// </summary>
|
||||
[Description("PT_MISSING")]
|
||||
PTMissing,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection closed for some other reason.
|
||||
/// </summary>
|
||||
[Description("MISC")]
|
||||
Misc
|
||||
}
|
||||
}
|
||||
50
TorWebClient/TorClient/ORConnections/Enumerators/ORStatus.cs
Normal file
50
TorWebClient/TorClient/ORConnections/Enumerators/ORStatus.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Tor
|
||||
{
|
||||
/// <summary>
|
||||
/// An enumerator containing the different states of an OR connection.
|
||||
/// </summary>
|
||||
public enum ORStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// No status was not provided or the status could not be determined.
|
||||
/// </summary>
|
||||
[Description(null)]
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection has been received and is beginning the handshake process.
|
||||
/// </summary>
|
||||
[Description("NEW")]
|
||||
New,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection has been launched and is beginning the client-side handshake process.
|
||||
/// </summary>
|
||||
[Description("LAUNCHED")]
|
||||
Launched,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection has been connected and the handshake is complete.
|
||||
/// </summary>
|
||||
[Description("CONNECTED")]
|
||||
Connected,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection failed.
|
||||
/// </summary>
|
||||
[Description("FAILED")]
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// The OR connection closed.
|
||||
/// </summary>
|
||||
[Description("CLOSED")]
|
||||
Closed
|
||||
}
|
||||
}
|
||||
96
TorWebClient/TorClient/ORConnections/ORConnection.cs
Normal file
96
TorWebClient/TorClient/ORConnections/ORConnection.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Tor
|
||||
{
|
||||
/// <summary>
|
||||
/// A class containing information regarding an OR connection within the tor service.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class ORConnection
|
||||
{
|
||||
private int circuitCount;
|
||||
private int id;
|
||||
private ORReason reason;
|
||||
private ORStatus status;
|
||||
private string target;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ORConnection"/> class.
|
||||
/// </summary>
|
||||
internal ORConnection()
|
||||
{
|
||||
this.circuitCount = 0;
|
||||
this.id = 0;
|
||||
this.reason = ORReason.None;
|
||||
this.status = ORStatus.None;
|
||||
this.target = "";
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of established and pending circuits.
|
||||
/// </summary>
|
||||
public int CircuitCount
|
||||
{
|
||||
get { return circuitCount; }
|
||||
internal set { circuitCount = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the connection. This value is only provided in version 0.2.5.2-alpha.
|
||||
/// </summary>
|
||||
public int ID
|
||||
{
|
||||
get { return id; }
|
||||
internal set { id = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reason for an <c>ORStatus.Closed</c> or <c>ORStatus.Failed</c> state.
|
||||
/// </summary>
|
||||
public ORReason Reason
|
||||
{
|
||||
get { return reason; }
|
||||
internal set { reason = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the connection.
|
||||
/// </summary>
|
||||
public ORStatus Status
|
||||
{
|
||||
get { return status; }
|
||||
internal set { status = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target of the connection.
|
||||
/// </summary>
|
||||
public string Target
|
||||
{
|
||||
get { return target; }
|
||||
internal set { target = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A class containing a read-only collection of <see cref="ORConnection"/> objects.
|
||||
/// </summary>
|
||||
public sealed class ORConnectionCollection : ReadOnlyCollection<ORConnection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ORConnectionCollection"/> class.
|
||||
/// </summary>
|
||||
/// <param name="list">The list of OR connections.</param>
|
||||
internal ORConnectionCollection(IList<ORConnection> list) : base(list)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user