/// <summary>Create a DtlsFilter.</summary> /// <param name="key">A CryptoKey initialized by the OpenSSL.NET library.</param> /// <param name="cert">The path to the certificate to use.</param> /// <param name="ca_cert">The path to the ca certificate to use.</param> /// <param name="client">Use client initialization parameters.</param> public DtlsAssociation(ISender sender, CertificateHandler ch, PType ptype, Ssl ssl, bool client) : base(sender, ch) { _ip = new IdentifierPair(); PType = ptype; _ssl = ssl; _client = client; _ssl.SetReadAhead(1); // Buggy SSL versions have issue with compression and dtls _ssl.SetOptions((int) SslOptions.SSL_OP_NO_COMPRESSION); if(client) { _ssl.SetConnectState(); } else { _ssl.SetAcceptState(); } // The ssl object will take control _read = BIO.MemoryBuffer(false); _read.NonBlocking = true; _write = BIO.MemoryBuffer(false); _write.NonBlocking = true; _ssl.SetBIO(_read, _write); _ssl.DoHandshake(); _buffer = new byte[Int16.MaxValue]; _buffer_sync = new object(); _fe_lock = 0; }
/// <summary>Create a XmppEdge.</summary> public XmppEdge(IEdgeSendHandler send_handler, XmppTransportAddress local_ta, XmppTransportAddress remote_ta, bool inbound) : base(send_handler, inbound) { _ip = new IdentifierPair(); _local_ta = local_ta; _remote_ta = remote_ta; To = remote_ta.JID; }
/// <summary>Constructor for an outgoing edge, since we don't know the remote /// id yet, it must be outgoing!</summary> public SubringEdge(TransportAddress local_ta, TransportAddress remote_ta, bool inbound, ISender sender, PType ptype) : base(null, inbound) { _ip = new IdentifierPair(); _local_ta = local_ta; _remote_ta = remote_ta; _ptype = ptype; _overlay_sender = sender; }
public void Test() { MemBlock payload; int local_id, remote_id; IdentifierTable it_0 = new IdentifierTable(); IIdentifierPair idpair_0 = new IdentifierPair(); IdentifierTable it_1 = new IdentifierTable(); IIdentifierPair idpair_1 = new IdentifierPair(); it_0.Add(idpair_0); it_1.Parse(idpair_0.Header, out payload, out local_id, out remote_id); Assert.AreEqual(local_id, 0, "Inbound local_id"); Assert.AreNotEqual(remote_id, 0, "Inbound remote_id"); idpair_1.RemoteID = remote_id; it_1.Add(idpair_1); it_0.Parse(idpair_1.Header, out payload, out local_id, out remote_id); Assert.IsTrue(it_0.Verify(idpair_0, idpair_1.Header, out payload), "Return"); Assert.IsTrue(it_1.Verify(idpair_1, idpair_0.Header, out payload), "Inbound 2"); Assert.IsTrue(it_0.Verify(idpair_0, idpair_1.Header, out payload), "Return 2"); Assert.AreEqual(idpair_0.LocalID, idpair_1.RemoteID, "idpair_0.LocalID"); Assert.AreEqual(idpair_1.LocalID, idpair_0.RemoteID, "idpair_1.LocalID"); Assert.AreNotEqual(0, idpair_0.LocalID, "idpair_0.LocalID != 0"); Assert.AreNotEqual(0, idpair_1.LocalID, "idpair_1.LocalID != 0"); IIdentifierPair idpair_2 = new IdentifierPair(); idpair_2.RemoteID = idpair_0.LocalID; idpair_2.LocalID = 1; try { Assert.IsFalse(it_0.Verify(idpair_0, idpair_2.Header, out payload), "Malicious packet"); } catch { } IIdentifierPair idpair_3 = new IdentifierPair(); try { Assert.IsFalse(it_0.Verify(idpair_3, idpair_3.Header, out payload), "Broken packet"); } catch { } }