예제 #1
0
    private static bool smethod_1(Socket socket_1, out string string_0, out byte[] byte_0)
    {
        string_0 = null;
        byte_0   = null;
        byte[] array = new byte[8192];
        int    num   = 0;
        int    num2  = 8192;

        while (num2 != 0)
        {
            int num3 = num;
            int num4 = socket_1.Receive(array, num, num2, SocketFlags.None);
            if (num4 == 0)
            {
                return(false);
            }
            num  += num4;
            num2 -= num4;
            int num5;
            if (array.smethod_0(Math.Max(0, num3 - 3), num, out num5))
            {
                string_0 = Encoding.ASCII.GetString(array, 0, num5);
                if (num != num5)
                {
                    int num6 = num - num5;
                    byte_0 = new byte[num6];
                    Array.Copy(array, num5, byte_0, 0, num6);
                }
                return(true);
            }
        }
        GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483648), "HTTP/1.1 ");
        return(false);
    }
예제 #2
0
    private static bool smethod_0(Socket socket_1, out string string_0, out int int_1, out string string_1, out bool bool_1, out string string_2, out byte[] byte_0)
    {
        string_0 = null;
        int_1    = -1;
        string_1 = null;
        bool_1   = false;
        string_2 = null;
        string text;

        if (!GClass123.smethod_1(socket_1, out text, out byte_0))
        {
            return(false);
        }
        List <string> list = text.Split(new char[]
        {
            '\n'
        }).Select(new Func <string, string>(GClass123.< > c.< > c_0.method_1)).Where(new Func <string, bool>(GClass123.< > c.< > c_0.method_2)).ToList <string>();

        string[] array = list[0].Split(new char[]
        {
            ' '
        });
        if (array.Length != 3)
        {
            GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483648), "HTTP/1.1 ");
            return(false);
        }
        string text2 = array[0];

        string_1 = array[2].Trim() + " ";
        bool_1   = text2.Equals("Connect", StringComparison.OrdinalIgnoreCase);
        string text3 = null;

        if (bool_1)
        {
            using (List <string> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string text4 = enumerator.Current;
                    int    num   = text4.IndexOf(':');
                    if (num == -1)
                    {
                        GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483648), string_1);
                        return(false);
                    }
                    if (text4.Substring(0, num).Trim().Equals("Host", StringComparison.OrdinalIgnoreCase))
                    {
                        text3 = text4.Substring(num + 1).Trim();
                        break;
                    }
                }
                goto IL_2B1;
            }
            bool result;
            return(result);
        }
        Uri           uri           = new Uri(array[1]);
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.Append(array[0]);
        stringBuilder.Append(' ');
        stringBuilder.Append(uri.PathAndQuery);
        stringBuilder.Append(uri.Fragment);
        stringBuilder.Append(' ');
        stringBuilder.Append(array[2]);
        for (int i = 1; i < list.Count; i++)
        {
            int num2 = list[i].IndexOf(':');
            if (num2 != -1)
            {
                string text5 = list[i].Substring(0, num2).Trim();
                if (text5.Equals("Host", StringComparison.OrdinalIgnoreCase))
                {
                    text3 = list[i].Substring(num2 + 1).Trim();
                    stringBuilder.Append("\r\n");
                    stringBuilder.Append(list[i]);
                }
                else if (!text5.smethod_1())
                {
                    stringBuilder.Append("\r\n");
                    stringBuilder.Append(list[i]);
                }
            }
        }
        if (text3 == null)
        {
            stringBuilder.Append("\r\nHost: ");
            stringBuilder.Append(uri.Host);
        }
        stringBuilder.Append("\r\n\r\n");
        string_2 = stringBuilder.ToString();
IL_2B1:
        int_1 = (bool_1 ? 443 : 80);
        if (string.IsNullOrEmpty(text3))
        {
            string text6 = array[1];
            string_0 = text6;
            int num3 = text6.LastIndexOf(':');
            if (num3 != -1)
            {
                if (int.TryParse(text6.Substring(num3 + 1), out int_1))
                {
                    string_0 = text6.Substring(0, num3);
                }
                else
                {
                    int_1 = (bool_1 ? 443 : 80);
                }
            }
        }
        else
        {
            int num4 = text3.LastIndexOf(':');
            if (num4 == -1)
            {
                string_0 = text3;
                string text7 = array[1];
                num4 = text7.LastIndexOf(':');
                if (num4 != -1 && !int.TryParse(text7.Substring(num4 + 1), out int_1))
                {
                    int_1 = (bool_1 ? 443 : 80);
                }
            }
            else
            {
                string_0 = text3.Substring(0, num4);
                if (!int.TryParse(text3.Substring(num4 + 1), out int_1))
                {
                    int_1 = (bool_1 ? 443 : 80);
                }
            }
        }
        return(true);
    }
예제 #3
0
    private void method_5(Socket socket_1)
    {
        Socket socket = null;
        bool   flag   = true;

        try
        {
            string string_;
            int    num;
            string text;
            bool   flag2;
            string string_2;
            byte[] array;
            if (GClass123.smethod_0(socket_1, out string_, out num, out text, out flag2, out string_2, out array))
            {
                try
                {
                    socket = GClass123.smethod_4();
                    socket.Connect(this.proxySettings_0[0].Host, this.proxySettings_0[0].Port);
                }
                catch (SocketException)
                {
                    GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483644), "HTTP/1.1 ");
                    flag = false;
                }
                catch (Exception)
                {
                    GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483647), "HTTP/1.1 ");
                    flag = false;
                }
                if (flag)
                {
                    int i = 0;
                    while (i < this.proxySettings_0.Length - 1)
                    {
                        ProxySettings    proxySettings  = this.proxySettings_0[i];
                        ProxySettings    proxySettings2 = this.proxySettings_0[i + 1];
                        GClass123.GEnum7 genum          = GClass123.Class3.smethod_0(socket, proxySettings2.Host, proxySettings2.Port, proxySettings);
                        if (genum == (GClass123.GEnum7) 0)
                        {
                            i++;
                        }
                        else
                        {
                            GClass123.smethod_3(socket_1, genum, text);
                            flag = false;
IL_CE:
                            if (!flag)
                            {
                                goto IL_12E;
                            }
                            ProxySettings proxySettings3 = this.proxySettings_0.Last <ProxySettings>();
                            genum = GClass123.Class3.smethod_0(socket, string_, num, proxySettings3);
                            if (genum != (GClass123.GEnum7) 0)
                            {
                                GClass123.smethod_3(socket_1, genum, text);
                                flag = false;
                                goto IL_12E;
                            }
                            if (flag2)
                            {
                                GClass123.smethod_2(socket_1, text + "200 Connection established\r\nProxy-Agent: HttpToSocksProxy\r\n\r\n");
                                goto IL_12E;
                            }
                            GClass123.smethod_2(socket, string_2);
                            if (array != null)
                            {
                                socket.Send(array, SocketFlags.None);
                                goto IL_12E;
                            }
                            goto IL_12E;
                        }
                    }
                    goto IL_CE;
                }
            }
            else
            {
                flag = false;
            }
            IL_12E :;
        }
        catch
        {
            flag = false;
            try
            {
                GClass123.smethod_3(socket_1, (GClass123.GEnum7)(-2147483647), "HTTP/1.1 ");
            }
            catch
            {
            }
        }
        finally
        {
            if (flag)
            {
                GClass123.Class2.smethod_1(socket, socket_1);
            }
            else
            {
                socket_1.smethod_3();
                socket.smethod_3();
            }
        }
    }