コード例 #1
0
ファイル: ProxyCore.cs プロジェクト: thankhuong/AutoLeadGUI
        public static bool selectNextIP(string referIP, out string nextIP)
        {
            if (ProxyCore.__tool == ProxyTool.Vip72)
            {
                nextIP = (string)null;
                GlobalConfig.currentSSH = (Dictionary <string, object>)null;
                if (ProxyCore.__allProxiesHandle != IntPtr.Zero && ProxyCore.__currentVip72Handle != null)
                {
                    ProxyCore.__currentVip72Handle.showWindow();
                    ProxyCore.__allProxiesHandle = ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.AllProxiesListView);
                    int itemCount = Vip72Handle.ListView_GetItemCount(ProxyCore.__allProxiesHandle);
                    int index1;
                    if (referIP != null)
                    {
                        ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.MyProxies);
                        IntPtr windowHandle = ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.MyProxiesListView);
                        for (int count = Vip72Handle.GetListViewItems(windowHandle).Count; count > 0; --count)
                        {
                            Vip72Handle.deleteListViewItem(windowHandle, 0);
                        }
                        ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.AllProxies);
                        ProxyCore.__vip72ProxiesList = Vip72Handle.GetListViewItems(ProxyCore.__allProxiesHandle);
                        int    num  = -1;
                        string text = (string)null;
                        for (int index2 = 0; index2 < ProxyCore.__vip72ProxiesList.Count; ++index2)
                        {
                            List <string> vip72Proxies = ProxyCore.__vip72ProxiesList[index2];
                            if (ProxyCore.compare_vip72ip(vip72Proxies[0], referIP))
                            {
                                num  = index2;
                                text = vip72Proxies[0];
                                break;
                            }
                        }
                        if (num == -1)
                        {
                            num = GlobalConfig.random.Next(ProxyCore.__vip72ProxiesList.Count);
                        }
                        string[] strArray = GlobalConfig.stringSplit(GlobalConfig.stringSplit(text, ",")[0].Trim(), ".");
                        ProxyCore.__selectedVip72IP.Remove(strArray[0] + "." + strArray[1] + "." + strArray[2] + ".***");
                        ProxyCore.__selectedVip72IP.Add(strArray[0] + "." + strArray[1] + "." + strArray[2] + ".***");
                        index1 = num;
                    }
                    else
                    {
                        ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.MyProxies);
                        IntPtr windowHandle = ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.MyProxiesListView);
                        for (int count = Vip72Handle.GetListViewItems(windowHandle).Count; count > 0; --count)
                        {
                            Vip72Handle.deleteListViewItem(windowHandle, 0);
                        }
                        ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.AllProxies);
                        ProxyCore.__vip72ProxiesList = Vip72Handle.GetListViewItems(ProxyCore.__allProxiesHandle);
                        string     text1   = (string)null;
                        List <int> intList = new List <int>();
                        for (int index2 = 0; index2 < ProxyCore.__vip72ProxiesList.Count; ++index2)
                        {
                            string[] strArray = GlobalConfig.stringSplit(ProxyCore.__vip72ProxiesList[index2][0], ".");
                            string   str      = strArray[0] + "." + strArray[1] + "." + strArray[2] + ".***";
                            if (!ProxyCore.__selectedVip72IP.Contains(str))
                            {
                                intList.Add(index2);
                            }
                        }
                        int index3;
                        if (intList.Count == 0)
                        {
                            index3 = -1;
                        }
                        else
                        {
                            index3 = intList[GlobalConfig.random.Next(intList.Count)];
                            string[] strArray = GlobalConfig.stringSplit(ProxyCore.__vip72ProxiesList[index3][0], ".");
                            text1 = strArray[0] + "." + strArray[1] + "." + strArray[2] + ".***";
                        }
                        if (index3 == -1)
                        {
                            ProxyCore.__selectedVip72IP.Clear();
                            index3 = GlobalConfig.random.Next(ProxyCore.__vip72ProxiesList.Count);
                            string[] strArray = GlobalConfig.stringSplit(ProxyCore.__vip72ProxiesList[index3][0], ".");
                            text1 = strArray[0] + "." + strArray[1] + "." + strArray[2] + ".***";
                        }
                        string   text2     = GlobalConfig.stringSplit(text1, ",")[0].Trim();
                        string[] strArray1 = GlobalConfig.stringSplit(text2, ".");
                        ProxyCore.__selectedVip72IP.Remove(strArray1[0] + "." + strArray1[1] + "." + strArray1[2] + ".***");
                        ProxyCore.__selectedVip72IP.Add(strArray1[0] + "." + strArray1[1] + "." + strArray1[2] + ".***");
                        index1 = index3;
                        ProxyCore.writeLog("\r\nWill select ip: " + text2 + " index: " + (object)index3);
                    }
                    if (itemCount <= index1)
                    {
                        return(false);
                    }
                    ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.MyProxies);
                    IntPtr windowHandle1 = ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.MyProxiesListView);
                    for (int count = Vip72Handle.GetListViewItems(windowHandle1).Count; count > 0; --count)
                    {
                        Vip72Handle.deleteListViewItem(windowHandle1, 0);
                    }
                    ProxyCore.__currentVip72Handle.SendLeftClickToWindow(Vip72Handle.Vip72Window.AllProxies);
                    bool   flag          = false;
                    IntPtr windowHandle2 = ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.CurrentSock);
                    string b             = Vip72Handle.GetControlText(windowHandle2);
                    List <List <string> > listViewItems = Vip72Handle.GetListViewItems(ProxyCore.__allProxiesHandle);
                    ProxyCore.writeLog("\r\n*** IP1: " + listViewItems[index1][0]);
                    ProxyCore.writeLog("\r\n*** Begin select ***");
                    Vip72Handle.selectListViewItem(ProxyCore.__allProxiesHandle, index1, true);
                    ProxyCore.writeLog("\r\n*** End select ***");
                    string a = listViewItems[index1][0];
                    ProxyCore.writeLog("\r\n*** IP2: " + a);
                    while (!flag)
                    {
                        if (ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.CurrentSock).ToInt32() > 0)
                        {
                            string controlText = Vip72Handle.GetControlText(ProxyCore.__currentVip72Handle.GetWindowHandle(Vip72Handle.Vip72Window.Status));
                            b = Vip72Handle.GetControlText(windowHandle2);
                            if (controlText != null)
                            {
                                if (controlText.Contains("checked") && ProxyCore.compare_vip72ip(a, b))
                                {
                                    flag = true;
                                    b    = Vip72Handle.GetControlText(windowHandle2);
                                }
                                else if (controlText.Contains("ERROR") || controlText.Contains("DISCONNECT"))
                                {
                                    flag = true;
                                    b    = (string)null;
                                }
                                else
                                {
                                    Thread.Sleep(200);
                                }
                            }
                            else
                            {
                                flag = true;
                                b    = (string)null;
                            }
                        }
                        else
                        {
                            flag = true;
                            b    = (string)null;
                        }
                    }
                    ProxyCore.__currentVip72Handle.hideWindow();
                    if (b != null)
                    {
                        nextIP = b;
                        return(true);
                    }
                }
                return(false);
            }
            nextIP = (string)null;

            if (ProxyCore.previousSshInfo != null)
            {
                Dictionary <string, object> previousSshInfo = ProxyCore.previousSshInfo;
                LocalConfig.getCurrentConfig().getLiveSSH(ProxyCore.__country, false, GlobalConfig.SSHRefresh);
                ProxyCore.previousSshInfo = (Dictionary <string, object>)null;
                if (previousSshInfo == null)
                {
                    return(false);
                }
                ProxyCore.setupProxy(ProxyCore.__tool, new IndexItem(0, previousSshInfo)
                {
                    hostKeyFp = previousSshInfo["fp"].ToString()
                }, out nextIP);
                GlobalConfig.currentSSH = previousSshInfo;
                return(true);
            }
            Dictionary <string, object> liveSsh = LocalConfig.getCurrentConfig().getLiveSSH(ProxyCore.__country, true, GlobalConfig.SSHRefresh);

            if (liveSsh == null)
            {
                return(false);
            }
            ProxyCore.setupProxy(ProxyCore.__tool, new IndexItem(0, liveSsh)
            {
                hostKeyFp = liveSsh["fp"].ToString()
            }, out nextIP);
            GlobalConfig.currentSSH = liveSsh;
            return(true);
        }
