Initial project commit
This commit is contained in:
45
TorControlLibrary/Responses/RouterStatusResponse.cs
Normal file
45
TorControlLibrary/Responses/RouterStatusResponse.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TorControlLibrary.Responses
|
||||
{
|
||||
public class RouterStatusResponse : CommandResponse
|
||||
{
|
||||
public static RouterStatusResponse Parse(String routerLine, String flagLine)
|
||||
{
|
||||
RouterStatusResponse resp = new RouterStatusResponse();
|
||||
|
||||
resp.PopulateData(routerLine, resp);
|
||||
resp.Flags = flagLine.Substring(2).Split(' ');
|
||||
return resp;
|
||||
}
|
||||
protected String ParseEncodedHashes(String value)
|
||||
{
|
||||
if (value.Length % 2 != 0)
|
||||
value += "=";
|
||||
Byte[] digest = Convert.FromBase64String(value);
|
||||
String hash = String.Empty;
|
||||
for (int i = 0; i < digest.Length; i++)
|
||||
hash += String.Format("{0:X2}", digest[i]);
|
||||
return hash;
|
||||
}
|
||||
//Starts at 2, line is r <data>
|
||||
[ParseAttribute(2)]
|
||||
public String NickName { get; set; }
|
||||
[ParseAttribute(3, CustomParser="ParseEncodedHashes")]
|
||||
public String Identity { get; set; }
|
||||
[ParseAttribute(4, CustomParser = "ParseEncodedHashes")]
|
||||
public String Digest { get; set; }
|
||||
[ParseAttribute(5,DataElementsToRead=2)]
|
||||
public DateTime Publication { get; set; }
|
||||
[ParseAttribute(7)]
|
||||
public System.Net.IPAddress Address { get; set; }
|
||||
[ParseAttribute(8)]
|
||||
public Int32 ORPort { get; set; }
|
||||
[ParseAttribute(9)]
|
||||
public Int32 DirPort { get; set; }
|
||||
public String[] Flags { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user