Exemple #1
0
        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);
        }