public DaemonCenterServerRpcHttpHost(Server daemonCenterServer) { try { // Start Log Server string certVaultDir = Lfs.ConfigPathStringToPhysicalDirectoryPath(@"Local/DaemonCenterRpc_CertVault/"); this.CertVault = new CertVault(certVaultDir, new CertVaultSettings(EnsureSpecial.Yes) { ReloadIntervalMsecs = 3600 * 1000, UseAcme = false, NonAcmeEnableAutoGenerateSubjectNameCert = false, }); PalSslServerAuthenticationOptions sslOptions = new PalSslServerAuthenticationOptions(this.CertVault.X509CertificateSelector("dummy", true), true, null); this.DaemonCenterServer = daemonCenterServer; JsonRpcServerConfig rpcCfg = new JsonRpcServerConfig(); HttpServerOptions httpConfig = new HttpServerOptions { HttpPortsList = new List <int>(), HttpsPortsList = Consts.Ports.DaemonCenterHttps._SingleList(), UseStaticFiles = false, AutomaticRedirectToHttpsIfPossible = false, HiveName = "DaemonCenterRpcHttpServer", DenyRobots = true, UseGlobalCertVault = false, ServerCertSelector = (param, sni) => (X509Certificate2)(this.CertVault.X509CertificateSelector(sni, true).NativeCertificate), }; this.HttpServer = JsonRpcHttpServerBuilder.StartServer(httpConfig, rpcCfg, this.DaemonCenterServer); } catch { this._DisposeSafe(); throw; } }
public LogServerApp() { try { this.Settings.AccessData(true, k => { string logDestDir = k.GetStr("DestDir", CoresConfig.LogServerApp.DefaultDestDirString); string certVaultDir = k.GetStr("LogServerCertVaultDirString", CoresConfig.LogServerApp.DefaultLogServerCertVaultDirString); string servicePortsStr = k.GetStr("LogServerPorts", CoresConfig.LogServerApp.DefaultLogServerPortsString); string httpPortsStr = k.GetStr("WebServerHttpPorts", CoresConfig.LogServerApp.DefaultHttpServerPortsString); string httpsPortsStr = k.GetStr("WebServerHttpsPorts", CoresConfig.LogServerApp.DefaultHttpsServerPortsString); string mustIncludeHostnameStr = k.GetStr("MustIncludeHostname", "*"); logDestDir = Lfs.ConfigPathStringToPhysicalDirectoryPath(logDestDir); certVaultDir = Lfs.ConfigPathStringToPhysicalDirectoryPath(certVaultDir); // Start Log Server this.CertVault = new CertVault(certVaultDir, new CertVaultSettings(EnsureSpecial.Yes) { ReloadIntervalMsecs = 3600 * 1000, UseAcme = false, NonAcmeEnableAutoGenerateSubjectNameCert = false, }); Lfs.CreateDirectory(logDestDir, FileFlags.OnCreateSetCompressionFlag); PalSslServerAuthenticationOptions sslOptions = new PalSslServerAuthenticationOptions(this.CertVault.X509CertificateSelector("dummy", true), true, null); this.LogServer = new LogServer(new LogServerOptions(null, logDestDir, FileFlags.AutoCreateDirectory | FileFlags.OnCreateSetCompressionFlag | FileFlags.LargeFs_AppendWithoutCrossBorder | FileFlags.LargeFs_AppendNewLineForCrossBorder, setDestinationProc: null, sslAuthOptions: sslOptions, tcpIp: LocalNet, ports: Str.ParsePortsList(servicePortsStr), rateLimiterConfigName: "LogServer" )); // Start HTTP Server-based Web log browser HttpServerOptions httpServerOptions = new HttpServerOptions { UseStaticFiles = false, UseSimpleBasicAuthentication = true, HttpPortsList = Str.ParsePortsList(httpPortsStr).ToList(), HttpsPortsList = Str.ParsePortsList(httpsPortsStr).ToList(), DebugKestrelToConsole = true, UseKestrelWithIPACoreStack = true, AutomaticRedirectToHttpsIfPossible = true, LocalHostOnly = false, }; if (mustIncludeHostnameStr._IsFilled() && mustIncludeHostnameStr._IsSamei("*") == false) { string[] tokens = mustIncludeHostnameStr.Split(new char[] { ' ', ' ', ';', '/', ',' }, StringSplitOptions.RemoveEmptyEntries); tokens._DoForEach(x => httpServerOptions.MustIncludeHostnameStrList.Add(x)); } LogBrowserOptions browserOptions = new LogBrowserOptions(logDestDir); this.LogBrowserHttpServer = LogBrowserHttpServerBuilder.StartServer(httpServerOptions, new LogBrowserHttpServerOptions(browserOptions, "")); }); } catch { this._DisposeSafe(); throw; } }