Exemplo n.º 1
0
        /// <summary>
        /// Stop the module, serialize the data object out
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStop()
        {
            ModuleError error = new ModuleError();

            error.errorType = ModuleErrorType.Success;

            try
            {
                if (!data.Save)
                {
                    data.Loaded_Lists  = new List <string>();
                    available_lists    = new List <string>();
                    data.logBlocked    = false;
                    data.blockIncoming = false;
                }

                PersistentData = data;
                SaveConfig();
            }
            catch (Exception e)
            {
                error.errorMessage = e.Message;
                error.errorType    = ModuleErrorType.UnknownError;
                error.moduleName   = "IPGuard";
            }
            return(error);
        }
Exemplo n.º 2
0
        public override ModuleError ModuleStart()
        {
            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;

            return me;
        }
Exemplo n.º 3
0
        public override ModuleError ModuleStop()
        {
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Start the mod, deserialize data into GuardData
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError error = new ModuleError();

            error.errorType = ModuleErrorType.Success;

            try
            {
                LoadConfig();
                if (PersistentData == null)
                {
                    data = new GuardData();
                }
                else
                {
                    data = (GuardData)PersistentData;
                }

                // block ranges aren't serialized, so go rebuild them with the loaded lists
                // when the module is started
                rebuild();
            }
            catch (Exception e)
            {
                error.errorMessage = e.Message;
                error.errorType    = ModuleErrorType.UnknownError;
                error.moduleName   = "IPGuard";
                data = new GuardData();
            }

            return(error);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Module initialization
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;

            try
            {
                LoadConfig();
                if (PersistentData == null)
                {
                    data = new ScanData();
                }
                else
                {
                    data = (ScanData)PersistentData;
                }

                // set our timer to do stuff
                janitor.Elapsed += new ElapsedEventHandler(timer_Tick);
                janitor.Interval = 60000;
                janitor.Enabled  = true;
                janitor.Start();
            }
            catch (Exception e)
            {
                me.errorMessage = e.Message;
                me.errorType    = ModuleErrorType.UnknownError;
                me.moduleName   = "Scan Detector";
                data            = new ScanData();
            }

            return(me);
        }
        /// <summary>
        /// ModuleStop
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStop()
        {
            ModuleError moduleError = new ModuleError();

            moduleError.errorType = ModuleErrorType.Success;
            return(moduleError);
        }
        public override ModuleError ModuleStop()
        {
            PersistentData = rules.ToArray();
            SaveConfig();
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 8
0
        public override ModuleError ModuleStop()
        {
            if (!data.Save)
                data.arpCache = new SerializableDictionary<IPAddress, byte[]>();

            PersistentData = data;
            SaveConfig();
            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;
            return me;
        }
Exemplo n.º 9
0
        // Action for ModuleStart
        public override ModuleError ModuleStart()
        {
            LoadConfig();
            if (PersistentData == null)
                data = new ICMPData();
            else
                data = (ICMPData)PersistentData;

            ModuleError moduleError = new ModuleError();
            moduleError.errorType = ModuleErrorType.Success;
            return moduleError;
        }
Exemplo n.º 10
0
        // Action for ModuleError
        public override ModuleError ModuleStop()
        {
            if (data != null)
            {
                if (!data.Save)
                    data = new DDoSData();

                PersistentData = data;
                SaveConfig();
            }
            ModuleError moduleError = new ModuleError();
            moduleError.errorType = ModuleErrorType.Success;
            return moduleError;
        }
Exemplo n.º 11
0
        public override ModuleError ModuleStop()
        {
            if (!data.Save)
            {
                data.arpCache = new SerializableDictionary <IPAddress, byte[]>();
            }

            PersistentData = data;
            SaveConfig();
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 12
0
 public override ModuleError ModuleStart()
 {
     LoadConfig();
     if (PersistentData == null)
     {
         data = new ArpData();
     }
     else
     {
         data = (ArpData)PersistentData;
     }
     ModuleError me = new ModuleError();
     me.errorType = ModuleErrorType.Success;
     return me;
 }
Exemplo n.º 13
0
        /// <summary>
        /// Starts the module
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError moduleError = new ModuleError();
            ipmon = new IPMonitorDisplay(this) { Dock = System.Windows.Forms.DockStyle.Fill };

            // configure the update timer to refresh the caches every
            // 5 seconds
            updateTimer.Elapsed += new ElapsedEventHandler(timer_Tick);
            updateTimer.Interval = 5000;
            updateTimer.Enabled = true;
            updateTimer.Start();

            moduleError.errorType = ModuleErrorType.Success;
            return moduleError;
        }
Exemplo n.º 14
0
        public override ModuleError ModuleStart()
        {
            LoadConfig();
            if (PersistentData == null)
            {
                data = new ArpData();
            }
            else
            {
                data = (ArpData)PersistentData;
            }
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 15
0
        // Action for ModuleStop
        public override ModuleError ModuleStop()
        {
            if (data != null)
            {
                if (!data.Save)
                {
                    data.RuleTable = new SerializableDictionary<string, List<string>>();
                    data.RuleTablev6 = new SerializableDictionary<string, List<string>>();
                }

                PersistentData = data;
                SaveConfig();
            }
            ModuleError moduleError = new ModuleError();
            moduleError.errorType = ModuleErrorType.Success;
            return moduleError;
        }
Exemplo n.º 16
0
        // Action for ModuleError
        public override ModuleError ModuleStop()
        {
            if (data != null)
            {
                if (!data.Save)
                {
                    data = new DDoSData();
                }

                PersistentData = data;
                SaveConfig();
            }
            ModuleError moduleError = new ModuleError();

            moduleError.errorType = ModuleErrorType.Success;
            return(moduleError);
        }
Exemplo n.º 17
0
        // Action for ModuleStart
        public override ModuleError ModuleStart()
        {
            LoadConfig();
            if (PersistentData == null)
            {
                data = new ICMPData();
            }
            else
            {
                data = (ICMPData)PersistentData;
            }

            ModuleError moduleError = new ModuleError();

            moduleError.errorType = ModuleErrorType.Success;
            return(moduleError);
        }
Exemplo n.º 18
0
        // Action for ModuleStop
        public override ModuleError ModuleStop()
        {
            if (data != null)
            {
                if (!data.Save)
                {
                    data.RuleTable   = new SerializableDictionary <string, List <string> >();
                    data.RuleTablev6 = new SerializableDictionary <string, List <string> >();
                }

                PersistentData = data;
                SaveConfig();
            }
            ModuleError moduleError = new ModuleError();

            moduleError.errorType = ModuleErrorType.Success;
            return(moduleError);
        }
Exemplo n.º 19
0
        public override ModuleError ModuleStop()
        {
            if (null != data)
            {
                if (!data.Save)
                {
                    data = new ScanData();
                }

                PersistentData = data;
                SaveConfig();
            }

            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Starts the module
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError moduleError = new ModuleError();

            ipmon = new IPMonitorDisplay(this)
            {
                Dock = System.Windows.Forms.DockStyle.Fill
            };

            // configure the update timer to refresh the caches every
            // 5 seconds
            updateTimer.Elapsed += new ElapsedEventHandler(timer_Tick);
            updateTimer.Interval = 5000;
            updateTimer.Enabled  = true;
            updateTimer.Start();

            moduleError.errorType = ModuleErrorType.Success;
            return(moduleError);
        }
Exemplo n.º 21
0
        public override ModuleError ModuleStart()
        {
            LoadConfig();
            rules = new List <MacRule>();
            lock (padlock)
            {
                if (PersistentData != null)
                {
                    rules.AddRange((MacRule[])PersistentData);
                }
                else
                {
                    rules = new List <MacRule>();
                }
            }

            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 22
0
        public override ModuleError ModuleStart()
        {
            rules = new List <Rule>();
            LoadConfig();
            lock (padlock)
            {
                if (PersistentData == null)
                {
                    rules.Add(new TCPAllRule(PacketStatus.BLOCKED, Direction.IN, true, true));
                }
                else
                {
                    rules.AddRange((Rule[])PersistentData);
                }
            }

            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Exemplo n.º 23
0
        protected override Boolean OnOpen()
        {
            try
            {
                _serialPort.Open();
                NotifyOpen(String.Format("{0} открыт, скорость {1}", PortName, Baudrate));

                return true;
            }
            catch (UnauthorizedAccessException)
            {
                LastError = new ModuleError(ModuleErrorCode.AccessDenied);
            }
            catch (ArgumentOutOfRangeException)
            {
                LastError = new ModuleError(ModuleErrorCode.WrongParam);
            }
            catch (ArgumentException)
            {
                LastError = new ModuleError(ModuleErrorCode.WrongPortName);
            }
            catch (InvalidOperationException)
            {
                LastError = new ModuleError(ModuleErrorCode.AlreadyOpen);
            }
            catch (IOException)
            {
                LastError = new ModuleError(ModuleErrorCode.PortNotPresent);
            }
            catch (Exception ex)
            {
                LastError = new ModuleError(ModuleErrorCode.Exception, ex.Message);
            }

            NotifyError(String.Format("Ошибка открытия {0}: {1}", PortName, LastError.Message));

            return false;
        }
Exemplo n.º 24
0
        public Boolean Open()
        {
            LastError = new ModuleError(ModuleErrorCode.None);

            TraceInfo(String.Format("Открытие {0}", LinkName));

            if (State == LinkState.Opened)
            {
                TraceWarn(String.Format("Уже открыт {0}", LinkName));

                return true;
            }

            State = LinkState.Opening;

            if (OnOpen())
            {
                State = LinkState.Opened;

                return true;
            }

            State = LinkState.Closed;

            return false;
        }
Exemplo n.º 25
0
 public override ModuleError ModuleStop()
 {
     PersistentData = rules.ToArray();
     SaveConfig();
     ModuleError me = new ModuleError();
     me.errorType = ModuleErrorType.Success;
     return me;
 }
Exemplo n.º 26
0
        public override ModuleError ModuleStart()
        {
            LoadConfig();
            rules = new List<MacRule>();
            lock (padlock)
            {
                if (PersistentData != null)
                {
                    rules.AddRange((MacRule[])PersistentData);
                }
                else
                    rules = new List<MacRule>();
            }

            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;
            return me;
        }
Exemplo n.º 27
0
        public override ModuleError ModuleStop()
        {
            lock (this) {
                // write any entries that may still be in the buffer to the log file
                writeBuffer();

                if (db == null)
                {
                    try
                    {
                        db.Close();
                    }
                    catch (Exception e)
                    {
                        PassThru.LogCenter.WriteErrorLog(e);
                    }
                }

                ModuleError me = new ModuleError();
                me.errorType = ModuleErrorType.Success;
                return me;
            }
        }
Exemplo n.º 28
0
        public override ModuleError ModuleStop()
        {
            if (null != data)
            {
                if (!data.Save)
                    data = new ScanData();

                PersistentData = data;
                SaveConfig();
            }

            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;
            return me;
        }
Exemplo n.º 29
0
        protected override Boolean OnSend(Byte[] buffer)
        {
            try
            {
                _serialPort.Write(buffer, 0, buffer.Length);

                return true;
            }
            catch (ArgumentNullException)
            {
                LastError = new ModuleError(ModuleErrorCode.BufferIsNull);
            }
            catch (InvalidOperationException)
            {
                LastError = new ModuleError(ModuleErrorCode.NotOpened);
            }
            catch (ArgumentOutOfRangeException)
            {
                LastError = new ModuleError(ModuleErrorCode.WrongParam, "count=" + buffer.Length.ToString());
            }
            catch (ArgumentException)
            {
                LastError = new ModuleError(ModuleErrorCode.WrongParam, "count=" + buffer.Length.ToString());
            }
            catch (TimeoutException ex)
            {
                LastError = new ModuleError(ModuleErrorCode.Exception, ex.Message);
            }
            catch (Exception ex)
            {
                LastError = new ModuleError(ModuleErrorCode.Exception, ex.Message);
            }

            NotifyError(String.Format("Ошибка отправки {0}: {1}", PortName, LastError.Message));

            return false;
        }
Exemplo n.º 30
0
        public override ModuleError ModuleStart()
        {
            rules = new List<Rule>();
            LoadConfig();
            lock (padlock)
            {
                if (PersistentData == null)
                {
                    rules.Add(new TCPAllRule(PacketStatus.BLOCKED, Direction.IN, true, true));
                }
                else
                {
                    rules.AddRange((Rule[])PersistentData);
                }
            }

            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;
            return me;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Module initialization
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;

            try
            {
                LoadConfig();
                if (PersistentData == null)
                    data = new ScanData();
                else
                    data = (ScanData)PersistentData;

                // set our timer to do stuff
                janitor.Elapsed += new ElapsedEventHandler(timer_Tick);
                janitor.Interval = 60000;
                janitor.Enabled = true;
                janitor.Start();
            }
            catch (Exception e)
            {
                me.errorMessage = e.Message;
                me.errorType = ModuleErrorType.UnknownError;
                me.moduleName = "Scan Detector";
                data = new ScanData();
            }

            return me;
        }
Exemplo n.º 32
0
 public Boolean SendBytes(Byte[] buffer)
 {
     if (State == LinkState.Opened)
     {
         Boolean result = OnSend(buffer);
         if (result)
         {
             TraceDump(DebugLevel.Out, LinkName, buffer);
         }
         return result;
     }
     else
     {
         // Передача данных в закрытый порт
         LastError = new ModuleError(ModuleErrorCode.SendToClosed);
     }
     return false;
 }
Exemplo n.º 33
0
        protected override Boolean OnClose()
        {
            try
            {
                _serialPort.Close();
                NotifyClose(String.Format("{0} закрыт", PortName));

                return true;
            }
            catch (IOException ex)
            {
                LastError = new ModuleError(ModuleErrorCode.Exception, ex.Message);
            }
            catch (Exception ex)
            {
                LastError = new ModuleError(ModuleErrorCode.Exception, ex.Message);
            }

            NotifyError(String.Format("Ошибка закрытия {0}: {1}", PortName, LastError.Message));

            return false;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Start the mod, deserialize data into GuardData
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStart()
        {
            ModuleError error = new ModuleError();
            error.errorType = ModuleErrorType.Success;

            try
            {
                LoadConfig();
                if (PersistentData == null)
                    data = new GuardData();
                else
                    data = (GuardData)PersistentData;

                // block ranges aren't serialized, so go rebuild them with the loaded lists
                // when the module is started
                rebuild();
            }
            catch (Exception e)
            {
                error.errorMessage = e.Message;
                error.errorType = ModuleErrorType.UnknownError;
                error.moduleName = "IPGuard";
                data = new GuardData();
            }

            return error;
        }
Exemplo n.º 35
0
        /// <summary>
        /// Stop the module, serialize the data object out
        /// </summary>
        /// <returns></returns>
        public override ModuleError ModuleStop()
        {
            ModuleError error = new ModuleError();
            error.errorType = ModuleErrorType.Success;

            try
            {
                if (!data.Save)
                {
                    data.Loaded_Lists = new List<string>();
                    available_lists = new List<string>();
                    data.logBlocked = false;
                    data.blockIncoming = false;
                }

                PersistentData = data;
                SaveConfig();
            }
            catch (Exception e)
            {
                error.errorMessage = e.Message;
                error.errorType = ModuleErrorType.UnknownError;
                error.moduleName = "IPGuard";
            }
            return error;
        }
Exemplo n.º 36
0
 /// <summary>
 /// ModuleStop
 /// </summary>
 /// <returns></returns>
 public override ModuleError ModuleStop()
 {
     ModuleError moduleError = new ModuleError();
     moduleError.errorType = ModuleErrorType.Success;
     return moduleError;
 }