コード例 #1
0
ファイル: Lumi.cs プロジェクト: thienkimlove/lead
        public static bool CreateOrUpdateProxy(string port, string username, string password, string zone, string countryCode, bool isUpdate)
        {
            bool        isValid = false;
            RestRequest request;

            try
            {
                var client = new RestClient("http://127.0.0.1:22999");
                if (isUpdate == true)
                {
                    request = new RestRequest("api/proxies/" + port, Method.PUT);
                }
                else
                {
                    request = new RestRequest("api/proxies", Method.POST);
                }

                request.RequestFormat = DataFormat.Json;
                request.AddBody(new
                {
                    proxy = new
                    {
                        port     = port,
                        zone     = zone,
                        country  = countryCode.ToLower(),
                        password = password,
                        customer = username
                    }
                });

                // execute the request
                IRestResponse response = client.Execute(request);

                var jsonRes = JObject.Parse(response.Content);
                var jResult = jsonRes["data"];
                Thread.Sleep(5);

                bool checkExisted = Lumi.checkIfPortExisted(port);

                if (checkExisted == true)
                {
                    isValid = true;
                }
            }
            catch (Exception eee)
            {
            }
            return(isValid);
        }
コード例 #2
0
ファイル: Lumi.cs プロジェクト: thienkimlove/lead
        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);
        }