Exemple #1
0
        public void UpdateListenerConfig(string listenername, ListenerConfig listenerconfig)
        {
            try
            {
                listeners.Remove(listenerconfig.GetName());
                Listener res = dbcontext.Listeners.FirstOrDefault <Listener>(s => s.name == listenerconfig.GetName());
                res.name    = listenerconfig.GetName();
                res.lhost   = listenerconfig.GetHost();
                res.lport   = listenerconfig.GetPort();
                res.profile = listenerconfig.GetProfileid();
                if (listenerconfig.GetSsl())
                {
                    res.ListenerType = ListenerType.Https;
                }
                else
                {
                    res.ListenerType = ListenerType.Http;
                }

                dbcontext.Listeners.Update(res);
                dbcontext.SaveChanges();
            }
            catch (Exception)
            {
                Console.WriteLine("[x] Error removing listener");
            }
        }
Exemple #2
0
 public void RemoveListenerConfig(ListenerConfig listenerconfig)
 {
     try
     {
         listeners.Remove(listenerconfig.GetName());
         Listener res = dbcontext.Listeners.FirstOrDefault <Listener>(s => s.name == listenerconfig.GetName());
         dbcontext.Listeners.Remove(res);
         dbcontext.SaveChanges();
     }
     catch (Exception)
     {
         Console.WriteLine("[x] Error removing listener");
     }
 }
Exemple #3
0
        public void RegisterListenerConfig(string listenername, ListenerConfig listenerconfig)
        {
            try
            {
                if (!listeners.ContainsKey(listenername))
                {
                    listeners.Add(listenername, listenerconfig);
                    Listener listener = dbcontext.Listeners.FirstOrDefault <Listener>(s => s.name == listenername);
                    if (listener == null)
                    {
                        listener = new Listener
                        {
                            name    = listenerconfig.GetName(),
                            lhost   = listenerconfig.GetHost(),
                            lport   = listenerconfig.GetPort(),
                            profile = listenerconfig.GetProfileid(),
                        };

                        if (listenerconfig.GetSsl())
                        {
                            listener.ListenerType = ListenerType.Https;
                        }
                        else
                        {
                            listener.ListenerType = ListenerType.Http;
                        }
                        dbcontext.Listeners.Add(listener);
                        dbcontext.SaveChanges();
                    }
                }
                else
                {
                    Console.WriteLine("[x] Listener already exist");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("[x] Error adding listener {0}", e.Message);
            }
        }
Exemple #4
0
        public void ListListeners()
        {
            if (GetListenersConfig() != null)
            {
                Console.WriteLine("[*]  {0}", new string('-', 66));
                Console.WriteLine("[*] | {0,-20} | {1,-15} | {2,-5} | {3,-7} | {4,-5} |", "Name", "IP", "Port", "Profile", "SSL");
                Console.WriteLine("[*]  {0}", new string('-', 66));

                foreach (KeyValuePair <string, ListenerConfig> item in GetListenersConfig())
                {
                    try
                    {
                        ListenerConfig listenerConfig = item.Value;
                        Console.WriteLine("[*] | {0,-20} | {1,-15} | {2,-5} | {3,-7} | {4,-5} |", listenerConfig.GetName(), listenerConfig.GetHost(), listenerConfig.GetPort(), listenerConfig.GetProfileid(), listenerConfig.GetSsl());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[x] Listener need to be removed {0}", e.Message);
                    }
                }
                Console.WriteLine("[*]  {0}", new string('-', 66));
            }
        }
Exemple #5
0
 public void ListListeners()
 {
     if (GetListenersConfig() != null)
     {
         foreach (KeyValuePair <string, ListenerConfig> item in GetListenersConfig())
         {
             try
             {
                 ListenerConfig listenerConfig = item.Value;
                 Console.WriteLine("[*] {0} | Host: {1} | port: {2} | profile: {3}", listenerConfig.GetName(), listenerConfig.GetHost(), listenerConfig.GetPort(), listenerConfig.GetProfileid());
             }
             catch (Exception e)
             {
                 Console.WriteLine("[x] Listener need to be removed {0}", e.Message);
             }
         }
     }
 }