Esempio n. 1
0
        public void TestInitialize()
        {
            this.sniffer = new TextWriterSniffer(Console.Out, BinaryPresentationMethod.Hexadecimal);

            //this.remoteEndpoint = new IPEndPoint(Dns.GetHostAddresses("vs0.inf.ethz.ch")[0], 5684);
            //this.remoteEndpoint = new IPEndPoint(Dns.GetHostAddresses("californium.eclipse.org")[0], 5684);
            this.remoteEndpoint = new IPEndPoint(Dns.GetHostAddresses("leshan.eclipse.org")[0], 5684);
            //this.remoteEndpoint = new IPEndPoint(Dns.GetHostAddresses("lsys-home.dyndns.org")[0], 5684);

            this.udpClient   = new UdpClient(5684, AddressFamily.InterNetwork);
            this.dtlsOverUdp = new DtlsOverUdp(this.udpClient, DtlsMode.Client, null, null, this.sniffer);
        }
Esempio n. 2
0
        public void TestInitialize()
        {
            this.sniffer = new TextWriterSniffer(Console.Out, BinaryPresentationMethod.Hexadecimal);
            this.users   = new Users(new User("testid", "01020304", "HEX"));

            this.toServer = new DtlsBridge(null);
            this.toClient = new DtlsBridge(null);

            this.toServer.RemoteBridge = toClient;
            this.toClient.RemoteBridge = toServer;

            this.client = new DtlsEndpoint(DtlsMode.Client, toServer, this.sniffer);
            this.server = new DtlsEndpoint(DtlsMode.Server, toClient, this.users);
        }
Esempio n. 3
0
        public void TestCleanup()
        {
            if (this.dtlsOverUdp != null)
            {
                this.dtlsOverUdp.Dispose();
                this.dtlsOverUdp = null;
            }

            if (this.udpClient != null)
            {
                this.udpClient.Dispose();
                this.udpClient = null;
            }

            this.sniffer = null;
        }
        /// <summary>
        /// Converts the latest Xmpp communication that the sniffer holds to plain text.
        /// </summary>
        /// <param name="sniffer">The sniffer whose contents to get.</param>
        /// <returns>The xmpp communication in plain text.</returns>
        public static string SnifferToText(this InMemorySniffer sniffer)
        {
            if (sniffer is null)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
                using (TextWriterSniffer output = new TextWriterSniffer(writer, BinaryPresentationMethod.ByteCount))
                {
                    sniffer.Replay(output);
                }

            return(sb.ToString());
        }
Esempio n. 5
0
        public void TestCleanup()
        {
            if (this.client != null)
            {
                this.client.Dispose();
                this.client = null;
            }

            if (this.server != null)
            {
                this.server.Dispose();
                this.server = null;
            }

            this.toServer = null;
            this.toClient = null;
            this.users    = null;
            this.sniffer  = null;
        }