Beispiel #1
0
        /// <summary>
        /// This part sends the argument to the server and also gives you the option to select
        /// what you want to do. If it's update or lookup.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (lacationform2.UpdateButton == true)
            {
                // the if statement below checks if the debugging features is ticked
                // if that is tick i want to send the arguement to the main program and making debug true


                // if the debug isn't ticked, the debug becomes the default which is false

                string[] argsfromwindowsform = { "-h", m_servername, "-p", m_portnumber, "-t", m_timeout, m_protocol, m_username, m_location };
                Whois.Main(argsfromwindowsform);
                textBox1.Text = Whois.response;
                if (checkBox1.Checked)
                {
                    textBox1.Text = textBox1.Text + "\r\n" + "Debug Feature enabled" + "\r\n" + Whois.debuggingresponse;
                }
            }

            // this method is to send the arguements to the main program if the it's a lookup
            // Also when the debug features is ticked, the debug becomes true and false by default when the server is not tick
            else
            {
                //Whois.clientInfo.Add(tb_username.Text);
                string[] argsfromwindowsform = { "-h", m_servername, "-p", m_portnumber, "-t", m_timeout, m_protocol, m_username };
                Whois.Main(argsfromwindowsform);
                textBox1.Text = Whois.response;

                // if the check box is clicked, enable the debug response.
                if (checkBox1.Checked)
                {
                    textBox1.Text = textBox1.Text + "\r\n" + "Debug Feature enabled" + "\r\n" + Whois.debuggingresponse;
                }
            }
        }
