public static void closeLuminatio(decimal port) { if (!Lumi.sendCheck()) { //MessageBox.Show("Luminatio Proxy Manager is not running!", Application.ProductName, MessageBoxButtons.OK,MessageBoxIcon.Hand); } else { try { var client = new RestClient("http://127.0.0.1:22999"); // client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest("api/proxies/" + port.ToString(), Method.DELETE); // execute the request client.Execute(request); } catch (Exception e) { MessageBox.Show("Error while Close Luminatio Port" + port.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }
public static bool fake_proxy_lumi(string countryName, string portforward, string zone, string password, string username) { bool isValid = false; //check if configuration file is existed or not DateTime now = DateTime.Now; int maxwait = 30; while (true) { if ((DateTime.Now - now).TotalSeconds <= (double)maxwait) { var countryCode = Lumi.GetCountryCodeFromName(countryName); if (countryCode != null) { //check if port is exited. if (!Lumi.sendCheck()) { MessageBox.Show("Luminatio Proxy Manager is not running!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { //create port with country. try { bool isPortExisted = Lumi.checkIfPortExisted(portforward); if (isPortExisted) { bool isSame = Lumi.CheckIfHaveProxySameInfo(portforward, username, zone, password, countryCode); if (isSame == true) { isValid = true; } else { isValid = CreateOrUpdateProxy(portforward, username, password, zone, countryCode, true); } } else { isValid = CreateOrUpdateProxy(portforward, username, password, zone, countryCode, false); } } catch (Exception e) { MessageBox.Show("Luminatio Proxy set country port with error" + e.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } break; } } else { MessageBox.Show("Timeout when finding country Code For Country" + countryName, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); break; } } return(isValid); }