Ejemplo n.º 1
0
        /// <summary>
        /// Outputs sniffed data to an XML file.
        /// </summary>
        /// <param name="FileName">File Name. The following strings will be replaced by current values:
        ///
        /// %YEAR% = Current year.
        /// %MONTH% = Current month.
        /// %DAY% = Current day.
        /// %HOUR% = Current hour.
        /// %MINUTE% = Current minute.
        /// %SECOND% = Current second.
        ///
        /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
        /// </param>
        /// <param name="Transform">Transform file name.</param>
        /// <param name="DeleteAfterDays">Number of days files will be kept. All files older than this
        /// in the corresponding folder will be removed. Default value is 7 days.</param>
        /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
        public XmlFileSniffer(string FileName, string Transform, int DeleteAfterDays,
                              BinaryPresentationMethod BinaryPresentationMethod)
            : base(null, BinaryPresentationMethod)
        {
            this.file            = null;
            this.output          = null;
            this.fileName        = FileName;
            this.transform       = Transform;
            this.deleteAfterDays = DeleteAfterDays;

            this.settings = new XmlWriterSettings()
            {
                CloseOutput             = true,
                ConformanceLevel        = ConformanceLevel.Document,
                Encoding                = Encoding.UTF8,
                Indent                  = true,
                IndentChars             = "\t",
                NewLineChars            = "\r\n",
                NewLineHandling         = NewLineHandling.Entitize,
                NewLineOnAttributes     = false,
                OmitXmlDeclaration      = false,
                WriteEndDocumentOnClose = true
            };

            string FolderName = Path.GetDirectoryName(FileName);

            if (!string.IsNullOrEmpty(FolderName) && !Directory.Exists(FolderName))
            {
                Log.Informational("Creating folder.", FolderName);
                Directory.CreateDirectory(FolderName);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Outputs sniffed data to a text file.
        /// </summary>
        /// <param name="FileName">File Name. The following strings will be replaced by current values:
        ///
        /// %YEAR% = Current year.
        /// %MONTH% = Current month.
        /// %DAY% = Current day.
        /// %HOUR% = Current hour.
        /// %MINUTE% = Current minute.
        /// %SECOND% = Current second.
        ///
        /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
        /// </param>
        /// <param name="DeleteAfterDays">Number of days files will be kept. All files older than this
        /// in the corresponding folder will be removed. Default value is 7 days.</param>
        /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
        public TextFileSniffer(string FileName, int DeleteAfterDays, BinaryPresentationMethod BinaryPresentationMethod)
            : base(null, BinaryPresentationMethod)
        {
            this.file            = null;
            this.output          = null;
            this.fileName        = FileName;
            this.deleteAfterDays = DeleteAfterDays;

            string FolderName = Path.GetDirectoryName(FileName);

            if (!Directory.Exists(FolderName))
            {
                Log.Informational("Creating folder.", FolderName);
                Directory.CreateDirectory(FolderName);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sending sniffer events to the corresponding web page(s).
        /// </summary>
        /// <param name="SnifferId">Sniffer ID</param>
        /// <param name="PageResource">Resource of page displaying the sniffer.</param>
        /// <param name="MaxLife">Maximum life of sniffer.</param>
        /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
        /// <param name="Sniffable">Object being sniffed</param>
        /// <param name="UserVariable">Event is only pushed to clients with a session contining a variable
        /// named <paramref name="UserVariable"/> having a value derived from <see cref="IUser"/>.</param>
        /// <param name="Privileges">Event is only pushed to clients with a user variable having the following set of privileges.</param>
        public WebSniffer(string SnifferId, string PageResource, TimeSpan MaxLife, BinaryPresentationMethod BinaryPresentationMethod, ISniffable Sniffable,
                          string UserVariable, params string[] Privileges)
            : base()
        {
            this.expires   = DateTime.Now.Add(MaxLife);
            this.sniffable = Sniffable;
            this.snifferId = SnifferId;
            this.resource  = PageResource;
            this.binaryPresentationMethod = BinaryPresentationMethod;
            this.tabIds        = null;
            this.userVariable  = UserVariable;
            this.privileges    = Privileges;
            this.feedbackCheck = Sniffable is HttpServer;

            if (this.feedbackCheck)
            {
                this.outgoing = new Cache <string, bool>(int.MaxValue, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
            }
            else
            {
                this.outgoing = null;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Outputs sniffed data to <see cref="Console.Out"/>.
 /// </summary>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 /// <param name="LineEndingMethod">Line ending method.</param>
 public ConsoleOutSniffer(BinaryPresentationMethod BinaryPresentationMethod,
                          LineEnding LineEndingMethod)
 {
     this.binaryPresentationMethod = BinaryPresentationMethod;
     this.lineEndingMethod         = LineEndingMethod;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Outputs sniffed data to an XML writer.
 /// </summary>
 /// <param name="Output">Output</param>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public XmlWriterSniffer(XmlWriter Output, BinaryPresentationMethod BinaryPresentationMethod)
 {
     this.output = Output;
     this.binaryPresentationMethod = BinaryPresentationMethod;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Outputs sniffed data to a text file.
 /// </summary>
 /// <param name="FileName">File Name. The following strings will be replaced by current values:
 ///
 /// %YEAR% = Current year.
 /// %MONTH% = Current month.
 /// %DAY% = Current day.
 /// %HOUR% = Current hour.
 /// %MINUTE% = Current minute.
 /// %SECOND% = Current second.
 ///
 /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
 /// </param>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public TextFileSniffer(string FileName, BinaryPresentationMethod BinaryPresentationMethod)
     : this(FileName, 7, BinaryPresentationMethod)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Outputs sniffed data to an XML file.
 /// </summary>
 /// <param name="FileName">File Name. The following strings will be replaced by current values:
 ///
 /// %YEAR% = Current year.
 /// %MONTH% = Current month.
 /// %DAY% = Current day.
 /// %HOUR% = Current hour.
 /// %MINUTE% = Current minute.
 /// %SECOND% = Current second.
 ///
 /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
 /// </param>
 /// <param name="Transform">Transform file name.</param>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public XmlFileSniffer(string FileName, string Transform, BinaryPresentationMethod BinaryPresentationMethod)
     : this(FileName, Transform, 7, BinaryPresentationMethod)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Outputs sniffed data to an XML file.
 /// </summary>
 /// <param name="FileName">File Name. The following strings will be replaced by current values:
 ///
 /// %YEAR% = Current year.
 /// %MONTH% = Current month.
 /// %DAY% = Current day.
 /// %HOUR% = Current hour.
 /// %MINUTE% = Current minute.
 /// %SECOND% = Current second.
 ///
 /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
 /// </param>
 /// <param name="DeleteAfterDays">Number of days files will be kept. All files older than this
 /// in the corresponding folder will be removed. Default value is 7 days.</param>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public XmlFileSniffer(string FileName, int DeleteAfterDays, BinaryPresentationMethod BinaryPresentationMethod)
     : this(FileName, string.Empty, DeleteAfterDays, BinaryPresentationMethod)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Outputs sniffed data to an XML file.
 /// </summary>
 /// <param name="FileName">File Name. The following strings will be replaced by current values:
 ///
 /// %YEAR% = Current year.
 /// %MONTH% = Current month.
 /// %DAY% = Current day.
 /// %HOUR% = Current hour.
 /// %MINUTE% = Current minute.
 /// %SECOND% = Current second.
 ///
 /// NOTE: Make sure files are stored in a separate folder, as old files will be automatically deleted.
 /// </param>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public XmlFileSniffer(string FileName, BinaryPresentationMethod BinaryPresentationMethod)
     : this(FileName, string.Empty, 7, BinaryPresentationMethod)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Outputs sniffed data to <see cref="Console.Error"/>.
 /// </summary>
 /// <param name="BinaryPresentationMethod">How binary data is to be presented.</param>
 public ConsoleErrorSniffer(BinaryPresentationMethod BinaryPresentationMethod)
     : base(Console.Error, BinaryPresentationMethod)
 {
 }