public void SetupLogBrowser(IServiceCollection services, LogBrowserOptions options) { if (this.EnabledFeatures.Bit(AspNetLibFeatures.LogBrowser) == false) { throw new ApplicationException(nameof(AspNetLibFeatures.LogBrowser) + " is not enabled."); } if (LogBrowser != null) { throw new ApplicationException("SetupLogBrowser is already called."); } LogBrowser = new LogBrowser(options, Consts.UrlPaths.LogBrowserMvcPath); services.AddSingleton(this.LogBrowser); }
public GitLabMainteDaemonApp() { try { // Settings を読み込む this.SettingsHive = new HiveData <GitLabMainteDaemonSettings>(Hive.SharedLocalConfigHive, $"GitLabMainteDaemon", null, HiveSyncPolicy.AutoReadFromFile); this.GitLabClient = new GitLabMainteClient(this.Settings.GitLabClientSettings); // TODO: ここでサーバーを立ち上げるなどの初期化処理を行なう this.MainLoop1Task = TaskUtil.StartAsyncTaskAsync(Loop1_MainteUsersAsync(this.GrandCancel)); this.MainLoop2Task = TaskUtil.StartAsyncTaskAsync(Loop2_MainteUsersAsync(this.GrandCancel)); // Log Browser を立ち上げる var logBrowserOptions = new LogBrowserOptions( this.Settings.GitWebDataRootDir, this.Settings.Title, flags: LogBrowserFlags.SecureJson | LogBrowserFlags.SecureJson_FlatDir | LogBrowserFlags.NoRootDirectory, extsAsMimeTypeUtf8: this.Settings.ExtsAsMimeTypeUtf8, logFileMaxSizePerDir: this.Settings.MaxAccessLogFileSizeInSpecificDir); this.LogBrowser = new LogBrowser(logBrowserOptions, "/d"); // HTTP サーバーを立ち上げる this.Cgi = new CgiHttpServer(new CgiHandler(this), new HttpServerOptions() { AutomaticRedirectToHttpsIfPossible = false, UseKestrelWithIPACoreStack = false, HttpPortsList = new int[] { 80 }.ToList(), HttpsPortsList = new int[] { 443 }.ToList(), UseStaticFiles = false, MaxRequestBodySize = 32 * 1024, ReadTimeoutMsecs = this.Settings.HttpTimeoutMsecs, DenyRobots = true, }, true); } catch { this._DisposeSafe(); throw; } }
public DataVaultLogBrowserHttpServerOptions(LogBrowserOptions options, string absolutePrefixPath, DataVaultServerApp app, DataVaultServer vault) : base(options, absolutePrefixPath) { this.App = app; this.Vault = vault; }
public DaemonUtil(string daemonName, CancellationToken cancel = default) : base(cancel) { if (daemonName._IsEmpty()) { throw new ArgumentNullException(nameof(daemonName)); } daemonName = daemonName._NonNullTrim(); try { // 起動パラメータ this.Params = new OneLineParams(GlobalDaemonStateManager.StartupArguments); if (Params._HasKey(Consts.DaemonArgKeys.StartLogFileBrowser)) { // Log Browser で利用されるべきポート番号の決定 int httpPort = Params._GetFirstValueOrDefault(Consts.DaemonArgKeys.LogFileBrowserPort, StrComparer.IgnoreCaseComparer)._ToInt(); if (httpPort == 0) { httpPort = Util.GenerateDynamicListenableTcpPortWithSeed(Env.DnsFqdnHostName + "_seed_daemonutil_logbrowser_http" + Env.AppRootDir + "@" + daemonName); } int httpsPort = Params._GetFirstValueOrDefault(Consts.DaemonArgKeys.LogFileBrowserPort, StrComparer.IgnoreCaseComparer)._ToInt(); if (httpsPort == 0) { httpsPort = Util.GenerateDynamicListenableTcpPortWithSeed(Env.DnsFqdnHostName + "_seed_daemonutil_logbrowser_https" + Env.AppRootDir + "@" + daemonName, excludePorts: httpPort._SingleArray()); } // Log Browser 用の CertVault の作成 CertVault certVault = new CertVault(PP.Combine(Env.AppLocalDir, "Config/DaemonUtil_LogBrowser/CertVault"), new CertVaultSettings(defaultSetting: EnsureSpecial.Yes) { UseAcme = false }); DisposeList.Add(certVault); // Log Browser の起動 HttpServerOptions httpServerOptions = new HttpServerOptions { UseStaticFiles = false, UseSimpleBasicAuthentication = false, HttpPortsList = httpPort._SingleList(), HttpsPortsList = httpsPort._SingleList(), DebugKestrelToConsole = false, UseKestrelWithIPACoreStack = true, AutomaticRedirectToHttpsIfPossible = false, LocalHostOnly = false, UseGlobalCertVault = false, // Disable Global CertVault DisableHiveBasedSetting = true, // Disable Hive based settings ServerCertSelector = certVault.X509CertificateSelectorForHttpsServerNoAcme, DenyRobots = true, // Deny robots }; LogBrowserOptions browserOptions = new LogBrowserOptions( Env.AppRootDir, systemTitle: $"{Env.DnsFqdnHostName}", zipEncryptPassword: GlobalDaemonStateManager.DaemonZipEncryptPassword, clientIpAcl: (ip) => { // 接続元 IP アドレスの種類を取得 IPAddressType type = ip._GetIPAddressType(); if (type.Bit(IPAddressType.GlobalIp)) { // 接続元がグローバル IP の場合 if (GlobalDaemonStateManager.IsDaemonClientLocalIpAddressGlobal == false) { // DaemonCenter との接続にプライベート IP を利用している場合: 接続拒否 return(false); } } // それ以外の場合: 接続許可 return(true); } ); DisposeList.Add(LogBrowserHttpServerBuilder.StartServer(httpServerOptions, new LogBrowserHttpServerOptions(browserOptions, "/" + GlobalDaemonStateManager.DaemonSecret))); GlobalDaemonStateManager.FileBrowserHttpsPortNumber = httpsPort; } } catch (Exception ex) { ex._Debug(); this._DisposeSafe(); throw; } }