Пример #1
0
 /// <summary>
 /// Updates <see cref="CurrentSettings"/>, making changes to other services (like forwarding ports) as necessary.
 /// </summary>
 /// <param name="newSettings">The settings to apply.</param>
 public void ChangeSettings(IMSSettings newSettings)
 {
     lock (CurrentSettings)
     {
         if (CurrentSettings.ManagementPort.AttemptUPnPForwarding)
         {
             PortManager.RemovePort(CurrentSettings.ManagementPort.Port);
         }
         if (newSettings.ManagementPort.AttemptUPnPForwarding)
         {
             PortManager.ForwardPort(newSettings.ManagementPort.Port);
         }
         if (CurrentSettings.ManagementPort.Port != newSettings.ManagementPort.Port)
         {
             WebServer.Stop();
             WebServer.Port = newSettings.ManagementPort;
             WebServer.Start();
         }
         if (CurrentSettings.RunIMSOnStartup != newSettings.RunIMSOnStartup)
         {
             if (newSettings.RunIMSOnStartup)
             {
                 Process.Start("cmd.exe", "/C sc config IMS start=auto");
             }
             else
             {
                 Process.Start("cmd.exe", "/C sc config IMS start=demand");
             }
         }
         CurrentSettings = newSettings;
         CurrentSettings.SaveConfiguration();
     }
 }
Пример #2
0
        private void Execute()
        {
            Logger.WriteInfo("Starting IMS...");

            CurrentSettings = new IMSSettings().FromConfiguration();
            Logger.WriteInfo("IMS settings configuration loaded.");
            Logger.WriteInfo("Attempting to find suitable UPnP router for port forwarding...");

            UserMessageManager = new InformationController().FromConfiguration();

            PluginManager = new PluginController().FromConfiguration();
            PluginManager.Initialize();

            FirewallManager = new FirewallController();
            FirewallManager.CreateFirewallExecutableException("MainService", Constants.ExecutionPath + "/IMS-Service.exe");

            PortManager = new PortForwarder();
            PortManager.Start();

            UpdateManager = new UpdateController();
            UpdateManager.Start();

            VersionManager = new MinecraftVersionProvider().FromConfiguration();
            VersionManager.Start();

            WorldManager = new WorldController();
            WorldManager.Start();

            ServerManager = new ServerController();
            ServerManager.Start();

            WebServer.Port = CurrentSettings.ManagementPort;
            WebServer.Start();

            PluginManager.Start();
            if (!string.IsNullOrEmpty(DevelopmentPluginPath))
            {
                try
                {
                    if (PluginManager.LoadedPlugins.Where(x => Path.GetFullPath(x.Value.PluginAssembly.Location) == Path.GetFullPath(DevelopmentPluginPath)).Count() == 0)
                    {
                        PluginManager.LoadPlugin(DevelopmentPluginPath);
                    }
                }
                catch (Exception e)
                {
                    UserMessageManager.LogError("Couldn't load development plugin!  See the console for more details.", false);
                    Logger.WriteError("Couldn't load development plugin at path '" + DevelopmentPluginPath + "'!  Error:\n" + e);
                }
            }

            StartLogDeletionTimer();
        }
 private async Task ResetCredentials()
 {
     await Task.Run(() => {
         MsgBoxResult result = Interaction.MsgBox("A credentials reset for IMS was requested using the IMS remote interface.  Would you like to reset the IMS admin console username/password?", "IMS Credentials Reset", MsgBoxStyle.YesNo);
         if (result == MsgBoxResult.Yes)
         {
             IMSSettings settings  = IMS.Instance.CurrentSettings.Clone() as IMSSettings;
             settings.Username     = null;
             settings.PasswordHash = null;
             IMS.Instance.ChangeSettings(settings);
         }
         lock (Locker) {
             CurrentTask = null;
         }
     });
 }