示例#1
0
        private static void ExtractServers(Servers serversInstance, threads threadsInstance, byte[] data)
        {
            if (data == null)
                return;
            String datastr = Encoding.ASCII.GetString(data);

            var seps = new string[1];
            seps[0] = "\\";
            string[] ips = datastr.Split(seps, StringSplitOptions.RemoveEmptyEntries);

            foreach (var s in ips)
            {
                if (s.Length != 6)
                    continue;

                String ip = "";
                ip += ((int)s[0]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[1]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[2]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[3]).ToString(CultureInfo.InvariantCulture);

                int port = (s[4]) * 256 + (s[5]);

                threadsInstance.addServerThread(ip, port, serversInstance);
            }
        }
示例#2
0
        private static void ExtractServers(Servers serversInstance, threads threadsInstance, byte[] data)
        {
            if (data == null)
            {
                return;
            }
            String datastr = Encoding.ASCII.GetString(data);

            var seps = new string[1];

            seps[0] = "\\";
            string[] ips = datastr.Split(seps, StringSplitOptions.RemoveEmptyEntries);

            foreach (var s in ips)
            {
                if (s.Length != 6)
                {
                    continue;
                }

                String ip = "";
                ip += ((int)s[0]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[1]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[2]).ToString(CultureInfo.InvariantCulture) + ".";
                ip += ((int)s[3]).ToString(CultureInfo.InvariantCulture);

                int port = (s[4]) * 256 + (s[5]);

                threadsInstance.addServerThread(ip, port, serversInstance);
            }
        }
示例#3
0
        private void addSingleIPAddressToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var SB = new getStringBox();

            SB.label1.Text = "Enter IP Address:Port";
            SB.ShowDialog();
            String ret = SB.returnvalue;

            if (ret == "")
            {
                return;
            }

            try
            {
                String ip   = ret.Substring(0, ret.IndexOf(':'));
                String port = ret.Substring(ret.IndexOf(':') + 1);

                Server s = threadsInstance.addServerThread(ip, Int32.Parse(port), serversInstance);
                if (s == null)
                {
                    return;
                }

                String kkey = s.getServerIdentifier(Protocol.Protocol.ipAddressSTR, Protocol.Protocol.portSTR);

                try
                {
                    Controller.AddServerToServerView(s, serverview);
                    Controller.UpdateServerInServerView(s, serverview);
                    serverview.SelectedItems.Clear();
                    serverview.Items[kkey].Selected = true;
                    serverview.EnsureVisible(serverview.Items[kkey].Index);
                }
                catch
                {
                    serverview.SelectedItems.Clear();
                    serverview.Items[kkey].Selected = true;
                    serverview.EnsureVisible(serverview.Items[kkey].Index);
                }

                Controller.Refreshselected(serverview, protocolInstance, serversInstance);
            }
            catch
            {
                MessageBox.Show("Error, must be in the format ip:port");
            }
        }