public void Listen(Mesh mesh) { KeepListening = true; Task.Run (async () => { while (KeepListening) { var received = await client.ReceiveAsync(); mesh.DebugLog("We got some data: " + Helpers.ToHexSring(received.Buffer) + "\n"); var pipe = PipeTo(received.RemoteEndPoint); mesh.DebugLog("Pipe is " + pipe.ToString() + "\n"); if (pipe == null) { mesh.DebugLog("No pipe, we're bailing"); continue; } var packet = Packet.Decloak(received.Buffer); mesh.DebugLog("Packet is here"); if (packet == null || packet.FullPacket == null) { mesh.DebugLog("No packet bailing"); continue; } try { mesh.Receive(pipe, packet); } catch(Exception ex) { mesh.DebugLog(ex.Message); mesh.DebugLog(ex.StackTrace); } } }); }
public void Start() { Mesh = new Mesh (); Mesh.Generate (); foreach (var cs in Mesh.Self.CipherSets) { Console.WriteLine ("{0}: {1}", cs.Key.ToString ("x2"), Telehash.Base32Encoder.EncodeStripped (cs.Value.Keys.PublicKey)); } Console.WriteLine ("Hashname: " + Mesh.Hashname); var builder = new UriBuilder (Mesh.URI); builder.Host = "127.0.0.1"; builder.Port = 8989; Console.WriteLine (builder.ToString ()); udp = new UDPTransport (new System.Net.IPEndPoint (System.Net.IPAddress.Any, 8989)); udp.Listen (Mesh); Mesh.DebugLogEvent += new DebugLogHandler (OnDebugLog); }
public Link (Mesh mesh, string hashname, byte[] remotePublicKey) { sharedSetup (hashname); Mesh = mesh; Exchange = new Exchange (Mesh.Self, 0x1a, remotePublicKey); }