Beispiel #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);
        }
Beispiel #2
0
        public override ModuleError ModuleStart()
        {
            ModuleError me = new ModuleError();
            me.errorType = ModuleErrorType.Success;

            return me;
        }
Beispiel #3
0
        public override ModuleError ModuleStop()
        {
            ModuleError me = new ModuleError();

            me.errorType = ModuleErrorType.Success;
            return(me);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        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;
        }
        // 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;
        }
        // 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;
        }
Beispiel #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);
        }
 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;
 }
        /// <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;
        }
Beispiel #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);
        }
        // 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;
        }
        // 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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        /// <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);
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #25
0
 public override ModuleError ModuleStop()
 {
     PersistentData = rules.ToArray();
     SaveConfig();
     ModuleError me = new ModuleError();
     me.errorType = ModuleErrorType.Success;
     return me;
 }
Beispiel #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;
        }
        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;
            }
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
 }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #36
0
 /// <summary>
 /// ModuleStop
 /// </summary>
 /// <returns></returns>
 public override ModuleError ModuleStop()
 {
     ModuleError moduleError = new ModuleError();
     moduleError.errorType = ModuleErrorType.Success;
     return moduleError;
 }