Example #1
0
        protected virtual void WaitForConnection(object objListener)
        {
            HttpListener listener = (HttpListener)objListener;

            while (true)
            {
                // Wait for a connection.  Return to caller while we wait.
                HttpListenerContext context = listener.GetContext();
                logger.Log(LogMessage.Create(context.Verb().Value + ": " + context.Path().Value));

                // Redirect to HTTPS if not local and not secure.
                if (!context.Request.IsLocal && !context.Request.IsSecureConnection)
                {
                    logger.Log(LogMessage.Create("Redirecting to HTTPS"));
                    string redirectUrl = context.Request.Url.ToString().Replace("http:", "https:");
                    context.Response.Redirect(redirectUrl);
                    context.Response.Close();
                }
                else
                {
                    string data = new StreamReader(context.Request.InputStream, context.Request.ContentEncoding).ReadToEnd();

                    // If the pre-router lets us continue, the route the request.
                    if (ServiceManager.Exists <IWebWorkflowService>())
                    {
                        if (ServiceManager.Get <IWebWorkflowService>().PreRouter(context))
                        {
                            ProcessRoute(context, data);
                        }
                        else
                        {
                            // Otherwise just close the response.
                            context.Response.Close();
                        }
                    }
                    else
                    {
                        ProcessRoute(context, data);
                    }
                }
            }
        }
Example #2
0
        public void StartCertificateMonitor(CertRegistrationMethod registrationMethod)
        {
            this.registrationMethod = registrationMethod;
            websiteName             = ServiceManager.Get <IAppConfigService>().GetValue("website");
            certPassword            = ServiceManager.Get <IAppConfigService>().GetValue("certPassword");
            log = new StringBuilder();

            Task.Run(() =>
            {
                try
                {
                    CheckCertificate();
                    Thread.Sleep(ONE_MINUTE);
                }
                catch (Exception ex)
                {
                    logger.Log(LogMessage.Create("CERTIFICATE PROCESSING ERROR:" + ex.Message + "\r\n" + ex.StackTrace));
                }
            });
        }
 public void LogException(object source, Exception exception)
 => Logger.GetLogger()?.Log(FunctionId.Extension_Exception, LogMessage.Create(source.GetType().Name + " : " + ToLogFormat(exception)));
Example #4
0
        public void ShowErrorInfoForCodeFix(string codefixName, Action OnEnableClicked, Action OnEnableAndIgnoreClicked, Action OnClose)
        {
            var message = LogMessage.Create($"{codefixName} crashed");

            Logger.Log(FunctionId.Extension_Exception, message);
        }
Example #5
0
        private async Task <List <PackageFile> > GetAssembliesAsync(PackageInput packageInput)
        {
            var result = new List <PackageFile>();
            var seen   = new HashSet <ISleetFile>();

            var assemblyFiles = await packageInput.RunWithLockAsync(p => Task.FromResult(p.Zip.Entries
                                                                                         .Where(e => e.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                                                                                         .ToList()));

            var pdbFiles = await packageInput.RunWithLockAsync(p => Task.FromResult(p.Zip.Entries
                                                                                    .Where(e => e.FullName.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase))
                                                                                    .ToList()));

            foreach (var assembly in assemblyFiles)
            {
                string          assemblyHash = null;
                string          pdbHash      = null;
                ZipArchiveEntry pdbEntry     = null;
                var             valid        = false;

                try
                {
                    using (var stream = await packageInput.GetEntryStreamWithLockAsync(assembly))
                        using (var reader = new PEReader(stream))
                        {
                            assemblyHash = SymbolsUtility.GetSymbolHashFromAssembly(reader);
                            pdbHash      = SymbolsUtility.GetPDBHashFromAssembly(reader);
                        }

                    var assemblyWithoutExt = SleetLib.PathUtility.GetFullPathWithoutExtension(assembly.FullName);

                    pdbEntry = pdbFiles.FirstOrDefault(e =>
                                                       StringComparer.OrdinalIgnoreCase.Equals(
                                                           SleetLib.PathUtility.GetFullPathWithoutExtension(e.FullName), assemblyWithoutExt));

                    valid = true;
                }
                catch
                {
                    // Ignore bad assemblies
                    var message = LogMessage.Create(LogLevel.Warning, $"Unable add symbols for {assembly.FullName}, this file will not be present in the symbol server.");
                    await _context.Log.LogAsync(message);
                }

                if (valid)
                {
                    // Add .dll
                    var fileInfo  = new FileInfo(assembly.FullName);
                    var dllFile   = _context.Source.Get(SymbolsIndexUtility.GetAssemblyFilePath(fileInfo.Name, assemblyHash));
                    var indexFile = _context.Source.Get(SymbolsIndexUtility.GetAssemblyToPackageIndexPath(fileInfo.Name, assemblyHash));

                    // Avoid duplicates
                    if (seen.Add(dllFile))
                    {
                        result.Add(new PackageFile(fileInfo.Name, assemblyHash, assembly, dllFile, indexFile));
                    }

                    // Add .pdb
                    if (pdbEntry != null)
                    {
                        var pdbFileInfo  = new FileInfo(pdbEntry.FullName);
                        var pdbFile      = _context.Source.Get(SymbolsIndexUtility.GetAssemblyFilePath(pdbFileInfo.Name, pdbHash));
                        var pdbIndexFile = _context.Source.Get(SymbolsIndexUtility.GetAssemblyToPackageIndexPath(pdbFileInfo.Name, pdbHash));

                        // Avoid duplicates
                        if (seen.Add(pdbFile))
                        {
                            result.Add(new PackageFile(pdbFileInfo.Name, pdbHash, pdbEntry, pdbFile, pdbIndexFile));
                        }
                    }
                }
            }

            return(result);
        }
Example #6
0
 public void LogError(string source, string message)
 {
     Logger.GetLogger()?.Log(FunctionId.Extension_Exception, LogMessage.Create(source + " : " + message));
 }