// GET: Tag/Details/5 public IActionResult Details(int?id) { if (id == null) { return(NotFound()); } var response = ApiConsumer.Get <Tag>( _options.Value.ApiUrl + $"tag/{id}"); if (response.Data == null) { return(NotFound()); } return(View(response.Data)); }
// GET: CrossReferences public IActionResult Index() { var response = ApiConsumer.Get <List <CrossReference> >(_options.Value.ApiUrl + "CrossReference"); foreach (var crossReference in response.Data) { var detail = ApiConsumer.Get <CrossReference>( _options.Value.ApiUrl + $"CrossReference/{crossReference.Id}/detail"); crossReference.Server = detail.Data.Server; crossReference.Regulation = detail.Data.Regulation; crossReference.Branch = detail.Data.Branch; crossReference.Company = detail.Data.Company; } return(View(response.Data)); }
public async Task CreateLykkeBluePartnerClientAndApiConsumer() { var consumer = new ApiConsumer(_configBuilder); await consumer.RegisterNewUser( new ClientRegisterDTO { Email = Helpers.RandomString(8) + GlobalConstants.AutoTestEmail, FullName = Helpers.RandomString(5) + " " + Helpers.RandomString(8), ContactPhone = Helpers.Random.Next(1000000, 9999999).ToString(), Password = Helpers.RandomString(10), Hint = Helpers.RandomString(3), PartnerId = _configBuilder.Config["LykkeBluePartnerId"] // "Lykke.blue" } ); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id)); }
private static void PegarCarta() { try { var consumidor = new ApiConsumer <Deck>(); _filtroDeck.deck_count = -1; _filtroDeck.count = 1; var resposta = consumidor.GetAsync("deck", _filtroDeck, _deckId, "draw").Result; foreach (var carta in resposta.Cards) { Console.WriteLine($"{ carta.Value } of { carta.Suit }"); } } catch (Exception ex) { throw ex; } }
public async Task SendImage(object sender) { try { CanExecute = false; DisplayMsg = false; if (String.IsNullOrEmpty(ImagePath)) { DisplayMsg = true; Message = "Image path is requried"; return; } ApiConsumer consumer = new ApiConsumer(); var result = await consumer.SendImageAsync(ImagePath, IsStore); DisplayMsg = true; Message = ""; foreach (var cur in result.JContent) { Message += cur.Value.Value <string>() + " "; } Message = Message.TrimEnd(' '); if (result.StatusCode == HttpStatusCode.Unauthorized) { MessageBox.Show(Message + " the token is expired, please re-login"); AppContext.Current.App.CurPageViewModel = new LoginViewModel(); } } catch (Exception ex) { _logger.Error(ex); DisplayMsg = true; Message = ex.Message; } finally { CanExecute = true; } }
public ActionResult Create(CandidateViewModel candidateViewModel) { try { var candidate = new Candidate { FirstName = candidateViewModel.FirstName, Id = candidateViewModel.Id, LastName = candidateViewModel.LastName, PartyName = candidateViewModel.PartyName }; ApiConsumer <Candidate> .ConsumePost("Candidates", candidate); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult EditSecretQuestion(SecretQuestion secretQuestionViewModel) { try { var secretQuestion = new SecretQuestion { Id = secretQuestionViewModel.Id, Question = secretQuestionViewModel.Question, Answer = secretQuestionViewModel.Answer }; ApiConsumer <SecretQuestion> .ConsumePut("SecretQuestions", secretQuestion); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Edit(int id, [Bind("Id,ServerId,RegulationId,BranchId,CompanyId")] CrossReference crossReference) { if (id != crossReference.Id) { return(NotFound()); } if (ModelState.IsValid) { try { ApiConsumer.Put <Branch>(crossReference, _options.Value.ApiUrl + $"CrossReference/{id}"); } catch (DbUpdateConcurrencyException) { if (!CrossReferenceExists(crossReference.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index))); } var response = ApiConsumer.Get <CrossReference>(_options.Value.ApiUrl + $"CrossReference/{id}"); var server = ApiConsumer.Get <List <Server> >(_options.Value.ApiUrl + "server"); var regulation = ApiConsumer.Get <List <Regulation> >(_options.Value.ApiUrl + "regulation"); var branch = ApiConsumer.Get <List <Branch> >(_options.Value.ApiUrl + "branch"); var company = ApiConsumer.Get <List <Company> >(_options.Value.ApiUrl + "company"); ViewData["BranchId"] = new SelectList(branch.Data, "Id", "Name", response.Data.BranchId); ViewData["CompanyId"] = new SelectList(company.Data, "Id", "Name", response.Data.CompanyId); ViewData["RegulationId"] = new SelectList(regulation.Data, "Id", "Name", response.Data.RegulationId); ViewData["ServerId"] = new SelectList(server.Data, "Id", "Name", response.Data.ServerId); return(View(crossReference)); }
public ActionResult Edit(VoterViewModel voterViewModel) { try { var voter = new Voter { FirstName = voterViewModel.FirstName, Id = voterViewModel.Id, LastName = voterViewModel.LastName, Cnp = voterViewModel.Cnp }; ApiConsumer <Voter> .ConsumePut("Voters", voter); return(RedirectToAction("Index")); } catch { return(View()); } }
public WiFiModule() : base("/wifi") { this.RequiresAuthentication(); Get["/"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Post["/save"] = x => { string data = Request.Form.Data; var dict = new Dictionary <string, string> { { "Data", data } }; return(ApiConsumer.Post(CommonString.Append(Application.ServerUrl, Request.Path), dict)); }; Post["/apply"] = x => { return(ApiConsumer.Post(CommonString.Append(Application.ServerUrl, Request.Path))); }; }
public IActionResult Create([Bind("Id,ServerId,RegulationId,BranchId,CompanyId")] CrossReference crossReference) { if (ModelState.IsValid) { ApiConsumer.Post <Branch>(crossReference, _options.Value.ApiUrl + "CrossReference"); return(RedirectToAction(nameof(Index))); } var server = ApiConsumer.Get <List <Server> >(_options.Value.ApiUrl + "server"); var regulation = ApiConsumer.Get <List <Regulation> >(_options.Value.ApiUrl + "regulation"); var branch = ApiConsumer.Get <List <Branch> >(_options.Value.ApiUrl + "branch"); var company = ApiConsumer.Get <List <Company> >(_options.Value.ApiUrl + "company"); ViewData["BranchId"] = new SelectList(branch.Data, "Id", "Name", crossReference.BranchId); ViewData["CompanyId"] = new SelectList(company.Data, "Id", "Name", crossReference.CompanyId); ViewData["RegulationId"] = new SelectList(regulation.Data, "Id", "Name", crossReference.RegulationId); ViewData["ServerId"] = new SelectList(server.Data, "Id", "Name", crossReference.ServerId); return(View(crossReference)); }
public IActionResult Edit(int id, [Bind("Name,Key,Logins,Id")] Tag tag) { if (id != tag.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var response = ApiConsumer.Put <Tag>(tag, _options.Value.ApiUrl + "tag/v2"); } catch (DbUpdateConcurrencyException) { } return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public ActionResult Create(VoterViewModel voterViewModel) { try { var voter = new Voter { FirstName = voterViewModel.FirstName, Id = voterViewModel.Id, LastName = voterViewModel.LastName, Cnp = voterViewModel.Cnp, SecretQuestions = new List <SecretQuestion>() }; var taskResult = ApiConsumer <Voter> .ConsumePost("Voters", voter); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Candidates/Details/5 public ActionResult Details(int id) { var voter = ApiConsumer <Voter> .ConsumeGet("Voters", id); var voterViewModel = new VoterViewModel { FirstName = voter.FirstName, Id = voter.Id, LastName = voter.LastName, Cnp = voter.Cnp }; voterViewModel.SecretQuestions = from secretQuestion in voter.SecretQuestions select new SecretQuestionViewModel { Id = secretQuestion.Id, Question = secretQuestion.Question, Answer = secretQuestion.Answer }; return(View(voterViewModel)); }
public IActionResult Create([Bind("Name,CrossReferenceId")] GroupCrossReferenceViewModel groupCrossReference) { if (ModelState.IsValid) { var objectToCreate = new GroupCrossReference { GroupName = groupCrossReference.Name, CrossReferenceId = groupCrossReference.CrossReferenceId }; ApiConsumer.Post <CrossReference>(groupCrossReference, _options.Value.ApiUrl + "Group"); return(RedirectToAction(nameof(Index))); } var crossReferenceResponse = ApiConsumer.Get <List <CrossReference> >(_options.Value.ApiUrl + "CrossReference/details"); var selectListDataSource = new List <GroupCrossReferenceViewModel>(); foreach (var item in crossReferenceResponse.Data) { selectListDataSource.Add(new GroupCrossReferenceViewModel { Id = item.Id, CrossReferenceAlias = item.Server.Name + " - " + item.Regulation.Name + " - " + item.Branch.Name + " - " + item.Company.Name, CrossReferenceId = item.Id }); } ViewData["CrossReference"] = new SelectList(selectListDataSource, "CrossReferenceId", "CrossReferenceAlias", groupCrossReference.CrossReferenceId); return(View(groupCrossReference)); }
// GET: GroupCrossReferences/Create public IActionResult Create() { var crossReferenceResponse = ApiConsumer.Get <List <CrossReference> >(_options.Value.ApiUrl + "CrossReference/details"); var selectListDataSource = new List <GroupCrossReferenceViewModel>(); foreach (var item in crossReferenceResponse.Data) { selectListDataSource.Add(new GroupCrossReferenceViewModel { CrossReferenceAlias = item.Server.Name + " - " + item.Regulation.Name + " - " + item.Branch.Name + " - " + item.Company.Name, CrossReferenceId = item.Id }); } ViewData["CrossReference"] = new SelectList(selectListDataSource, "CrossReferenceId", "CrossReferenceAlias"); return(View()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.accounts); ApiService = new ApiConsumer(); simpleSwitch = FindViewById <Switch>(Resource.Id.simpleSwitch); capable = FindViewById <TextView>(Resource.Id.capable); contentLinearLayout = FindViewById <LinearLayout>(Resource.Id.contentLinearLayout); progressBar = FindViewById <LinearLayout>(Resource.Id.ProgressBar); Button continueBtn = FindViewById <Button>(Resource.Id.continueBtn); continueBtn.Click += ContinueBtn_Click; Button exitBtn = FindViewById <Button>(Resource.Id.exitBtn); exitBtn.Click += ExitBtn_Click; CallApi(); }
public ActionResult AddSecretQuestion(SecretQuestionViewModel secretQuestionViewModel, int id) { try { var secretQuestion = new SecretQuestion { Question = secretQuestionViewModel.Question, Answer = secretQuestionViewModel.Answer }; var voter = ApiConsumer <Voter> .ConsumeGet("Voters", id); voter.SecretQuestions.Add(secretQuestion); var result = ApiConsumer <Voter> .ConsumePut("Voters", voter); return(RedirectToAction("Index")); } catch { return(View()); } }
public static ResponseLicenseStatusModel Check(string appName, byte[] publicKey) { var cloudaddress = Application.CurrentConfiguration.WebService.Cloud; try { var p = new Ping(); var pingReply = p.Send(cloudaddress, 500); if (pingReply?.Status != IPStatus.Success) { return(null); } } catch (Exception) { return(null); } if (string.IsNullOrEmpty(cloudaddress)) { return(null); } if (cloudaddress.Contains("localhost")) { return(null); } if (!cloudaddress.EndsWith("/")) { cloudaddress = cloudaddress + "/"; } var pk = Encoding.ASCII.GetString(publicKey); var dict = new Dictionary <string, string> { { "AppName", appName }, { "PartNumber", Application.CurrentConfiguration.Host.PartNumber.ToString() }, { "SerialNumber", Application.CurrentConfiguration.Host.SerialNumber.ToString() }, { "Uid", Application.CurrentConfiguration.Host.MachineUid.ToString() }, { "PublicKey", pk } }; var status = ApiConsumer.Post <ResponseLicenseStatusModel>($"{cloudaddress}license/check", dict); return(status); }
// GET: GroupCrossReferences public IActionResult Index() { var response = ApiConsumer.Get <List <GroupCrossReference> >(_options.Value.ApiUrl + "Group/details"); var viewModel = new List <GroupCrossReferenceViewModel>(); foreach (var item in response.Data) { viewModel.Add(new GroupCrossReferenceViewModel { Id = item.Id, Name = item.GroupName, CrossReferenceAlias = item.CrossReference.Server.Name + " - " + item.CrossReference.Regulation.Name + " - " + item.CrossReference.Branch.Name + " - " + item.CrossReference.Company.Name }); } return(View(viewModel)); }
private async Task prepareTestData() { ConfigBuilder apiv2Config = new ConfigBuilder("ApiV2"); ApiConsumer registerConsumer1 = new ApiConsumer(apiv2Config); ApiConsumer registerConsumer2 = new ApiConsumer(apiv2Config); var registerTestAccount1 = registerConsumer1.RegisterNewUser(); var registerTestAccount2 = registerConsumer2.RegisterNewUser(); TestAsset1 = Constants.TestAsset1; TestAsset2 = Constants.TestAsset2; TestAccountId1 = (await registerTestAccount1)?.Account.Id; TestAccountId2 = (await registerTestAccount2)?.Account.Id; AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId1)); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId2)); //give test clients some cash to work with List <Task> giveCashTasks = new List <Task>() { Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset1, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset2, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset1, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset2, Constants.InitialAssetAmmount) }; if (!Int32.TryParse(_configBuilder.Config["AssetPrecission"], out AssetPrecission)) { AssetPrecission = 2; } this.TestAssetPair = (AssetPairEntity)Task.Run(async() => { return(await this.AssetPairsRepository.TryGetAsync(TestAsset1 + TestAsset2)); }).Result; await Task.WhenAll(giveCashTasks); }
public static async Task StopAlgoInstance(ApiConsumer apiConsumer, InstanceDataDTO postInstanceData) { StopBinaryDTO stopAlgo = new StopBinaryDTO() { AlgoId = postInstanceData.AlgoId, InstanceId = postInstanceData.InstanceId }; var stopAlgoRequest = await apiConsumer.ExecuteRequest(stopAlgoPath, Helpers.EmptyDictionary, JsonUtils.SerializeObject(stopAlgo), Method.POST); StopBinaryResponseDTO stopAlgoResponce = JsonUtils.DeserializeJson <StopBinaryResponseDTO>(stopAlgoRequest.ResponseJson); int retryCounter = 1; while ((stopAlgoResponce.Status.Equals("Deploying") || stopAlgoResponce.Status.Equals("Started")) && retryCounter <= 30) { System.Threading.Thread.Sleep(10000); stopAlgoRequest = await apiConsumer.ExecuteRequest(stopAlgoPath, Helpers.EmptyDictionary, JsonUtils.SerializeObject(stopAlgo), Method.POST); stopAlgoResponce = JsonUtils.DeserializeJson <StopBinaryResponseDTO>(stopAlgoRequest.ResponseJson); retryCounter++; } }
public ActionResult SessionStats() { var latestSession = ApiConsumer <VotingSession> .ConsumeGet("VotingSessions", 0); VotingSessionViewModel latestSessionViewModel; if (latestSession != null) { latestSessionViewModel = new VotingSessionViewModel { Name = latestSession.Name, StartDate = latestSession.StartDate, EndDate = latestSession.EndDate, Candidates = (ICollection <CandidateViewModel>)latestSession.Candidates }; if (latestSession.EndDate > DateTime.Now) { return(PartialView("SessionStats", latestSessionViewModel)); } } latestSessionViewModel = new VotingSessionViewModel(); return(PartialView("Create", latestSessionViewModel)); }
/// <summary> /// Send root public key to a remote host managed by antd /// </summary> /// <param name="remoteHost">address:port</param> /// <returns></returns> private static bool Handshake(string remoteHost) { if (string.IsNullOrEmpty(remoteHost) || !remoteHost.Contains(":")) { ConsoleLogger.Error("[vpn] remote host not defined"); return(false); } const string pathToPrivateKey = "/root/.ssh/id_rsa"; const string pathToPublicKey = "/root/.ssh/id_rsa.pub"; if (!File.Exists(pathToPublicKey)) { var bash = new Bash(); bash.Execute($"ssh-keygen -t rsa -N '' -f {pathToPrivateKey}"); } var key = File.ReadAllText(pathToPublicKey); if (string.IsNullOrEmpty(key)) { ConsoleLogger.Error("[vpn] missing local host public key"); return(false); } var dict = new Dictionary <string, string> { { "ApplePie", key } }; var r = new ApiConsumer().Post($"http://{remoteHost}/asset/handshake", dict); var kh = new SshKnownHosts(); kh.Add(remoteHost.Split(':').FirstOrDefault()); if (r == HttpStatusCode.OK) { ConsoleLogger.Log("[vpn] handshake"); return(true); } ConsoleLogger.Error("[vpn] something went wrong during handshaking"); return(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.chooseFiles); ApiService = new ApiConsumer(); foldersCarousel = FindViewById <ViewPager>(Resource.Id.cardCarousel); ImageButton next = FindViewById <ImageButton>(Resource.Id.next); ImageButton previous = FindViewById <ImageButton>(Resource.Id.previous); continueBtn = FindViewById <Button>(Resource.Id.continueBtn); continueBtn.Click += ContinueBtn_Click; othersBtn = FindViewById <Button>(Resource.Id.othersBtn); othersBtn.Click += OthersBtn_Click; carouselAdapter = new CarouselAdapter(this, folderCarousel); foldersCarousel.Adapter = carouselAdapter; CirclePageIndicator indicator = FindViewById <CirclePageIndicator>(Resource.Id.indicator); indicator.SetViewPager(foldersCarousel); one = FindViewById <ImageView>(Resource.Id.one); two = FindViewById <ImageView>(Resource.Id.two); three = FindViewById <ImageView>(Resource.Id.three); four = FindViewById <ImageView>(Resource.Id.four); five = FindViewById <ImageView>(Resource.Id.five); oneFile = FindViewById <TextView>(Resource.Id.oneFile); secondFile = FindViewById <TextView>(Resource.Id.secondFile); thirthFile = FindViewById <TextView>(Resource.Id.thirthFile); fourFile = FindViewById <TextView>(Resource.Id.fourFile); fiveFile = FindViewById <TextView>(Resource.Id.fiveFile); next.Click += Next_Click; previous.Click += Previous_Click; }
public JournalctlModule() : base("/journalctl") { this.RequiresAuthentication(); Get["/"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Get["/unit/{unitname}"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Get["/unit/antd"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Get["/unit/antdui"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; Get["/last/{hours}"] = x => { return(ApiConsumer.GetJson(CommonString.Append(Application.ServerUrl, Request.Path))); }; }
private void CallTheApi() { if (txtUrl.Text.HasValue() && !txtUrl.Text.EndsWith("/")) { txtUrl.Text = txtUrl.Text + "/"; } if (cboPath.Text.HasValue() && !cboPath.Text.StartsWith("/")) { cboPath.Text = "/" + cboPath.Text; } var context = new WebApiRequestContext { PublicKey = txtPublicKey.Text, SecretKey = txtSecretKey.Text, Url = txtUrl.Text + (radioOdata.Checked ? "odata/" : "api/") + txtVersion.Text + cboPath.Text, HttpMethod = cboMethod.Text, HttpAcceptType = (radioJson.Checked ? ApiConsumer.JsonAcceptType : ApiConsumer.XmlAcceptType) }; if (cboQuery.Text.HasValue()) { context.Url = string.Format("{0}?{1}", context.Url, cboQuery.Text); } if (!context.IsValid) { "Please enter Public-Key, Secret-Key, URL and method.".Box(MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Debug.WriteLine(context.ToString()); return; } var apiConsumer = new ApiConsumer(); var response = new WebApiConsumerResponse(); var sb = new StringBuilder(); StringBuilder requestContent = null; Dictionary <string, object> multiPartData = null; lblRequest.Text = "Request: " + context.HttpMethod + " " + context.Url; lblRequest.Refresh(); if (radioApi.Checked && txtFile.Text.HasValue()) { var id1 = txtIdentfier1.Text.ToInt(); var id2 = txtIdentfier2.Text; var keyForId1 = "Id"; var keyForId2 = ""; multiPartData = new Dictionary <string, object>(); if (cboPath.Text.StartsWith("/Uploads/ProductImages")) { // only one identifier required: product id, sku or gtin keyForId2 = "Sku"; } else if (cboPath.Text.StartsWith("/Uploads/ImportFiles")) { // only one identifier required: import profile id or profile name keyForId2 = "Name"; // to delete existing import files: //multiPartData.Add("deleteExisting", true); } if (id1 != 0) { multiPartData.Add(keyForId1, id1); } if (id2.HasValue()) { multiPartData.Add(keyForId2, id2); } apiConsumer.AddApiFileParameter(multiPartData, txtFile.Text); } var webRequest = apiConsumer.StartRequest(context, cboContent.Text, multiPartData, out requestContent); txtRequest.Text = requestContent.ToString(); var result = apiConsumer.ProcessResponse(webRequest, response); lblResponse.Text = "Response: " + response.Status; sb.Append(response.Headers); if (result && radioJson.Checked && radioOdata.Checked) { var customers = response.TryParseCustomers(); if (customers != null) { sb.AppendLine("Parsed {0} customer(s):".FormatInvariant(customers.Count)); customers.ForEach(x => sb.AppendLine(x.ToString())); sb.Append("\r\n"); } } sb.Append(response.Content); txtResponse.Text = sb.ToString(); cboPath.InsertRolled(cboPath.Text, 64); cboQuery.InsertRolled(cboQuery.Text, 64); cboContent.InsertRolled(cboContent.Text, 64); }
private void cboMethod_changeCommitted(object sender, EventArgs e) { bool enable = ApiConsumer.BodySupported(cboMethod.Text); cboContent.Enabled = enable; }
// GET: Servers public IActionResult Index() { var response = ApiConsumer.Get <List <Server> >(_options.Value.ApiUrl + "server"); return(View(response.Data)); }
private void SaveHaproxy(string publicIp, List <NodeModel> nodes) { ConsoleLogger.Log("[cluster] init haproxy"); CommandLauncher.Launch("haproxy-stop"); if (File.Exists(_haproxyFileOutput)) { File.Copy(_haproxyFileOutput, $"{_haproxyFileOutput}.bck", true); } ConsoleLogger.Log("[cluster] set haproxy file"); var clusterInfo = ClusterConfiguration.GetClusterInfo(); var ports = clusterInfo.PortMapping; if (!ports.Any()) { return; } var lines = new List <string> { "global", " daemon", " log 127.0.0.1 local0", " log 127.0.0.1 local1 notice", " maxconn 4096", " user haproxy", " group haproxy", "", "defaults", " log global", " mode http", " option httplog", " option dontlognull", " retries 3", " option redispatch", " maxconn 2000", " timeout connect 5000", " timeout client 50000", " timeout server 50000", "" }; var localport = new AppConfiguration().Get().AntdUiPort; var localServices = new ApiConsumer().Get <List <RssdpServiceModel> >($"http://localhost:{localport}/device/services"); foreach (var portMapping in ports) { portMapping.ServicePort = localServices.FirstOrDefault(_ => _.Name == portMapping.ServiceName)?.Port; if (string.IsNullOrEmpty(portMapping.ServicePort)) { continue; } var frontEndLabel = $"fe_in{portMapping.ServicePort}_out{portMapping.VirtualPort}"; var backEndLabel = $"be_in{portMapping.ServicePort}_out{portMapping.VirtualPort}"; lines.Add($"frontend {frontEndLabel}"); lines.Add(" mode http"); lines.Add($" bind {clusterInfo.VirtualIpAddress}:{portMapping.VirtualPort} transparent"); lines.Add(" stats enable"); lines.Add(" stats auth admin:Anthilla"); lines.Add(" option httpclose"); lines.Add(" option forwardfor"); lines.Add($" default_backend {backEndLabel}"); lines.Add(""); lines.Add($"backend {backEndLabel}"); lines.Add(" balance roundrobin"); lines.Add(" cookie JSESSIONID prefix"); lines.Add(" option httpchk HEAD /check.txt HTTP/1.0"); foreach (var node in nodes) { lines.Add($" server {node.Hostname} {node.PublicIp}:{portMapping.ServicePort} check"); } lines.Add(""); } File.WriteAllLines(_haproxyFileOutput, lines); CommandLauncher.Launch("haproxy-start", new Dictionary <string, string> { { "$file", _haproxyFileOutput } }); ConsoleLogger.Log("[cluster] haproxy started"); }