コード例 #1
0
        /// <summary>
        /// Create a log file scanner
        /// </summary>
        /// <param name="service">IPBan service</param>
        /// <param name="source">The source, i.e. SSH or SMTP, etc.</param>
        /// <param name="pathAndMask">File path and mask (i.e. /var/log/auth*.log)</param>
        /// <param name="regex">Regex to parse file lines to pull out ipaddress and username</param>
        /// <param name="maxFileSize">Max size of file before it is deleted or 0 for unlimited</param>
        /// <param name="pingIntervalMilliseconds"></param>
        public IPBanLogFileScanner(IIPBanService service, string source, string pathAndMask, string regex, long maxFileSize = 0, int pingIntervalMilliseconds = 10000)
        {
            Source           = source;
            this.service     = service;
            this.maxFileSize = maxFileSize;
            service.AddUpdater(this);
            PathAndMask        = pathAndMask;
            Regex              = IPBanConfig.ParseRegex(regex);
            directoryToWatch   = Path.GetDirectoryName(pathAndMask);
            fileMask           = Path.GetFileName(pathAndMask);
            pingTimer          = new System.Timers.Timer(pingIntervalMilliseconds);
            pingTimer.Elapsed += PingTimerElapsed;
            pingTimer.Start();

            // add initial files
            foreach (string existingFileName in Directory.GetFiles(Path.GetDirectoryName(pathAndMask), Path.GetFileName(pathAndMask), SearchOption.TopDirectoryOnly))
            {
                // start at end of existing files
                AddPingFile(existingFileName, new FileInfo(existingFileName).Length);
            }
        }
コード例 #2
0
 public IPBanLogFileManager(IIPBanService service)
 {
     this.service           = service;
     service.ConfigChanged += UpdateLogFiles;
 }
コード例 #3
0
ファイル: IPBanEventViewerTests.cs プロジェクト: tareq2/IPBan
 void IIPBanDelegate.Start(IIPBanService service)
 {
 }
コード例 #4
0
 void IIPBanDelegate.Start(IIPBanService service)
 {
     AddEvent(nameof(IIPBanDelegate.Start));
 }
コード例 #5
0
 public IPBanWindowsEventViewer(IIPBanService service)
 {
     this.service = service;
     service.AddUpdater(this);
     Update();
 }
コード例 #6
0
 public ExternalBlocker(IIPBanService service)
 {
     this.service = service;
 }