/// <summary> /// Initializes a new instance of the <see cref="BasicWatchdog"/> <see langword="class"/>. /// </summary> /// <param name="chat">The <see cref="IChatManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionControllerFactory">The <see cref="ISessionControllerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="dmbFactory">The <see cref="IDmbFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="reattachInfoHandler">The <see cref="IReattachInfoHandler"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="autoStart">The autostart value for the <see cref="WatchdogBase"/>.</param> public BasicWatchdog( IChatManager chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, ILogger <BasicWatchdog> logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) : base( chat, sessionControllerFactory, dmbFactory, reattachInfoHandler, databaseContextFactory, jobManager, serverControl, asyncDelayer, logger, initialLaunchParameters, instance, autoStart) { }
/// <summary> /// Initializes a new instance of the <see cref="AdministrationController"/> class. /// </summary> /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/>.</param> /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/>.</param> /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/>.</param> /// <param name="serverControl">The value of <see cref="serverControl"/>.</param> /// <param name="serverUpdater">The value of <see cref="serverUpdater"/>.</param> /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param> /// <param name="ioManager">The value of <see cref="ioManager"/>.</param> /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param> /// <param name="fileTransferService">The value of <see cref="fileTransferService"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/>.</param> /// <param name="updatesConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="updatesConfiguration"/>.</param> /// <param name="fileLoggingConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="fileLoggingConfiguration"/>.</param> public AdministrationController( IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, IGitHubClientFactory gitHubClientFactory, IServerControl serverControl, IServerUpdateInitiator serverUpdater, IAssemblyInformationProvider assemblyInformationProvider, IIOManager ioManager, IPlatformIdentifier platformIdentifier, IFileTransferTicketProvider fileTransferService, ILogger <AdministrationController> logger, IOptions <UpdatesConfiguration> updatesConfigurationOptions, IOptions <FileLoggingConfiguration> fileLoggingConfigurationOptions) : base( databaseContext, authenticationContextFactory, logger, true) { this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.serverUpdater = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater)); this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); this.fileTransferService = fileTransferService ?? throw new ArgumentNullException(nameof(fileTransferService)); updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions)); fileLoggingConfiguration = fileLoggingConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(fileLoggingConfigurationOptions)); }
/// <summary> /// Initializes a new instance of the <see cref="BasicWatchdog"/> <see langword="class"/>. /// </summary> /// <param name="chat">The <see cref="IChatManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionControllerFactory">The <see cref="ISessionControllerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="dmbFactory">The <see cref="IDmbFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionPersistor">The <see cref="ISessionPersistor"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="diagnosticsIOManager">The <see cref="IIOManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="remoteDeploymentManagerFactory">The <see cref="IRemoteDeploymentManagerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="autoStart">The autostart value for the <see cref="WatchdogBase"/>.</param> public BasicWatchdog( IChatManager chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, ISessionPersistor sessionPersistor, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, IIOManager diagnosticsIOManager, IEventConsumer eventConsumer, IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory, ILogger <BasicWatchdog> logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) : base( chat, sessionControllerFactory, dmbFactory, sessionPersistor, jobManager, serverControl, asyncDelayer, diagnosticsIOManager, eventConsumer, remoteDeploymentManagerFactory, logger, initialLaunchParameters, instance, autoStart) { }
public LogService(IServerControl serverCtrl) { _serverCtrl = serverCtrl; _subscribers = new Dictionary <string, ILogCallback>(); }
/// <summary> /// Construct a <see cref="ChatManagerFactory"/> /// </summary> /// <param name="providerFactory">The value of <see cref="providerFactory"/></param> /// <param name="serverControl">The value of <see cref="serverControl"/></param> /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/></param> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> public ChatManagerFactory(IProviderFactory providerFactory, IServerControl serverControl, IAsyncDelayer asyncDelayer, ILoggerFactory loggerFactory) { this.providerFactory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); }
/// <summary> /// Construct an <see cref="AdministrationController"/> /// </summary> /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param> /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param> /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/></param> /// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param> /// <param name="application">The value of <see cref="application"/></param> /// <param name="ioManager">The value of <see cref="ioManager"/></param> /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/></param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param> /// <param name="updatesConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="updatesConfiguration"/></param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="generalConfiguration"/></param> public AdministrationController( IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, IGitHubClientFactory gitHubClientFactory, IServerControl serverUpdater, IApplication application, IIOManager ioManager, IPlatformIdentifier platformIdentifier, ILogger <AdministrationController> logger, IOptions <UpdatesConfiguration> updatesConfigurationOptions, IOptions <GeneralConfiguration> generalConfigurationOptions) : base( databaseContext, authenticationContextFactory, logger, false, true) { this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); this.serverUpdater = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater)); this.application = application ?? throw new ArgumentNullException(nameof(application)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); }
/// <summary> /// Construct an <see cref="InstanceManager"/> /// </summary> /// <param name="instanceFactory">The value of <see cref="instanceFactory"/></param> /// <param name="ioManager">The value of <paramref name="ioManager"/></param> /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/></param> /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param> /// <param name="jobManager">The value of <see cref="jobManager"/></param> /// <param name="serverControl">The value of <see cref="serverControl"/></param> /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/>.</param> /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param> /// <param name="logger">The value of <see cref="logger"/></param> public InstanceManager( IInstanceFactory instanceFactory, IIOManager ioManager, IDatabaseContextFactory databaseContextFactory, IAssemblyInformationProvider assemblyInformationProvider, IJobManager jobManager, IServerControl serverControl, ISystemIdentityFactory systemIdentityFactory, IAsyncDelayer asyncDelayer, IOptions <GeneralConfiguration> generalConfigurationOptions, ILogger <InstanceManager> logger) { this.instanceFactory = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.systemIdentityFactory = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory)); this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); serverControl.RegisterForRestart(this); instances = new Dictionary <long, IInstance>(); bridgeHandlers = new Dictionary <string, IBridgeHandler>(); readyTcs = new TaskCompletionSource <object>(); }
/// <summary> /// Construct a <see cref="HomeController"/> /// </summary> /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param> /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param> /// <param name="tokenFactory">The value of <see cref="tokenFactory"/></param> /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/></param> /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/></param> /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param> /// <param name="identityCache">The value of <see cref="identityCache"/></param> /// <param name="oAuthProviders">The value of <see cref="oAuthProviders"/>.</param> /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param> /// <param name="browserResolver">The value of <see cref="browserResolver"/></param> /// <param name="swarmService">The value of <see cref="swarmService"/>.</param> /// <param name="serverControl">The value of <see cref="serverControl"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param> /// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="controlPanelConfiguration"/></param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param> public HomeController( IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, ITokenFactory tokenFactory, ISystemIdentityFactory systemIdentityFactory, ICryptographySuite cryptographySuite, IAssemblyInformationProvider assemblyInformationProvider, IIdentityCache identityCache, IOAuthProviders oAuthProviders, IPlatformIdentifier platformIdentifier, IBrowserResolver browserResolver, ISwarmService swarmService, IServerControl serverControl, IOptions <GeneralConfiguration> generalConfigurationOptions, IOptions <ControlPanelConfiguration> controlPanelConfigurationOptions, ILogger <HomeController> logger) : base( databaseContext, authenticationContextFactory, logger, false) { this.tokenFactory = tokenFactory ?? throw new ArgumentNullException(nameof(tokenFactory)); this.systemIdentityFactory = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory)); this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite)); this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); this.identityCache = identityCache ?? throw new ArgumentNullException(nameof(identityCache)); this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); this.oAuthProviders = oAuthProviders ?? throw new ArgumentNullException(nameof(oAuthProviders)); this.browserResolver = browserResolver ?? throw new ArgumentNullException(nameof(browserResolver)); this.swarmService = swarmService ?? throw new ArgumentNullException(nameof(swarmService)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); }
/// <summary> /// Initializes a new instance of the <see cref="InstanceManager"/> class. /// </summary> /// <param name="instanceFactory">The value of <see cref="instanceFactory"/>.</param> /// <param name="ioManager">The value of <paramref name="ioManager"/>.</param> /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/>.</param> /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param> /// <param name="jobManager">The value of <see cref="jobManager"/>.</param> /// <param name="serverControl">The value of <see cref="serverControl"/>.</param> /// <param name="systemIdentityFactory">The value of <see cref="systemIdentityFactory"/>.</param> /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/>.</param> /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param> /// <param name="swarmService">The value of <see cref="swarmService"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param> /// <param name="swarmConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="swarmConfiguration"/>.</param> /// <param name="logger">The value of <see cref="logger"/>.</param> public InstanceManager( IInstanceFactory instanceFactory, IIOManager ioManager, IDatabaseContextFactory databaseContextFactory, IAssemblyInformationProvider assemblyInformationProvider, IJobManager jobManager, IServerControl serverControl, ISystemIdentityFactory systemIdentityFactory, IAsyncDelayer asyncDelayer, IServerPortProvider serverPortProvider, ISwarmService swarmService, IOptions <GeneralConfiguration> generalConfigurationOptions, IOptions <SwarmConfiguration> swarmConfigurationOptions, ILogger <InstanceManager> logger) { this.instanceFactory = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.systemIdentityFactory = systemIdentityFactory ?? throw new ArgumentNullException(nameof(systemIdentityFactory)); this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); this.serverPortProvider = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider)); this.swarmService = swarmService ?? throw new ArgumentNullException(nameof(swarmService)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); swarmConfiguration = swarmConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(swarmConfigurationOptions)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); instances = new Dictionary <long, InstanceContainer>(); bridgeHandlers = new Dictionary <string, IBridgeHandler>(); readyTcs = new TaskCompletionSource <object>(); instanceStateChangeSemaphore = new SemaphoreSlim(1); }
/// <summary> /// Construct a <see cref="WatchdogFactory"/> /// </summary> /// <param name="serverControl">The value of <see cref="serverControl"/></param> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="byondTopicSender"/></param> /// <param name="jobManager">The value of <see cref="jobManager"/></param> public WatchdogFactory(IServerControl serverControl, ILoggerFactory loggerFactory, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IJobManager jobManager) { this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); }
/// <summary> /// Construct an <see cref="AdministrationController"/> /// </summary> /// <param name="databaseContext">The <see cref="IDatabaseContext"/> for the <see cref="ApiController"/></param> /// <param name="authenticationContextFactory">The <see cref="IAuthenticationContextFactory"/> for the <see cref="ApiController"/></param> /// <param name="gitHubClient">The value of <see cref="gitHubClient"/></param> /// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param> /// <param name="application">The value of <see cref="application"/></param> /// <param name="ioManager">The value of <see cref="ioManager"/></param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param> /// <param name="updatesConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing value of <see cref="updatesConfiguration"/></param> public AdministrationController(IDatabaseContext databaseContext, IAuthenticationContextFactory authenticationContextFactory, IGitHubClient gitHubClient, IServerControl serverUpdater, IApplication application, IIOManager ioManager, ILogger <AdministrationController> logger, IOptions <UpdatesConfiguration> updatesConfigurationOptions) : base(databaseContext, authenticationContextFactory, logger, false) { this.gitHubClient = gitHubClient ?? throw new ArgumentNullException(nameof(gitHubClient)); this.serverUpdater = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater)); this.application = application ?? throw new ArgumentNullException(nameof(application)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions)); }
/// <summary> /// Construct a <see cref="WatchdogFactory"/> /// </summary> /// <param name="serverControl">The value of <see cref="ServerControl"/></param> /// <param name="loggerFactory">The value of <see cref="LoggerFactory"/></param> /// <param name="databaseContextFactory">The value of <see cref="DatabaseContextFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="ByondTopicSender"/></param> /// <param name="jobManager">The value of <see cref="JobManager"/></param> /// <param name="asyncDelayer">The value of <see cref="AsyncDelayer"/></param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="GeneralConfiguration"/></param> public WatchdogFactory(IServerControl serverControl, ILoggerFactory loggerFactory, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IJobManager jobManager, IAsyncDelayer asyncDelayer, IOptions <GeneralConfiguration> generalConfigurationOptions) { ServerControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); DatabaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); ByondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); JobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); }
/// <summary> /// Construct a <see cref="WatchdogFactory"/> /// </summary> /// <param name="chat">The value of <see cref="chat"/></param> /// <param name="sessionControllerFactory">The value of <see cref="sessionControllerFactory"/></param> /// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> /// <param name="reattachInfoHandler">The value of <see cref="reattachInfoHandler"/></param> /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="byondTopicSender"/></param> /// <param name="eventConsumer">The value of <see cref="eventConsumer"/></param> /// <param name="instance">The value of <see cref="instance"/></param> public WatchdogFactory(IChat chat, ISessionControllerFactory sessionControllerFactory, IServerControl serverUpdater, ILoggerFactory loggerFactory, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IEventConsumer eventConsumer, Api.Models.Instance instance) { this.chat = chat ?? throw new ArgumentNullException(nameof(chat)); this.sessionControllerFactory = sessionControllerFactory ?? throw new ArgumentNullException(nameof(sessionControllerFactory)); this.serverUpdater = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater)); this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); this.reattachInfoHandler = reattachInfoHandler ?? throw new ArgumentNullException(nameof(reattachInfoHandler)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer)); this.instance = instance ?? throw new ArgumentNullException(nameof(instance)); }
/// <summary> /// Configure the <see cref="Application"/> /// </summary> /// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/> to configure</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="Application"/></param> /// <param name="tokenFactory">The value of <see cref="tokenFactory"/></param> /// <param name="logger">The <see cref="Microsoft.Extensions.Logging.ILogger"/> for the <see cref="Application"/></param> public void Configure(IApplicationBuilder applicationBuilder, IServerControl serverControl, ITokenFactory tokenFactory, ILogger <Application> logger) { if (applicationBuilder == null) { throw new ArgumentNullException(nameof(applicationBuilder)); } if (serverControl == null) { throw new ArgumentNullException(nameof(serverControl)); } this.tokenFactory = tokenFactory ?? throw new ArgumentNullException(nameof(tokenFactory)); if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.LogInformation(VersionString); //attempt to restart the server if the configuration changes if (serverControl.WatchdogPresent) { ChangeToken.OnChange(configuration.GetReloadToken, () => serverControl.Restart()); } //now setup the HTTP request pipeline //should anything after this throw an exception, catch it and display a detailed html page applicationBuilder.UseDeveloperExceptionPage(); //it is not worth it to limit this, you should only ever get it if you're an authorized user //suppress OperationCancelledExceptions, they are just aborted HTTP requests applicationBuilder.UseCancelledRequestSuppression(); //Do not service requests until Ready is called, this will return 503 until that point applicationBuilder.UseAsyncInitialization(async cancellationToken => { using (cancellationToken.Register(() => startupTcs.SetCanceled())) await startupTcs.Task.ConfigureAwait(false); }); //authenticate JWT tokens using our security pipeline if present, returns 401 if bad applicationBuilder.UseAuthentication(); //suppress and log database exceptions applicationBuilder.UseDbConflictHandling(); //majority of handling is done in the controllers applicationBuilder.UseMvc(); //404 anything that gets this far }
/// <summary> /// Initializes a new instance of the <see cref="WatchdogBase"/> <see langword="class"/>. /// </summary> /// <param name="chat">The value of <see cref="Chat"/></param> /// <param name="sessionControllerFactory">The value of <see cref="SessionControllerFactory"/></param> /// <param name="dmbFactory">The value of <see cref="DmbFactory"/></param> /// <param name="reattachInfoHandler">The value of <see cref="reattachInfoHandler"/></param> /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="byondTopicSender"/></param> /// <param name="eventConsumer">The value of <see cref="eventConsumer"/></param> /// <param name="jobManager">The value of <see cref="jobManager"/></param> /// <param name="serverControl">The <see cref="IServerControl"/> to populate <see cref="restartRegistration"/> with</param> /// <param name="asyncDelayer">The value of <see cref="AsyncDelayer"/>.</param> /// <param name="logger">The value of <see cref="Logger"/></param> /// <param name="initialLaunchParameters">The initial value of <see cref="ActiveLaunchParameters"/>. May be modified</param> /// <param name="instance">The value of <see cref="instance"/></param> /// <param name="autoStart">The value of <see cref="autoStart"/></param> protected WatchdogBase( IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IEventConsumer eventConsumer, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, ILogger logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) { Chat = chat ?? throw new ArgumentNullException(nameof(chat)); SessionControllerFactory = sessionControllerFactory ?? throw new ArgumentNullException(nameof(sessionControllerFactory)); DmbFactory = dmbFactory ?? throw new ArgumentNullException(nameof(dmbFactory)); AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); this.reattachInfoHandler = reattachInfoHandler ?? throw new ArgumentNullException(nameof(reattachInfoHandler)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ActiveLaunchParameters = initialLaunchParameters ?? throw new ArgumentNullException(nameof(initialLaunchParameters)); this.instance = instance ?? throw new ArgumentNullException(nameof(instance)); this.autoStart = autoStart; if (serverControl == null) { throw new ArgumentNullException(nameof(serverControl)); } chat.RegisterCommandHandler(this); ActiveLaunchParameters = initialLaunchParameters; releaseServers = false; ActiveParametersUpdated = new TaskCompletionSource <object>(); restartRegistration = serverControl.RegisterForRestart(this); try { Semaphore = new SemaphoreSlim(1); } catch { restartRegistration.Dispose(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="ServerUpdateInitiator"/> class. /// </summary> /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/>.</param> /// <param name="ioManager">The value of <see cref="ioManager"/>.</param> /// <param name="serverControl">The value of <see cref="serverControl"/>.</param> /// <param name="logger">The value of <see cref="logger"/>.</param> /// <param name="updatesConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="updatesConfiguration"/>.</param> public ServerUpdateInitiator( IGitHubClientFactory gitHubClientFactory, IIOManager ioManager, IServerControl serverControl, ILogger <ServerUpdateInitiator> logger, IOptions <UpdatesConfiguration> updatesConfigurationOptions) { this.gitHubClientFactory = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); updatesConfiguration = updatesConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(updatesConfigurationOptions)); }
/// <summary> /// Construct an <see cref="InstanceManager"/> /// </summary> /// <param name="instanceFactory">The value of <see cref="instanceFactory"/></param> /// <param name="ioManager">The value of <paramref name="ioManager"/></param> /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/></param> /// <param name="application">The value of <see cref="application"/></param> /// <param name="jobManager">The value of <see cref="jobManager"/></param> /// <param name="serverControl">The value of <see cref="serverControl"/></param> /// <param name="logger">The value of <see cref="logger"/></param> public InstanceManager(IInstanceFactory instanceFactory, IIOManager ioManager, IDatabaseContextFactory databaseContextFactory, IApplication application, IJobManager jobManager, IServerControl serverControl, ILogger <InstanceManager> logger) { this.instanceFactory = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.application = application ?? throw new ArgumentNullException(nameof(application)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); serverControl.RegisterForRestart(this); instances = new Dictionary <long, IInstance>(); }
private void AddControlToMenu(IServerControl control) { int imageKey = 0; if (control.MenuIcon != null) { _menu.ImageList.Images.Add(control.MenuIcon); imageKey = _menu.ImageList.Images.Count - 1; } TreeNode node = new TreeNode(control.MenuText, imageKey, imageKey); node.Tag = control; _menu.Nodes.Add(node); }
/// <summary> /// Construct an <see cref="InstanceFactory"/> /// </summary> /// <param name="ioManager">The value of <see cref="ioManager"/></param> /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param> /// <param name="application">The value of <see cref="application"/></param> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="byondTopicSender"/></param> /// <param name="serverUpdater">The value of <see cref="serverUpdater"/></param> /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/></param> /// <param name="synchronousIOManager">The value of <see cref="synchronousIOManager"/></param> /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/></param> /// <param name="byondInstaller">The value of <see cref="byondInstaller"/></param> /// <param name="providerFactory">The value of <see cref="providerFactory"/></param> /// <param name="processExecutor">The value of <see cref="processExecutor"/></param> /// <param name="postWriteHandler">The value of <see cref="postWriteHandler"/></param> public InstanceFactory(IIOManager ioManager, IDatabaseContextFactory databaseContextFactory, IApplication application, ILoggerFactory loggerFactory, IByondTopicSender byondTopicSender, IServerControl serverUpdater, ICryptographySuite cryptographySuite, ISynchronousIOManager synchronousIOManager, ISymlinkFactory symlinkFactory, IByondInstaller byondInstaller, IProviderFactory providerFactory, IProcessExecutor processExecutor, IPostWriteHandler postWriteHandler) { this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.application = application ?? throw new ArgumentNullException(nameof(application)); this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.serverUpdater = serverUpdater ?? throw new ArgumentNullException(nameof(serverUpdater)); this.cryptographySuite = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite)); this.synchronousIOManager = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager)); this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); this.byondInstaller = byondInstaller ?? throw new ArgumentNullException(nameof(byondInstaller)); this.providerFactory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory)); this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor)); this.postWriteHandler = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="WindowsWatchdogFactory"/> class. /// </summary> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="symlinkFactory">The value of <see cref="SymlinkFactory"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param> public WindowsWatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IJobManager jobManager, IAsyncDelayer asyncDelayer, ISymlinkFactory symlinkFactory, IOptions <GeneralConfiguration> generalConfigurationOptions) : base( serverControl, loggerFactory, jobManager, asyncDelayer, generalConfigurationOptions) { SymlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); }
/// <summary> /// Initializes a new instance of the <see cref="PosixWatchdogFactory"/> class. /// </summary> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="symlinkFactory">The <see cref="ISymlinkFactory"/> for the <see cref="WindowsWatchdogFactory"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param> public PosixWatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IJobManager jobManager, IAsyncDelayer asyncDelayer, ISymlinkFactory symlinkFactory, IOptions <GeneralConfiguration> generalConfigurationOptions) : base( serverControl, loggerFactory, jobManager, asyncDelayer, symlinkFactory, generalConfigurationOptions) { }
/// <summary> /// Initializes a new instance of the <see cref="WindowsWatchdog"/> class. /// </summary> /// <param name="chat">The <see cref="IChatManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionControllerFactory">The <see cref="ISessionControllerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="dmbFactory">The <see cref="IDmbFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionPersistor">The <see cref="ISessionPersistor"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="diagnosticsIOManager">The <see cref="IIOManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="remoteDeploymentManagerFactory">The <see cref="IRemoteDeploymentManagerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="gameIOManager">The value of <see cref="GameIOManager"/>.</param> /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="autoStart">The autostart value for the <see cref="WatchdogBase"/>.</param> public WindowsWatchdog( IChatManager chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, ISessionPersistor sessionPersistor, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, IIOManager diagnosticsIOManager, IEventConsumer eventConsumer, IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory, IIOManager gameIOManager, ISymlinkFactory symlinkFactory, ILogger <WindowsWatchdog> logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) : base( chat, sessionControllerFactory, dmbFactory, sessionPersistor, jobManager, serverControl, asyncDelayer, diagnosticsIOManager, eventConsumer, remoteDeploymentManagerFactory, logger, initialLaunchParameters, instance, autoStart) { try { GameIOManager = gameIOManager ?? throw new ArgumentNullException(nameof(gameIOManager)); this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); } catch { _ = DisposeAsync(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="WindowsWatchdog"/> <see langword="class"/>. /// </summary> /// <param name="chat">The <see cref="IChat"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionControllerFactory">The <see cref="ISessionControllerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="dmbFactory">The <see cref="IDmbFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="reattachInfoHandler">The <see cref="IReattachInfoHandler"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="byondTopicSender">The <see cref="IByondTopicSender"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="ioManager">The value of <see cref="ioManager"/>.</param> /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="autoStart">The autostart value for the <see cref="WatchdogBase"/>.</param> public WindowsWatchdog( IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IEventConsumer eventConsumer, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, IIOManager ioManager, ISymlinkFactory symlinkFactory, ILogger <WindowsWatchdog> logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) : base( chat, sessionControllerFactory, dmbFactory, reattachInfoHandler, databaseContextFactory, byondTopicSender, eventConsumer, jobManager, serverControl, asyncDelayer, logger, initialLaunchParameters, instance, autoStart) { try { this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); } catch { Dispose(); throw; } }
/// <summary> /// Initializes a new instance of the <see cref="WindowsWatchdogFactory"/> <see langword="class"/>. /// </summary> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="byondTopicSender">The <see cref="IByondTopicSender"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogFactory"/>.</param> /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param> /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> for <see cref="GeneralConfiguration"/> for the <see cref="WatchdogFactory"/>.</param> public WindowsWatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IJobManager jobManager, IAsyncDelayer asyncDelayer, ISymlinkFactory symlinkFactory, IOptions <GeneralConfiguration> generalConfigurationOptions) : base( serverControl, loggerFactory, databaseContextFactory, byondTopicSender, jobManager, asyncDelayer, generalConfigurationOptions) { this.symlinkFactory = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory)); }
/// <summary> /// Construct a <see cref="ChatManager"/> /// </summary> /// <param name="providerFactory">The value of <see cref="providerFactory"/></param> /// <param name="ioManager">The value of <see cref="ioManager"/></param> /// <param name="commandFactory">The value of <see cref="commandFactory"/></param> /// <param name="serverControl">The <see cref="IServerControl"/> to populate <see cref="restartRegistration"/> with</param> /// <param name="asyncDelayer">The value of <see cref="asyncDelayer"/></param> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> /// <param name="logger">The value of <see cref="logger"/></param> /// <param name="initialChatBots">The <see cref="IEnumerable{T}"/> used to populate <see cref="activeChatBots"/></param> public ChatManager(IProviderFactory providerFactory, IIOManager ioManager, ICommandFactory commandFactory, IServerControl serverControl, IAsyncDelayer asyncDelayer, ILoggerFactory loggerFactory, ILogger <ChatManager> logger, IEnumerable <Models.ChatBot> initialChatBots) { this.providerFactory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.commandFactory = commandFactory ?? throw new ArgumentNullException(nameof(commandFactory)); if (serverControl == null) { throw new ArgumentNullException(nameof(serverControl)); } this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); activeChatBots = initialChatBots?.ToList() ?? throw new ArgumentNullException(nameof(initialChatBots)); restartRegistration = serverControl.RegisterForRestart(this); synchronizationLock = new object(); builtinCommands = new Dictionary <string, ICommand>(); providers = new Dictionary <long, IProvider>(); mappedChannels = new Dictionary <ulong, ChannelMapping>(); trackingContexts = new List <IChatTrackingContext>(); handlerCts = new CancellationTokenSource(); connectionsUpdated = new TaskCompletionSource <object>(); channelIdCounter = 1; }
/// <summary> /// Initializes a new instance of the <see cref="ExperimentalWatchdog"/> <see langword="class"/>. /// </summary> /// <param name="chat">The <see cref="IChat"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="sessionControllerFactory">The <see cref="ISessionControllerFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="dmbFactory">The <see cref="IDmbFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="reattachInfoHandler">The <see cref="IReattachInfoHandler"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="databaseContextFactory">The <see cref="IDatabaseContextFactory"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="byondTopicSender">The <see cref="IByondTopicSender"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="eventConsumer">The <see cref="IEventConsumer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="asyncDelayer">The <see cref="IAsyncDelayer"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="initialLaunchParameters">The <see cref="DreamDaemonLaunchParameters"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="instance">The <see cref="Api.Models.Instance"/> for the <see cref="WatchdogBase"/>.</param> /// <param name="autoStart">The autostart value for the <see cref="WatchdogBase"/>.</param> public ExperimentalWatchdog(IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IEventConsumer eventConsumer, IJobManager jobManager, IServerControl serverControl, IAsyncDelayer asyncDelayer, ILogger <ExperimentalWatchdog> logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) : base( chat, sessionControllerFactory, dmbFactory, reattachInfoHandler, databaseContextFactory, byondTopicSender, eventConsumer, jobManager, serverControl, asyncDelayer, logger, initialLaunchParameters, instance, autoStart) { alphaIsActive = true; }
public TextInterfaceModule(IServerControl control, IServerInfo info) : base("Text Interface", "Text Interface") { Data.Control = control; Data.Info = info; }
/// <summary> /// Construct an <see cref="InstanceManager"/> /// </summary> /// <param name="instanceFactory">The value of <see cref="instanceFactory"/></param> /// <param name="ioManager">The value of <paramref name="ioManager"/></param> /// <param name="databaseContextFactory">The value of <paramref name="databaseContextFactory"/></param> /// <param name="application">The value of <see cref="application"/></param> /// <param name="jobManager">The value of <see cref="jobManager"/></param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="InstanceManager"/></param> /// <param name="logger">The value of <see cref="logger"/></param> public InstanceManager(IInstanceFactory instanceFactory, IIOManager ioManager, IDatabaseContextFactory databaseContextFactory, IApplication application, IJobManager jobManager, IServerControl serverControl, ILogger <InstanceManager> logger) { this.instanceFactory = instanceFactory ?? throw new ArgumentNullException(nameof(instanceFactory)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.application = application ?? throw new ArgumentNullException(nameof(application)); this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); if (serverControl == null) { throw new ArgumentNullException(nameof(serverControl)); } shutdownCancellationTokenSource = new CancellationTokenSource(); var cancellationToken = shutdownCancellationTokenSource.Token; serverControl.RegisterForRestart(() => { lock (this) shutdownTasks.AddRange(instances.Select(x => x.Value.Chat.SendBroadcast("TGS: Restart requested...", cancellationToken))); }); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); instances = new Dictionary <long, IInstance>(); shutdownTasks = new List <Task>(); }
/// <summary> /// Configure the <see cref="Application"/> /// </summary> /// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/> to configure</param> /// <param name="serverControl">The <see cref="IServerControl"/> for the <see cref="Application"/></param> /// <param name="tokenFactory">The value of <see cref="tokenFactory"/></param> /// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the <see cref="ControlPanelConfiguration"/> to use</param> /// <param name="logger">The <see cref="Microsoft.Extensions.Logging.ILogger"/> for the <see cref="Application"/></param> public void Configure(IApplicationBuilder applicationBuilder, IServerControl serverControl, ITokenFactory tokenFactory, IOptions <ControlPanelConfiguration> controlPanelConfigurationOptions, ILogger <Application> logger) { if (applicationBuilder == null) { throw new ArgumentNullException(nameof(applicationBuilder)); } if (serverControl == null) { throw new ArgumentNullException(nameof(serverControl)); } this.tokenFactory = tokenFactory ?? throw new ArgumentNullException(nameof(tokenFactory)); var controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.LogInformation(VersionString); logger.LogDebug("Content Root: {0}", hostingEnvironment.ContentRootPath); logger.LogTrace("Web Root: {0}", hostingEnvironment.WebRootPath); // attempt to restart the server if the configuration changes if (serverControl.WatchdogPresent) { ChangeToken.OnChange(configuration.GetReloadToken, () => serverControl.Restart()); } // setup the HTTP request pipeline // Final point where we wrap exceptions in a 500 (ErrorMessage) response applicationBuilder.UseServerErrorHandling(); // should anything after this throw an exception, catch it and display a detailed html page if (hostingEnvironment.IsDevelopment()) { applicationBuilder.UseDeveloperExceptionPage(); // it is not worth it to limit this, you should only ever get it if you're an authorized user } // suppress OperationCancelledExceptions, they are just aborted HTTP requests applicationBuilder.UseCancelledRequestSuppression(); if (hostingEnvironment.IsDevelopment()) { applicationBuilder.UseSwagger(); applicationBuilder.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TGS API V4")); } // Set up CORS based on configuration if necessary Action <CorsPolicyBuilder> corsBuilder = null; if (controlPanelConfiguration.AllowAnyOrigin) { logger.LogTrace("Access-Control-Allow-Origin: *"); corsBuilder = builder => builder.AllowAnyOrigin(); } else if (controlPanelConfiguration.AllowedOrigins?.Count > 0) { logger.LogTrace("Access-Control-Allow-Origin: ", String.Join(',', controlPanelConfiguration.AllowedOrigins)); corsBuilder = builder => builder.WithOrigins(controlPanelConfiguration.AllowedOrigins.ToArray()); } var originalBuilder = corsBuilder; corsBuilder = builder => { builder.AllowAnyHeader().AllowAnyMethod(); originalBuilder?.Invoke(builder); }; applicationBuilder.UseCors(corsBuilder); // Do not service requests until Ready is called, this will return 503 until that point applicationBuilder.UseAsyncInitialization(async cancellationToken => { using (cancellationToken.Register(() => startupTcs.SetCanceled())) await startupTcs.Task.ConfigureAwait(false); }); // spa loading if necessary if (controlPanelConfiguration.Enable) { logger.LogWarning("Web control panel enabled. This is a highly WIP feature!"); applicationBuilder.UseStaticFiles(); } else { logger.LogDebug("Web control panel disabled!"); } // authenticate JWT tokens using our security pipeline if present, returns 401 if bad applicationBuilder.UseAuthentication(); // suppress and log database exceptions applicationBuilder.UseDbConflictHandling(); // majority of handling is done in the controllers applicationBuilder.UseMvc(); // 404 anything that gets this far }
/// <summary> /// Construct a <see cref="IWatchdog"/> /// </summary> /// <param name="chat">The value of <see cref="chat"/></param> /// <param name="sessionControllerFactory">The value of <see cref="sessionControllerFactory"/></param> /// <param name="dmbFactory">The value of <see cref="dmbFactory"/></param> /// <param name="serverUpdater">The <see cref="IServerControl"/> for the <see cref="Watchdog"/></param> /// <param name="logger">The value of <see cref="logger"/></param> /// <param name="reattachInfoHandler">The value of <see cref="reattachInfoHandler"/></param> /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param> /// <param name="byondTopicSender">The value of <see cref="byondTopicSender"/></param> /// <param name="initialLaunchParameters">The initial value of <see cref="ActiveLaunchParameters"/></param> /// <param name="instance">The value of <see cref="instance"/></param> /// <param name="autoStart">The value of <see cref="autoStart"/></param> /// <param name="eventConsumer">The value of <see cref="eventConsumer"/></param> public Watchdog(IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IServerControl serverUpdater, ILogger <Watchdog> logger, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, IByondTopicSender byondTopicSender, IEventConsumer eventConsumer, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, bool autoStart) { this.chat = chat ?? throw new ArgumentNullException(nameof(chat)); this.sessionControllerFactory = sessionControllerFactory ?? throw new ArgumentNullException(nameof(sessionControllerFactory)); this.dmbFactory = dmbFactory ?? throw new ArgumentNullException(nameof(dmbFactory)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.reattachInfoHandler = reattachInfoHandler ?? throw new ArgumentNullException(nameof(reattachInfoHandler)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.eventConsumer = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer)); this.instance = instance ?? throw new ArgumentNullException(nameof(instance)); this.autoStart = autoStart; if (serverUpdater == null) { throw new ArgumentNullException(nameof(serverUpdater)); } serverUpdater.RegisterForRestart(() => releaseServers = true); chat.RegisterCommandHandler(this); AlphaIsActive = true; ActiveLaunchParameters = initialLaunchParameters; releaseServers = false; semaphore = new SemaphoreSlim(1); activeParametersUpdated = new TaskCompletionSource <object>(); }
/// <summary> /// Construct a <see cref="ChatFactory"/> /// </summary> /// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param> /// <param name="providerFactory">The value of <see cref="providerFactory"/></param> /// <param name="serverControl">The value of <see cref="serverControl"/></param> public ChatFactory(ILoggerFactory loggerFactory, IProviderFactory providerFactory, IServerControl serverControl) { this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); this.providerFactory = providerFactory ?? throw new ArgumentNullException(nameof(providerFactory)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); }