Beispiel #2
0
 private void sendButton_Click(object sender, EventArgs e)
 {
     //These aray gonna contain all the value need to sent to location.cs to process it
     string[] myargs = { "-h", serverNameInput, "-p", portNumberInput, "-t", timeoutInput, debug, protocolInput, userNameInput, locationInput };
     Whois.Main(myargs);                                                       //this send the array of value to the location.cs to WHois protocol
     if (debugCheckBox.Checked)                                                //When debugging options is ticked
     {
         respomseTextBox.Text = Whois.response + "\r\n" + Whois.debugResponse; //Print response with debug response
     }
     else
     {
         respomseTextBox.Text = Whois.response;//The server output
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            string portnumber     = portNumberTextBox.Text.ToString();
            string address        = serverAddressTextBox.Text.ToString();
            string protocolChoice = protocolComboBox.SelectedItem.ToString();
            string user           = userTextBox.Text.ToString();
            string location       = locationTextBox.Text.ToString();
            string timeout        = timeoutTextBox.Text.ToString();

            string finalCommandLineString;

            switch (protocolChoice)
            {
            case "HTTP/0.9":
                protocolChoice         = "-h9";
                finalCommandLineString = "-t" + " " + timeout + " " + "-p" + " " + portnumber + " " + "-h" + " " + address + " " + protocolChoice + " " + user + " " + location;
                break;

            case "HTTP/1.0":
                protocolChoice         = "-h0";
                finalCommandLineString = "-t" + " " + timeout + " " + "-p" + " " + portnumber + " " + "-h" + " " + address + " " + protocolChoice + " " + user + " " + location;
                break;

            case "HTTP/1.1":
                protocolChoice         = "-h1";
                finalCommandLineString = "-t" + " " + timeout + " " + "-p" + " " + portnumber + " " + "-h" + " " + address + " " + protocolChoice + " " + user + " " + location;
                break;

            default:
                finalCommandLineString = "-t" + " " + timeout + " " + "-p" + " " + portnumber + " " + "-h" + " " + address + " " + user + " " + location;
                break;
            }

            string[] commandLineArray = finalCommandLineString.Trim().Split(new char[] { ' ' });

            Whois.setStringFromGUI(commandLineArray);
            this.Close();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            List <string> largs = args.ToList <string>();

            //try
            //{
            if (args.Length > 2)
            {
                int       hIndex = 0, pIndex = 0, gIndex = 0;
                IPAddress nIp = IPAddress.Any;
                foreach (string s in args)
                {
                    if (s == "localhost")
                    {
                        hIndex               = gIndex;
                        settings.IPAddress   = IPAddress.Parse("127.0.0.1").ToString();
                        s_WhoisServerAddress = IPAddress.Parse("127.0.0.1").ToString();
                        largs.Remove(largs.Where(T => T == "-h").FirstOrDefault());
                        largs.Remove(s);
                        continue;
                    }
                    if (s == "-h")
                    {
                        s_WhoisServerAddress = args[args.ToList().IndexOf("-h") + 1];
                    }
                    //s_WhoisServerAddress = args[gIndex+1];
                    foreach (string ss in largs)
                    {
                        args.ToList().Remove(ss);
                    }
                    if (IPAddress.TryParse(args[hIndex], out nIp))
                    {
                        if (!args[hIndex].Contains('.'))
                        {
                            continue;
                        }
                        settings.IPAddress   = args[hIndex - 1];
                        s_WhoisServerAddress = args[hIndex - 1];
                        largs.Remove(largs.Where(T => T == "-h").FirstOrDefault());
                        if (largs[0].Contains('.'))
                        {
                            largs.RemoveAt(0);
                        }

                        break;
                    }
                    if (largs.Contains("-p") && int.TryParse(args[args.ToList().IndexOf("-p") + 1], out PORT))
                    {
                        settings.Port = PORT.ToString();
                        largs.Remove(largs.Where(T => T == "-p").FirstOrDefault());
                        largs.Remove(s);
                    }
                    gIndex++;
                }
            }


            if (args.Contains("-h1"))
            {
                ProtocolType = "h1";
            }
            if (args.Contains("-h0"))
            {
                ProtocolType = "h0";
            }
            if (args.Contains("-h9"))
            {
                ProtocolType = "h9";
            }
            largs.Remove("-h1");
            largs.Remove("-h0");
            largs.Remove("-h9");
            largs.Remove("-h");
            largs.Remove("-p");
            largs.Remove(settings.Port);
            largs.Remove(s_WhoisServerAddress);

            string loc = "";

            if (largs.Count >= 2)
            {
                for (int i = 1; i < largs.Count; i++)
                {
                    loc += (largs[i] + ' ');
                }
            }
            foreach (string s in loc.Split(' '))
            {
                largs.Remove(s);
            }
            //if (loc != "")
            //    largs.Add(loc);
            switch (largs.Count)
            {
            case 1:
                switch (ProtocolType)
                {
                case "WHOIS":
                    if (Whois.bConnectToServer())
                    {
                        Whois.bLookupName(largs[0]);
                    }
                    break;

                case "h9":
                    if (Http09.bConnectToServer())
                    {
                        Http09.bLookupName(largs[0]);
                    }
                    break;

                case "h0":
                    if (Http10.bConnectToServer())
                    {
                        Http10.bLookupName(largs[0]);
                    }
                    break;

                case "h1":
                    if (Http11.bConnectToServer())
                    {
                        Http11.bLookupName(largs[0]);
                    }
                    break;
                }
                break;

            case 2:
                switch (ProtocolType)
                {
                case "WHOIS":
                    if (Whois.bConnectToServer())
                    {
                        Whois.bChangeLocation(largs[0], loc);
                    }
                    break;

                case "h9":
                    if (Http09.bConnectToServer())
                    {
                        Http09.bChangeLocation(largs[0], loc);
                    }
                    break;

                case "h0":
                    if (Http10.bConnectToServer())
                    {
                        Http10.bChangeLocation(largs[0], loc);
                    }
                    break;

                case "h1":
                    if (Http11.bConnectToServer())
                    {
                        Http11.bChangeLocation(largs[0], loc);
                    }
                    break;
                }
                break;
            }
            //}
            //catch (Exception er)
            //{
            //    throw er;
            //    Console.WriteLine($"Error: {er.Message}");
            //    return;
            //}
            Console.ReadLine();
        }