static void Main(string[] args) { ConfigServer.LoadFromFile(); P2PService service = new P2PService(); service.Start(); }
/// <summary> /// Copy from file ConfigCli.json to ConfigServer.json /// </summary> public static void ConfigToServer() { // Console.WriteLine("Copy runtime specific values from ConfigCli to ConfigServer"); // There is also other values not needed for runtime like DeployAzureGitUrl. var configCli = ConfigCli.Load(); var configServer = ConfigServer.Load(); // Environment configServer.EnvironmentName = configCli.EnvironmentGet().EnvironmentName; configServer.IsUseDeveloperExceptionPage = configCli.EnvironmentGet().IsUseDeveloperExceptionPage; // ConnectionString configServer.ConnectionStringFramework = configCli.EnvironmentGet().ConnectionStringFramework; configServer.ConnectionStringApplication = configCli.EnvironmentGet().ConnectionStringApplication; // Website configServer.WebsiteList.Clear(); foreach (var webSite in configCli.WebsiteList) { configServer.WebsiteList.Add(new ConfigServerWebsite() { DomainNameList = webSite.DomainNameList.Where(item => item.EnvironmentName == configCli.EnvironmentGet().EnvironmentName).Select(item => new ConfigServerWebsiteDomain { DomainName = item.DomainName, AppTypeName = item.AppTypeName }).ToList() }); } ConfigServer.Save(configServer); }
static void Main(string[] args) { try { IUnityContainer container = new UnityContainer(); ConfigServer _ConfigServer = ConfigurationServer.ReadConfigFromFile("user.json"); container.RegisterSingleton <GeneralChatInfo>(new InjectionConstructor(1, "General", "Server")); container.RegisterSingleton <IHandlerRequestFromClient, HandlerRequestFromClient>(); container.RegisterSingleton <ITransportServer, WsServer>(new InjectionConstructor(new IPEndPoint(IPAddress.Any, _ConfigServer.Port), container.Resolve <IHandlerRequestFromClient>())); container.RegisterType <IHandlerRequestToData, RequestManagerDb>(); container.RegisterSingleton <HandlerConnection>(); container.RegisterSingleton <HandlerChat>(); container.RegisterSingleton <HandlerMessage>(); container.Resolve <HandlerMessage>(); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); } }
/// <summary> /// Constructor. /// </summary> public AppSelector() { List <ConfigServerWebsite> result = new List <ConfigServerWebsite>(); string requestDomainName = UtilServer.RequestDomainName(); this.ConfigServer = ConfigServer.Load(); foreach (var website in ConfigServer.WebsiteList) { foreach (var item in website.DomainNameList) { if (item.DomainName == requestDomainName) { result.Add(website); } } } // Make sure Website has been found if (result.Count == 0) { throw new Exception(string.Format("Website not found! See also: ConfigServer.json (Domain={0}; Environment={1};)", requestDomainName, this.ConfigServer.EnvironmentName)); } if (result.Count > 1) { throw new Exception(string.Format("More than one website found! See also: ConfigServer.json ({0})", requestDomainName)); } this.Website = result.Single(); this.AppTypeName = Website.DomainNameList.Where(item => item.DomainName == requestDomainName).Single().AppTypeName; }
/// <summary> /// Если запуск сервера скидывается, то скорее всего занят порт нужно убить процес /// </summary> /// <param name="cfg"></param> /// <param name="java"></param> public bool run(ConfigServer cfg, string java) { string batFile = ConfigApp.currentDir + SERVER_DIR + @"\" + cfg.Version + @"\" + BAT_FILE_NAME; if (File.Exists(batFile)) { Process start = new Process(); start.StartInfo.WorkingDirectory = ConfigApp.currentDir + SERVER_DIR + @"\" + cfg.Version + @"\"; if (cfg.IsGUI) { string serverFile = ConfigApp.currentDir + SERVER_DIR + @"\" + cfg.Version + @"\" + SERVER_FILE; string param = String.Format(" -Xms512M -Xmx{0}M -jar {1}", cfg.Memory, serverFile); start.StartInfo.CreateNoWindow = true; start.StartInfo.UseShellExecute = false; start.StartInfo.Arguments = param; start.StartInfo.FileName = java + @"\javaw.exe"; } else { string param = String.Format("java -Xms512M -Xmx{0}M -jar {1} nogui", cfg.Memory, SERVER_FILE); System.IO.File.WriteAllText(batFile, param); start.StartInfo.FileName = batFile; } start.Start(); start.Close(); return(true); } return(false); }
//Process UpdateSaphire (Atualiza as Saphriras requerida pelos Reis) public static DBResult Exec_MSG_DBUpdateSapphire(DBController gs, pServer GameServer) { _MSG_SIGNALPARM sm = W2Marshal.GetStructure <_MSG_SIGNALPARM>(GameServer.RecvPacket.RawBuffer); ConfigServer.ReadConfigFile(gs.Config); int Old = gs.Config.Sapphire; if (sm.parm == 1) { gs.Config.Sapphire *= 2; } else { gs.Config.Sapphire /= 2; } if (gs.Config.Sapphire < 1) { gs.Config.Sapphire = 1; } else if (gs.Config.Sapphire > 64) { gs.Config.Sapphire = 64; } gs.Server.SendSignalParm(0, BaseDef._MSG_DBSetIndex, -1, gs.Config.Sapphire, sm.Header.ClientId); ConfigServer.saveConfig(gs.Config); W2Log.Write($"sucess db set saphire: {Old} -> {gs.Config.Sapphire}"); return(DBResult.NO_ERROR); }
public frmBackup(ConfigServer cfg) { InitializeComponent(); this.cfg = cfg; txtMap.Text = cfg.MapDir; txtDirBackup.Text = cfg.BackupMapDir; }
public static void Configure(IApplicationBuilder applicationBuilder) { UtilServer.ApplicationBuilder = applicationBuilder; var configServer = ConfigServer.Load(); if (UtilServer.IsIssServer == false) { // Running in Visual Studio environment. if (configServer.IsServerSideRendering) { UtilServer.StartUniversalServer(); } } if (configServer.IsUseDeveloperExceptionPage) { applicationBuilder.UseDeveloperExceptionPage(); } applicationBuilder.UseDefaultFiles(); // Used for index.html applicationBuilder.UseStaticFiles(); // Enable access to files in folder wwwwroot. applicationBuilder.UseSession(); if (configServer.IsUseHttpsRedirection) { // Enforce HTTPS in ASP.NET Core https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-5.0&tabs=visual-studio applicationBuilder.UseHsts(); applicationBuilder.UseHttpsRedirection(); } applicationBuilder.Run(new Request().RunAsync); }
/// <summary> /// Render first html GET request. /// </summary> private static async Task <string> WebsiteServerSideRenderingAsync(HttpContext context, AppSelector appSelector, AppJson appJson) { string url; if (UtilServer.IsIssServer) { // Running on IIS Server. url = context.Request.IsHttps ? "https://" : "http://"; url += context.Request.Host.ToUriComponent() + "/Framework/Framework.Angular/server/main.js"; // Url of server side rendering when running on IIS Server } else { // Running in Visual Studio. url = "http://localhost:4000/"; // Url of server side rendering when running in Visual Studio } // Process AppJson string jsonClient = await appSelector.ProcessAsync(context, appJson); // Process (For first server side rendering) // Server side rendering POST. string folderNameServer = appSelector.Website.FolderNameServerGet(appSelector.ConfigServer, "Application.Server/Framework/"); string serverSideRenderView = UtilFramework.FolderNameParse(folderNameServer, "/index.html"); serverSideRenderView = HttpUtility.UrlEncode(serverSideRenderView); url += "?view=" + serverSideRenderView; bool isServerSideRendering = ConfigServer.Load().IsServerSideRendering; string indexHtml; if (isServerSideRendering) { // index.html server side rendering indexHtml = await UtilServer.WebPost(url, jsonClient); // Server side rendering POST. http://localhost:50919/Framework/Framework.Angular/server.js?view=Application.Website%2fDefault%2findex.html } else { // index.html serve directly string fileName = UtilServer.FolderNameContentRoot() + UtilFramework.FolderNameParse(appSelector.Website.FolderNameServerGet(appSelector.ConfigServer, "Application.Server/"), "/index.html"); indexHtml = UtilFramework.FileLoad(fileName); } // Set jsonBrowser in index.html. string scriptFind = "</app-root>"; //" <script>var jsonBrowser={}</script>"; // For example Html5Boilerplate build process renames var jsonBrowser to a. string scriptReplace = "</app-root><script>var jsonBrowser = " + jsonClient + "</script>"; if (isServerSideRendering) { indexHtml = UtilFramework.Replace(indexHtml, scriptFind, scriptReplace); } // Add Angular scripts scriptFind = "</body></html>"; scriptReplace = "<script src=\"runtime.js\" defer></script><script src=\"polyfills.js\" defer></script><script src=\"main.js\" defer></script>" + "</body></html>"; indexHtml = UtilFramework.Replace(indexHtml, scriptFind, scriptReplace); return(indexHtml); }
public void IsChangeWorldThreadCountTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 bool actual; actual = target.IsChangeWorldThreadCount; Assert.Inconclusive("验证此测试方法的正确性。"); }
public void SetupServerConfigurationBeforeStart() { using (var server = new ConfigServer()) { server.SetupConfiguration(); server.Start(); } }
public void IsChangeAssemblyDirectoryTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 bool actual; actual = target.IsChangeAssemblyDirectory; Assert.Inconclusive("验证此测试方法的正确性。"); }
public void IsChangeClientNetConfigTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 bool actual; actual = target.IsChangeClientNetConfig; Assert.Inconclusive("验证此测试方法的正确性。"); }
public void GetCompleteSolutionTest() { ConfigServer _server = new ConfigServer(); var r = _server.GetCompleteSolution(Guid.Parse("8bfd55bf-ad32-49a9-bece-db8d5262297e")); Assert.IsTrue(r.ActionResult); Assert.IsNotNull(r.Data); Assert.IsNotNull(r.Data.Components); Assert.IsTrue(r.Data.Components.Count > 0); }
public void StartServerWithoutConfiguration() { using (var server = new ConfigServer()) { Exception ex = Assert.Throws <EtherConfigurationException>(() => server.Start()); Assert.IsType <EtherConfigurationException>(ex); } }
private void frmMain_Loaded(object sender, RoutedEventArgs e) { ConfigApp.initDirSetting(); webServer = new WebServer(clientInfoAdd); os = new OS(); os.interfaceServerDisabled = interfaceServerDisabled; os.interfaceMinecraftDisabled = interfaceMinecraftDisabled; os.serverRunning = serverRunning; os.minecraftRunning = minicraftRunning; os.startMonitor(); this.frmMain.Title = ConfigApp.getAppTitle(); cfgClient = ConfigApp.LoadClientSetting(); cfgServer = ConfigApp.LoadServerSetting(); listServer = ConfigApp.LoadListServer(); cmbMemory.ItemsSource = os.freeMemory(); //cmbMemory.ite; cmbMemoryServer.ItemsSource = os.freeMemory(); lblIsx64.Content = os.getIsOSx64() + os.getJavaInfo(); cmbVersionGame.ItemsSource = game.getGameVersions(); cmbVersionServer.ItemsSource = server.getVersions(); //SERVER SETTING for (int i = 0; i < listServer.Length; i++) { cmbGameServer.Items.Add(listServer[i]); } // CLIENT txtUserName.Text = (!String.IsNullOrEmpty(cfgClient.Username)) ? cfgClient.Username : os.getUserName(); IsForge.IsChecked = cfgClient.IsForge; isReMods.IsChecked = cfgClient.IsinstallMods; cmbMemory.Text = (!String.IsNullOrEmpty(cfgClient.Memory)) ? cfgClient.Memory.Trim() : ""; cmbVersionGame.Text = (!String.IsNullOrEmpty(cfgClient.VersionGame)) ? cfgClient.VersionGame.Trim() : ""; //txtHostServerMap.Text = cfgClient.HostServer; cmbGameServer.Text = cfgClient.HostServer; txtPortGameServer.Text = cfgClient.PortGameServer; txtPortMapServer.Text = cfgClient.PortMapServer; //SERVER cmbMemoryServer.Text = (!String.IsNullOrEmpty(cfgServer.Memory)) ? cfgServer.Memory.Trim() : ""; cmbVersionServer.Text = (!String.IsNullOrEmpty(cfgServer.Version)) ? cfgServer.Version.Trim() : ""; isGUI.IsChecked = cfgServer.IsGUI; // Отправить данные на сервер string postData = String.Format("login={0}&memory={1}&version={2}&is_forge={3}&version_launcher={4}", cfgClient.Username, cfgClient.Memory, cfgClient.VersionGame, cfgClient.IsForge, ConfigApp.getVersion()); new WebClientInfo(serverResponseInfo).send(postData); }
/// <summary> /// /// </summary> /// <param name="configServer"></param> internal static void ConfigServer(ref ConfigServer configServer) { ////////////////////////////////////////////////////////////////////////// // 获取配置的信息 LoadVariables(); ////////////////////////////////////////////////////////////////////////// // 设置配置的信息 configServer.Service = s_ConfigInfo.Service; configServer.LogFile = s_ConfigInfo.LogFile; configServer.Cache = s_ConfigInfo.Cache; configServer.Debug = s_ConfigInfo.Debug; configServer.HaltOnWarning = s_ConfigInfo.HaltOnWarning; configServer.Profiling = s_ConfigInfo.Profiling; configServer.WorldThreadCount = s_ConfigInfo.WorldThreadCount; if (s_ConfigInfo.ServerCachedSize > 0 && s_ConfigInfo.ServerBufferSize > 0 && s_ConfigInfo.ServerManageThreadPoolSize > 0 && s_ConfigInfo.ServerSendThreadPoolSize > 0 && s_ConfigInfo.ServerReceiveThreadPoolSize > 0 && s_ConfigInfo.ServerProcessThreadPoolSize > 0 && s_ConfigInfo.ServerMaxClients > 0 && s_ConfigInfo.ServerOutTimeInterval >= 0) { configServer.SetServerNetConfig((int)s_ConfigInfo.ServerCachedSize , (int)s_ConfigInfo.ServerBufferSize , (int)s_ConfigInfo.ServerManageThreadPoolSize , (int)s_ConfigInfo.ServerSendThreadPoolSize , (int)s_ConfigInfo.ServerReceiveThreadPoolSize , (int)s_ConfigInfo.ServerProcessThreadPoolSize , (int)s_ConfigInfo.ServerMaxClients , (int)s_ConfigInfo.ServerOutTimeInterval); } if (s_ConfigInfo.ClientCachedSize > 0 && s_ConfigInfo.ClientBufferSize > 0 && s_ConfigInfo.ClientManageThreadPoolSize > 0 && s_ConfigInfo.ClientSendThreadPoolSize > 0 && s_ConfigInfo.ClientReceiveThreadPoolSize > 0 && s_ConfigInfo.ClientProcessThreadPoolSize > 0 && s_ConfigInfo.ClientOutTimeInterval >= 0) { configServer.SetClientNetConfig((int)s_ConfigInfo.ClientCachedSize , (int)s_ConfigInfo.ClientBufferSize , (int)s_ConfigInfo.ClientManageThreadPoolSize , (int)s_ConfigInfo.ClientSendThreadPoolSize , (int)s_ConfigInfo.ClientReceiveThreadPoolSize , (int)s_ConfigInfo.ClientProcessThreadPoolSize , (int)s_ConfigInfo.ClientOutTimeInterval); } }
public string getConfig(ConfigServer cfg) { string file = ConfigApp.currentDir + @"\" + SERVER_DIR + @"\" + cfg.Version + @"\" + CONFIG_FILE; if (File.Exists(file)) { currentVersion = cfg.Version; return(File.ReadAllText(file)); } return(""); }
public void WorldThreadCountTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 byte expected = 0; // TODO: 初始化为适当的值 byte actual; target.WorldThreadCount = expected; actual = target.WorldThreadCount; Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void ServiceTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; target.Service = expected; actual = target.Service; Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void ScriptDirectoryTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 string expected = string.Empty; // TODO: 初始化为适当的值 string actual; target.ScriptDirectory = expected; actual = target.ScriptDirectory; Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void CreateComponentTest() { ConfigServer _server = new ConfigServer(); var r = _server.CreateComponent(new Component() { ComponentID = 1001, ComponentName = "配置服务" }); Assert.IsTrue(r.ActionResult); Assert.IsTrue(r.Data > 0); }
public void SetupServerConfigurationAfterStart() { using (var server = new ConfigServer()) { server.SetupConfiguration(); server.Start(); Exception ex = Assert.Throws <EtherConfigurationException>(() => server.SetupConfiguration()); Assert.IsType <EtherConfigurationException>(ex); } }
public void SetupServerConfigurationAfterStartStop() { using (var server = new ConfigServer()) { server.SetupConfiguration(); server.Start(); server.Stop(); server.SetupConfiguration(); server.Start(); server.Stop(); } }
public static void SaveServerSetting(ConfigServer cf) { string fileConfig = DIR_ROOT + @"\" + DIR_SETTING + @"\" + FILE_SERVER_CONFIG; StreamWriter save = new StreamWriter(fileConfig); save.WriteLine(cf.Memory); save.WriteLine(cf.Version); save.WriteLine(cf.IsGUI); save.WriteLine(cf.BackupMapDir); save.WriteLine(cf.MapDir); save.Close(); }
public void SetClientNetConfigTest() { ConfigServer target = new ConfigServer(); // TODO: 初始化为适当的值 int ClientCachedSize = 0; // TODO: 初始化为适当的值 int ClientBufferSize = 0; // TODO: 初始化为适当的值 int ClientManageThreadPoolSize = 0; // TODO: 初始化为适当的值 int ClientSendThreadPoolSize = 0; // TODO: 初始化为适当的值 int ClientReceiveThreadPoolSize = 0; // TODO: 初始化为适当的值 int ClientProcessThreadPoolSize = 0; // TODO: 初始化为适当的值 int ClientOutTimeInterval = 0; // TODO: 初始化为适当的值 target.SetClientNetConfig(ClientCachedSize, ClientBufferSize, ClientManageThreadPoolSize, ClientSendThreadPoolSize, ClientReceiveThreadPoolSize, ClientProcessThreadPoolSize, ClientOutTimeInterval); Assert.Inconclusive("无法验证不返回值的方法。"); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); string certPath = Path.Combine(_env.ContentRootPath, "identity_token_server.pfx"); X509Certificate2 cert = new X509Certificate2(certPath, "w@s@m@ndr@kk@"); services.AddIdentityServer() .AddInMemoryApiResources(ConfigServer.GetApiResources()) .AddTestUsers(ConfigServer.GetUSers()) .AddInMemoryClients(ConfigServer.GetClients()) .AddSigningCredential(cert); }
public ITransportServer Create(ConfigServer config) { switch (config.Protocol) { case TypeTransport.WebSocket: return(new WsServer(new IPEndPoint(IPAddress.Any, config.Port), new HandlerRequestFromClient())); case TypeTransport.Tcp: return(new TcpServer(new IPEndPoint(IPAddress.Any, config.Port), new HandlerRequestFromClient())); default: throw new ArgumentOutOfRangeException(nameof(config), config, null); } }
public ManagerServer(ConfigServer type_config) { this.type_config = type_config; this.package = Program.config.packages[this.type_config.package_name]; //Get servers of this type and spawn their processes (but don't actually start them yet) foreach (var i in Program.server_instances) { if (i.server_type == type_config.type.ToString() && i.manager_id == Program.config.server_id) { instances.Add(new ManagerInstance(this, i)); } } }
public void StartClientWithConfiguration() { using (var server = new ConfigServer()) { server.SetupConfiguration(); server.Start(); using (var client = new ConfigClient()) { client.SetupConfiguration(); client.Connect(); client.Disconnect(); } } }
public void CreateComponentConfigTest() { ConfigServerConfig csc = new ConfigServerConfig() { DalConfigs = new List<DataAccessConfiguration>() }; csc.DalConfigs.Add(new DataAccessConfiguration() { ConnectionName = "SolutionConfiguration", DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456", DatabaseType = EnumDatabaseType.MySql, Multiple = false }); csc.DalConfigs.Add(new DataAccessConfiguration() { ConnectionName = "ComponentConnection", DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456", DatabaseType = EnumDatabaseType.MySql, Multiple = false }); csc.DalConfigs.Add(new DataAccessConfiguration() { ConnectionName = "ComponentConfiguration", DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456", DatabaseType = EnumDatabaseType.MySql, Multiple = false }); ConfigServer _server = new ConfigServer(); var r = _server.CreateComponentConfig(new ComponentConfiguration() { ComponentId = 1001, Content = XmlConfigSerializer.Instance.ToXml<ConfigServerConfig>(csc), Environment = 1, CreateBy = 1, IsActive = true, Enable = true, IsDebug = false, IsDelete = false, Signature = "无签名", Version = 1 }); Assert.IsTrue(r.ActionResult); Assert.IsTrue(r.Data > 0); }
public void CreateSolutionTest() { ConfigServer _server = new ConfigServer(); var r = _server.CreateSolution(new SolutionConfiguration() { Version = 1, Content = "", Environment = 1, Enable = true, IsActive = true, IsDelete = false, IsFile = true, CreateBy = 1, IsRemote = false, SolutionId = Guid.NewGuid(), SolutionName = "配置服务解决方案" }); Assert.IsTrue(r.ActionResult); Assert.IsTrue(r.Data > 0); }
private void MainClientForm_Load(object sender, EventArgs e) { TraceOps.LoadLog(); Services.PrepareGetService(); SystemOps.SetAutoStart(); _configServer = new ConfigServer(); _configServer.Changed += ConfigServerOnChanged; _keyboard = new KeyboardControl(); _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Left, this); _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Right, this); _keyboard.KeyPressed += HandleHotkey; DllLoader.InitializeClientPlugIns(_plugins); }