Example #1
0
        public void SymetricTest()
        {
            var initResults = new Dictionary <NatPortType, NatInitInfo>();

            initResults.Add(NatPortType.GP, new NatInitInfo()
            {
                PrivateIPEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.1"), 0),
                PublicIPEndPoint  = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80)
            });
            initResults.Add(NatPortType.NN1, new NatInitInfo()
            {
                PrivateIPEndPoint = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 0),
                PublicIPEndPoint  = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 81)
            });
            initResults.Add(NatPortType.NN2, new NatInitInfo()
            {
                PrivateIPEndPoint = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80),
                PublicIPEndPoint  = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 82)
            });
            initResults.Add(NatPortType.NN3, new NatInitInfo()
            {
                PrivateIPEndPoint = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80),
                PublicIPEndPoint  = new IPEndPoint(IPAddress.Parse("10.0.0.1"), 83)
            });

            var prop = AddressCheckHandler.DetermineNatType(initResults);

            Assert.Equal(NatType.Symmetric, prop.NatType);
        }
        public void AddressTest()
        {
            var rawRequest = new byte[] { 0xfd, 0xfc, 0x1e, 0x66, 0x6a, 0xb2, 0x03, 0x0a, 0x00, 0x00, 0x03, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
            var request    = new AddressCheckRequest(rawRequest);
            var handler    = new AddressCheckHandler(_client, request);

            handler.Handle();
        }