Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Future idea: create tool like iftop via API
            //Posible features:
            // DNS resolve
            // Geolocation - https://db-ip.com/db/
            // Visualise if address is from any AddressList
            // ??
            // looking for volunteers :-)

            using (ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api))
            {
                connection.Open(ConfigurationManager.AppSettings["host"], ConfigurationManager.AppSettings["user"], ConfigurationManager.AppSettings["pass"]);
                string interfaceName = ConfigurationManager.AppSettings["interface"];

                Console.Clear();

                var loadingContext = connection.LoadAsync <ToolTorch>(
                    TorchItemRead, error => Console.WriteLine(error.ToString()),
                    connection.CreateParameter("interface", interfaceName),
                    //connection.CreateParameter("ip-protocol", "any"),
                    connection.CreateParameter("port", "any"),
                    connection.CreateParameter("src-address", "0.0.0.0/0"),
                    connection.CreateParameter("dst-address", "0.0.0.0/0"));

                Console.ReadLine();

                loadingContext.Cancel();
            }
        }
Exemplo n.º 2
0
        public List <ToolPing> Ping(string address, short count = 1, short size = 64)
        {
            List <ToolPing> responseList      = new List <ToolPing>();
            Exception       responseException = null;

            try
            {
                ITikCommand pingCommand = connection.LoadAsync <ToolPing>(ping =>
                                                                          responseList.Add(ping),
                                                                          exception => responseException = exception,
                                                                          connection.CreateParameter("address", address),
                                                                          connection.CreateParameter("count", count.ToString()),
                                                                          connection.CreateParameter("size", "64")
                                                                          );

                Thread.Sleep(2 * 1000);
                if (responseException != null)
                {
                    throw responseException;
                }
                return(responseList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }