Example #1
0
        public void BindingRequestParse()
        {
            var input = BufferPrimitives.ParseHexStream("000100002112a44261534344636d466568656253");

            Assert.AreEqual(StunPacket.ResultCodes.Ok, StunPacket.TryParse(input, out var output));
            Assert.AreEqual(StunPacket.MessageTypes.BindingRequest, output.MessageType);
            Assert.AreEqual(StunPacket.MessageClasses.Request, output.MessageClass);
            Assert.AreEqual(StunPacket.MessageMethods.Binding, output.MessageMethod);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("61534344636d466568656253"), output.TransactionId);
        }
Example #2
0
        public void BindingResponseParse()
        {
            var input = BufferPrimitives.ParseHexStream("0101000c2112a44261534344636d4665686562530020000800018a54e1baa549");

            Assert.AreEqual(StunPacket.ResultCodes.Ok, StunPacket.TryParse(input, out var output));
            Assert.AreEqual(StunPacket.MessageTypes.BindingSuccessResponse, output.MessageType);
            Assert.AreEqual(StunPacket.MessageClasses.SuccessResponse, output.MessageClass);
            Assert.AreEqual(StunPacket.MessageMethods.Binding, output.MessageMethod);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("61534344636d466568656253"), output.TransactionId);
            Assert.AreEqual(new IPEndPoint(new IPAddress(new byte[] { 192, 168, 1, 11 }), 43846), output.XorMappedAddress);
        }
Example #3
0
        public void BindingResponseIceParse()
        {
            var input = BufferPrimitives.ParseHexStream("0101002c2112a4422f3230767457754a415a3439002000080001cd97e1baa546000800140f966d9872873fb87da48206a40ef8933f1c483980280004d43b7dae");

            Assert.AreEqual(StunPacket.ResultCodes.Ok, StunPacket.TryParse(input, out var output));
            Assert.AreEqual(StunPacket.MessageTypes.BindingSuccessResponse, output.MessageType);
            Assert.AreEqual(StunPacket.MessageClasses.SuccessResponse, output.MessageClass);
            Assert.AreEqual(StunPacket.MessageMethods.Binding, output.MessageMethod);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("2f3230767457754a415a3439"), output.TransactionId);
            Assert.AreEqual(new IPEndPoint(new IPAddress(new byte[] { 192, 168, 1, 4 }), 60549), output.XorMappedAddress);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("0f966d9872873fb87da48206a40ef8933f1c4839"), output.MessageIntegrity);
            Assert.AreEqual(true, output.Fingerprint);
            Assert.IsTrue(output.VerifyIntegrity(Encoding.UTF8.GetBytes("2bosGehEV5BaY5xf3t4EJeII")));
        }
Example #4
0
        public void BindingRequestIceParse()
        {
            var input = BufferPrimitives.ParseHexStream("0001004c2112a4422f3230767457754a415a343900060009397536793a39517757000000c0570004000200008029000881a33ba9b20f6d45002400046e7e1eff00080014131089f8e85bc61285b469e97314b264e24098e38028000486676339");

            Assert.AreEqual(StunPacket.ResultCodes.Ok, StunPacket.TryParse(input, out var output));
            Assert.AreEqual(StunPacket.MessageTypes.BindingRequest, output.MessageType);
            Assert.AreEqual(StunPacket.MessageClasses.Request, output.MessageClass);
            Assert.AreEqual(StunPacket.MessageMethods.Binding, output.MessageMethod);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("2f3230767457754a415a3439"), output.TransactionId);
            Assert.AreEqual("9u6y:9QwW", output.Username);
            Assert.AreEqual(0x81a33ba9b20f6d45, output.IceControlledTieBreaker);
            Assert.AreEqual(1853759231, output.Priority);
            Assert.AreEqual(BufferPrimitives.ParseHexStream("131089f8e85bc61285b469e97314b264e24098e3"), output.MessageIntegrity);
            Assert.AreEqual(true, output.Fingerprint);
            Assert.IsTrue(output.VerifyIntegrity(Encoding.UTF8.GetBytes("2bosGehEV5BaY5xf3t4EJeII")));
        }