Ejemplo n.º 1
0
 public RemoteCitpTcpClient(ICitpLogService log, ITcpSocketClient client, CancellationToken cancellationToken)
 {
     _log               = log;
     _client            = client;
     _cancellationToken = cancellationToken;
     RemoteEndPoint     = new IpEndpoint(IpAddress.Parse(client.RemoteAddress), client.RemotePort);
 }
Ejemplo n.º 2
0
        public void IsReserved()
        {
            // TODO: Test range
            var address = new Address(IpAddress.Parse("0.0.0.1"));

            Assert.IsFalse(address.IsLoopback);
            Assert.IsFalse(address.IsPrivate);
            Assert.IsTrue(address.IsReserved);
        }
Ejemplo n.º 3
0
        public void Ctor()
        {
            var ipAddress = IPAddress.Parse("192.168.1.123");

            var address = new Address(IpAddress.Parse("192.168.1.123"));

            Assert.AreEqual((byte)192, address.OctetA);
            Assert.AreEqual((byte)168, address.OctetB);
            Assert.AreEqual((byte)1, address.OctetC);
            Assert.AreEqual((byte)123, address.OctetD);

            address = new Address((uint)IpAddress.ReverseBytes((int)ipAddress.Address));

            Assert.AreEqual((byte)192, address.OctetA);
            Assert.AreEqual((byte)168, address.OctetB);
            Assert.AreEqual((byte)1, address.OctetC);
            Assert.AreEqual((byte)123, address.OctetD);
        }
Ejemplo n.º 4
0
        public override void OnJsonRouteList(Json jRoutesList)
        {
            base.OnJsonRouteList(jRoutesList);

            string netstatPath = LocateExecutable("netstat");

            if (netstatPath != "")
            {
                string result = SystemShell.Shell1(netstatPath, "-rnl");

                string[] lines = result.Split('\n');
                foreach (string line in lines)
                {
                    if (line == "Routing tables")
                    {
                        continue;
                    }
                    if (line == "Internet:")
                    {
                        continue;
                    }
                    if (line == "Internet6:")
                    {
                        continue;
                    }

                    string[] fields = line.CleanSpace().Split(' ');

                    if ((fields.Length > 0) && (fields[0].ToLowerInvariant().Trim() == "destination"))
                    {
                        continue;
                    }

                    if (fields.Length >= 7)
                    {
                        Json      jRoute  = new Json();
                        IpAddress address = new IpAddress();
                        if (fields[0].ToLowerInvariant().Trim() == "default")
                        {
                            IpAddress gateway = new IpAddress(fields[1]);
                            if (gateway.Valid == false)
                            {
                                continue;
                            }
                            if (gateway.IsV4)
                            {
                                address = IpAddress.DefaultIPv4;
                            }
                            else if (gateway.IsV6)
                            {
                                address = IpAddress.DefaultIPv6;
                            }
                        }
                        else
                        {
                            address.Parse(fields[0]);
                        }
                        if (address.Valid == false)
                        {
                            continue;
                        }
                        jRoute["address"].Value   = address.ToCIDR();
                        jRoute["gateway"].Value   = fields[1];
                        jRoute["flags"].Value     = fields[2];
                        jRoute["refs"].Value      = fields[3];
                        jRoute["use"].Value       = fields[4];
                        jRoute["mtu"].Value       = fields[5];
                        jRoute["interface"].Value = fields[6];
                        if (fields.Length > 7)
                        {
                            jRoute["expire"].Value = fields[7];
                        }
                        jRoutesList.Append(jRoute);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public FilterEntry([NotNull] string from, [NotNull] string to) : this(IpAddress.Parse(from), IpAddress.Parse(to))
 {
 }
Ejemplo n.º 6
0
 private void messageReceived(object sender, UdpSocketMessageReceivedEventArgs e)
 {
     MessageReceived?.Invoke(this, new MessageReceivedEventArgs(
                                 new IpEndpoint(IpAddress.Parse(e.RemoteAddress), int.Parse(e.RemotePort)),
                                 e.ByteData));
 }
Ejemplo n.º 7
0
 public void LessThan()
 {
     Assert.AreEqual(-1, comparer.Compare(IpAddress.Parse("192.168.1.253"), IpAddress.Parse("192.168.1.254")));
     Assert.IsTrue(comparer.Compare(IpAddress.Parse("3.255.255.255"), IpAddress.Parse("6.0.0.1")) < -1);
 }
Ejemplo n.º 8
0
 public void Equal()
 {
     Assert.AreEqual(0, comparer.Compare(IpAddress.Parse("192.168.1.254"), IpAddress.Parse("192.168.1.254")));
 }
Ejemplo n.º 9
0
 public void ParseAddress()
 {
     Assert.AreEqual(0xC0A801FE, IpAddress.Parse("192.168.1.254"));
 }