コード例 #2
0
ファイル: ProxyCore.cs プロジェクト: thankhuong/AutoLeadGUI
        private static void changeIP(ProxyTool tool, string country, string region, string preferIp, out string ip)
        {
            if (preferIp != null)
            {
                LocalConfig.getCurrentConfig().refreshLiveSSHs(country);
                ProxyCore.__selectedVip72Index = -1;
                ProxyCore.__selectedVip72IP.Clear();
            }
            ip = (string)null;
            ProxyCore.__preferIp = preferIp;
            ProxyCore.__country  = country;
            ProxyCore.__region   = region;
            ProxyCore.__tool     = tool;
            switch (tool)
            {
            case ProxyTool.Vip72:
                GlobalConfig.currentSSH = (Dictionary <string, object>)null;
                Array array = (Array)LocalConfig.getCurrentConfig().allVip72s().ToArray();
                for (int index1 = 0; index1 < array.Length; ++index1)
                {
                    if (index1 > ProxyCore.__selectedVip72Index)
                    {
                        ProxyCore.__selectedVip72Index = index1;
                        bool   flag = false;
                        string str1 = (string)null;
                        if (ProxyCore.__process == null || ProxyCore.__process.HasExited)
                        {
                            Dictionary <string, object> dictionary = (Dictionary <string, object>)array.GetValue(index1);
                            ProxyCore.handle = new IntPtr(-1);
                            if (ProxyCore.__process != null)
                            {
                                try
                                {
                                    ProxyCore.kill(ProxyCore.__process);
                                }
                                catch
                                {
                                }
                                ProxyCore.__process = (Process)null;
                            }
                            string      str2         = dictionary["username"].ToString();
                            string      str3         = dictionary["password"].ToString();
                            RegistryKey registryKey1 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true);
                            if (registryKey1 != null)
                            {
                                registryKey1.SetValue(GlobalConfig.executableDirectory() + "\\Tools\\vip72socks\\vip72socks.exe", (object)"HIGHDPIAWARE", RegistryValueKind.String);
                                registryKey1.Close();
                            }
                            else
                            {
                                Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
                                RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true);
                                if (registryKey2 != null)
                                {
                                    registryKey2.SetValue(GlobalConfig.executableDirectory() + "\\Tools\\vip72socks\\vip72socks.exe", (object)"HIGHDPIAWARE", RegistryValueKind.String);
                                    registryKey2.Close();
                                }
                            }
                            ProxyCore.__process = Process.Start(new ProcessStartInfo()
                            {
                                WorkingDirectory = GlobalConfig.executableDirectory() + "/Tools/vip72socks",
                                FileName         = GlobalConfig.executableDirectory() + "/Tools/vip72socks/vip72socks.exe",
                                Arguments        = "-login;" + str2 + ":" + str3 + "; -mp:" + (object)LocalConfig.getCurrentConfig().getSSHAndVip72Port()
                            });
                            while (ProxyCore.handle.ToInt32() <= 0)
                            {
                                ProxyCore.handle = ProxyCore.__process.MainWindowHandle;
                                Thread.Sleep(200);
                            }
                            Console.WriteLine((object)ProxyCore.handle);
                            ProxyCore.vip72h = new Vip72Handle(ProxyCore.handle);
                            Thread.Sleep(200);
                            ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.Login);
                            while (!flag)
                            {
                                IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status);
                                if (windowHandle.ToInt32() > 0)
                                {
                                    string controlText = Vip72Handle.GetControlText(windowHandle);
                                    if (controlText.Length > 0)
                                    {
                                        if (controlText.Contains("ERROR") || controlText.Contains("DISCONNECT"))
                                        {
                                            ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.Exit);
                                            str1 = (string)null;
                                            break;
                                        }
                                        if (controlText.Contains("ready"))
                                        {
                                            str1 = Vip72Handle.GetControlText(ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Info));
                                            flag = true;
                                        }
                                    }
                                    Thread.Sleep(200);
                                }
                                else
                                {
                                    str1 = (string)null;
                                    flag = true;
                                }
                            }
                            if (str1 != null)
                            {
                                if (flag)
                                {
                                    ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.SelectCountry);
                                    flag = false;
                                }
                                while (!flag)
                                {
                                    IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status);
                                    if (windowHandle.ToInt32() > 0)
                                    {
                                        string controlText = Vip72Handle.GetControlText(windowHandle);
                                        if (controlText.Length > 0)
                                        {
                                            if (controlText.Contains("ERROR") || controlText.Contains("DISCONNECT"))
                                            {
                                                ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.Exit);
                                                str1 = (string)null;
                                                break;
                                            }
                                            if (controlText.Contains("Total"))
                                            {
                                                str1 = Vip72Handle.GetControlText(ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status));
                                                flag = true;
                                            }
                                        }
                                        Thread.Sleep(200);
                                    }
                                    else
                                    {
                                        str1 = (string)null;
                                        flag = true;
                                    }
                                }
                                if (str1 == null)
                                {
                                    ProxyCore.__process = (Process)null;
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            flag = false;
                            str1 = "Reuse";
                            ProxyCore.__currentVip72Handle.showWindow();
                            ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.SelectCountry);
                            while (!flag)
                            {
                                IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status);
                                if (windowHandle.ToInt32() > 0)
                                {
                                    string controlText = Vip72Handle.GetControlText(windowHandle);
                                    if (controlText.Length > 0)
                                    {
                                        if (controlText.Contains("ERROR") || controlText.Contains("DISCONNECT"))
                                        {
                                            ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.Exit);
                                            str1 = (string)null;
                                            break;
                                        }
                                        if (controlText.Contains("Total"))
                                        {
                                            str1 = Vip72Handle.GetControlText(ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status));
                                            flag = true;
                                        }
                                    }
                                    Thread.Sleep(200);
                                }
                                else
                                {
                                    str1 = (string)null;
                                    flag = true;
                                }
                            }
                            if (str1 == null)
                            {
                                ProxyCore.__process = (Process)null;
                                continue;
                            }
                        }
                        if (flag)
                        {
                            IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.SelectCountryListView);
                            Console.WriteLine(Vip72Handle.GetWindowClassName(windowHandle));
                            int index2 = 0;
                            int num    = 0;
                            List <List <string> > listViewItems1 = Vip72Handle.GetListViewItems(windowHandle);
                            for (int index3 = 0; index3 < listViewItems1.Count; ++index3)
                            {
                                List <string> stringList = listViewItems1[index3];
                                if (stringList[0].Equals(country))
                                {
                                    index2 = index3;
                                    num    = Convert.ToInt32(stringList[1]);
                                    break;
                                }
                            }
                            Vip72Handle.selectListViewItem(windowHandle, index2, true);
                            if (region != null && num > 170)
                            {
                                ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.SelectRegion);
                                IntPtr handle = windowHandle;
                                List <List <string> > listViewItems2;
                                for (listViewItems2 = Vip72Handle.GetListViewItems(handle); listViewItems2.Count == listViewItems1.Count || listViewItems2.Count == 0; listViewItems2 = Vip72Handle.GetListViewItems(handle))
                                {
                                    Thread.Sleep(1000);
                                }
                                for (int index3 = 0; index3 < listViewItems2.Count; ++index3)
                                {
                                    List <string> stringList = listViewItems2[index3];
                                    if (stringList.Count > 0 && stringList[0].Equals(region))
                                    {
                                        Vip72Handle.selectListViewItem(handle, index3, true);
                                        break;
                                    }
                                }
                            }
                            ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.GetProxyByGEO);
                            flag = false;
                        }
                        while (!flag)
                        {
                            IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status);
                            if (windowHandle.ToInt32() > 0)
                            {
                                string controlText = Vip72Handle.GetControlText(windowHandle);
                                if (controlText.Length > 0)
                                {
                                    if (controlText.ToUpper().Contains("ERROR") || controlText.ToUpper().Contains("DISCONNECT"))
                                    {
                                        ProxyCore.vip72h.SendLeftClickToWindow(Vip72Handle.Vip72Window.Exit);
                                        str1 = (string)null;
                                        break;
                                    }
                                    if (controlText.Contains("Ok"))
                                    {
                                        str1 = Vip72Handle.GetControlText(ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status));
                                        flag = true;
                                    }
                                    else if (controlText.Contains("ONLY"))
                                    {
                                        str1 = Vip72Handle.GetControlText(ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.Status));
                                        flag = true;
                                    }
                                }
                                Thread.Sleep(200);
                            }
                            else
                            {
                                str1 = (string)null;
                                flag = true;
                            }
                        }
                        if (str1 != null)
                        {
                            if (!flag)
                            {
                                break;
                            }
                            List <IntPtr>          allChildHandles  = ProxyCore.vip72h.GetAllChildHandles();
                            Vip72Handle.WINDOWINFO childWindowInfo1 = Vip72Handle.GetChildWindowInfo(ProxyCore.handle);
                            for (int index2 = 0; index2 < allChildHandles.Count; ++index2)
                            {
                                IntPtr num1        = allChildHandles[index2];
                                string controlText = Vip72Handle.GetControlText(num1);
                                Vip72Handle.WINDOWINFO childWindowInfo2 = Vip72Handle.GetChildWindowInfo(num1);
                                int num2 = childWindowInfo2.rcWindow.top - childWindowInfo1.rcWindow.top;
                                int num3 = childWindowInfo2.rcWindow.left - childWindowInfo1.rcWindow.left;
                                int num4 = childWindowInfo2.rcWindow.bottom - childWindowInfo2.rcWindow.top;
                                int num5 = childWindowInfo2.rcWindow.right - childWindowInfo2.rcWindow.left;
                                Console.WriteLine("*** [" + Vip72Handle.GetWindowClassName(num1) + "] : " + controlText + " " + (object)num2 + " : " + (object)num3 + " : " + (object)num4 + " : " + (object)num5);
                            }
                            IntPtr windowHandle = ProxyCore.vip72h.GetWindowHandle(Vip72Handle.Vip72Window.AllProxiesListView);
                            Console.WriteLine("All Proxies visible:" + Vip72Handle.IsWindowVisible(windowHandle).ToString());
                            ProxyCore.__vip72ProxiesList = Vip72Handle.GetListViewItems(windowHandle);
                            Thread.Sleep(1000);
                            ProxyCore.__currentVip72Handle = ProxyCore.vip72h;
                            ProxyCore.__allProxiesHandle   = windowHandle;
                            ProxyCore.selectNextIP(preferIp, out ip);
                            AutoLeadClientHelper.reloadNetwork();
                            break;
                        }
                    }
                }
                break;

            case ProxyTool.SSH:
                if (ProxyCore.previousSshInfo != null)
                {
                    Dictionary <string, object> previousSshInfo = ProxyCore.previousSshInfo;
                    LocalConfig.getCurrentConfig().getLiveSSH(ProxyCore.__country, true, GlobalConfig.SSHRefresh);
                    ProxyCore.previousSshInfo = (Dictionary <string, object>)null;
                    if (previousSshInfo == null)
                    {
                        break;
                    }
                    ProxyCore.setupProxy(ProxyCore.__tool, new IndexItem(0, previousSshInfo)
                    {
                        hostKeyFp = previousSshInfo["fp"].ToString()
                    }, out ip);
                    GlobalConfig.currentSSH = previousSshInfo;
                    break;
                }
                Dictionary <string, object> liveSsh = LocalConfig.getCurrentConfig().getLiveSSH(ProxyCore.__country, true, GlobalConfig.SSHRefresh);
                if (liveSsh != null)
                {
                    ProxyCore.setupProxy(ProxyCore.__tool, new IndexItem(0, liveSsh)
                    {
                        hostKeyFp = liveSsh["fp"].ToString()
                    }, out ip);
                    GlobalConfig.currentSSH = liveSsh;
                }
                break;
            }
        }