!! query mechanism !@#$ !!

Started by EK.IceFlake, Jul 04, 2016, 07:28 AM

Previous topic - Next topic

EK.IceFlake

query mechanism f*ing me up lately
public void Remaster()
        {
            listView1.Items.Clear();
            browser.Log(_INFO, "Querying masterlist for all listed servers");
            browser.Log(_INFO, "Adding servers to display");
            dynamic sdata = Serverdata.ParseJson(Masterl.StartDownload());
            for (int i = 0; i < sdata.Count; ++i)
            {
                dynamic item = sdata[i];
                browser.Log(_INFO, "Load " + item.ip + ", " + item.port + "... ", false);
                Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                s.SendTimeout = 15000;
                s.ReceiveTimeout = 15000;
                IPAddress xip = IPAddress.Parse(item.ip.ToString());
                IPEndPoint ep = new IPEndPoint(xip, Convert.ToInt32(item.port.ToString()));
                try
                {
                    Byte[] magic = Encoding.UTF8.GetBytes("VCMP");
                    string[] array = xip.ToString().Split('.');
                    Byte[] port = Encoding.ASCII.GetBytes(item.port.ToString());
                    /*Byte[] port = new byte[2]
                    {
                        (byte)Convert.ToInt32(item.port.ToString()),
                        (byte)(i >> 8)
                    };*/
                    Byte[] ipa1 = Encoding.UTF8.GetBytes(array[0]);
                    Byte[] ipa2 = Encoding.UTF8.GetBytes(array[1]);
                    Byte[] ipa3 = Encoding.UTF8.GetBytes(array[2]);
                    Byte[] ipa4 = Encoding.UTF8.GetBytes(array[3]);
                    Byte[] opcode = Encoding.UTF8.GetBytes("i");
                    Byte[] evsig = Encoding.UTF8.GetBytes("EVSI");
                    MemoryStream outs = new MemoryStream();
                    outs.Write(magic, 0, 4);
                    outs.Write(ipa1, 0, 1);
                    outs.Write(ipa2, 0, 1);
                    outs.Write(ipa3, 0, 1);
                    outs.Write(ipa4, 0, 1);
                    outs.Write(port, 0, 1);
                    outs.Write(opcode, 0, 1);
                    outs.Write(evsig, 0, 1);
                    Byte[] outarray = outs.ToArray();
                    s.SendTo(outarray, outarray.Length, SocketFlags.None, ep);
                    Byte[] recd = new byte[15];
                    s.Receive(recd);
                    string recv = Encoding.ASCII.GetString(recd);
                    browser.Log(_INFO, "Receive: " + recv);
                }
                catch (Exception e)
                {
                    browser.Log("");
                    browser.Log(_ERROR, e.ToString());
                    browser.Log(_WARN, "Failed load " + item.ip + ", " + item.port);
                }
                s.Close();
                //udpclient.Close();

                ListViewItem litem = new ListViewItem();
                litem.Text = "Temporarily unavailable";
                ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem();
                subitem.Text = item.ip + ":" + item.port;
                litem.SubItems.Add(subitem);
                ListViewItem.ListViewSubItem subitemt = new ListViewItem.ListViewSubItem();
                subitemt.Text = "T.UA";
                litem.SubItems.Add(subitemt);
                ListViewItem.ListViewSubItem subitemtt = new ListViewItem.ListViewSubItem();
                subitemtt.Text = "T.UA";
                litem.SubItems.Add(subitemtt);
                ListViewItem.ListViewSubItem subitemttt = new ListViewItem.ListViewSubItem();
                subitemttt.Text = "T.UA";
                litem.SubItems.Add(subitemttt);
                ListViewItem.ListViewSubItem subitemtttt = new ListViewItem.ListViewSubItem();
                subitemtttt.Text = "T.UAs";
                litem.SubItems.Add(subitemtttt);
                listView1.Items.Add(litem);
                //browser.Log("OK");
            }
this shit isn't working at all ive also tried to use raw bytes for ip + port that didn't work too so I thought to try it how George has did it (memory stream) and still no luck
it always fails and says 'the connecting party did not respond after a ...'
pl0x help :(
also its not about some bug in the master server because that part works perfectly
@Stormeus @maxorator @George @ysc3839

ysc3839

I don't know C#. It's your responsibility to study C#. And you shouldn't filled the page up with :-[.

EK.IceFlake

Quote from: ysc3839 on Jul 04, 2016, 12:37 PMI don't know C#. It's your responsibility to study C#. And you shouldn't filled the page up with :-[.
that was my style of bump :D

Thijn

Did you really dump your topic after only 4 hours?

Anyways. You gave no explanation what-so-ever about what's not working and what is. You're just pasting a piece of code asking us to do some magic and make it work.

The other party didn't respond probably means you're not actually properly connecting. Try hex dumping your sending data to take a look what you're sending.

EK.IceFlake

Well I managed to solve it myself by rewriting it from scratch and with a different method. You can observe the new code when I release my new browser.