Exemplo n.º 1
0
        public override string ToString()
        {
            string str = OpenDHT.GetString(Data);

            if (str == string.Empty)
            {
                str = ToHexa(Data);
            }

            string hash = ToHexa(Hash).Substring(0, 8);

            return(string.Format("{0} {1} {2} 0x{3}", str, TTL, Algo, hash));
        }
Exemplo n.º 2
0
    /// <summary>
    /// OpenDHTLib Test compatible with OpenDHT python scripts (http://www.opendht.org/)
    /// </summary>
    public static void Main()
	{
        string line = new string('-', 80);
        string[] res = new string[] { "Success", "Capacity", "Again" };
        OpenDHT openDHT = new OpenDHT();
        OpenDHTMessage message = new OpenDHTMessage("OpenDHT.Net-Key", string.Empty, "OpenDHT.Net-Secret", 100);

        message.Content = "OpenDHT.Net-Value";
        Console.WriteLine("Put : " + res[openDHT.Put(message)]);

        Console.WriteLine("Get : ");
        foreach (string value in openDHT.GetStringValues(message.KeyStr))
            Console.WriteLine(value);
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value1";
        Console.WriteLine("PutRemovable : " + res[openDHT.PutRemovable(message)]);
        message.Content = "OpenDHT.Net-Value2";
        Console.WriteLine("PutRemovable : " + res[openDHT.PutRemovable(message)]);
        Console.WriteLine(line);

        Console.WriteLine("GetDetails :");
        foreach (OpenDHTMessageDetails msg in openDHT.GetDetailsStringValues(message.KeyStr))
            Console.WriteLine(msg);
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value1";
        Console.WriteLine("Remove : " + res[openDHT.Rm(message)]);
        Console.WriteLine(line);

        message.Content = "OpenDHT.Net-Value2";
        message.Secret = "OpenDHT.Net-SecretFoo";
        Console.WriteLine("Remove Fails : " + res[openDHT.Rm(message)]);
        Console.WriteLine(line);

        Console.WriteLine("GetDetails :");
        foreach (OpenDHTMessageDetails msg in openDHT.GetDetailsStringValues(message.KeyStr))
            Console.WriteLine(msg);
        Console.WriteLine(line);
	}
Exemplo n.º 3
0
 public OpenDHTMessageDetails[] GetDetailsStringValues(string key)
 {
     return(OpenDHT.GetDetailsValues(GetDetailsValues(key)));
 }
Exemplo n.º 4
0
 public string[] GetStringValues(string key)
 {
     return(OpenDHT.GetValues(GetValues(key)));
 }
Exemplo n.º 5
0
 public OpenDHTMessage(string key, string data, string secret, int ttl)
 {
     byte[] dataByte = OpenDHT.GetBytes(data);
     Init(key, dataByte, secret, ttl);
 }