Esempio n. 1
0
        async Task MainBodyAsync(MHttpStream localStream)
        {
            try
            {
                while (true)
                {
                    MHttpRequest request = await MHttpRequest.ReadAsync(localStream, m_info.MaxContentSize).ConfigureAwait(false);

                    var sendFunc = CreateSendFunc(request);

                    if (request.Path.IndexOf("view_video.php?viewkey") != -1)
                    {
                        await GetSeleteHtmlAsync(sendFunc, localStream).ConfigureAwait(false);
                    }
                    else
                    {
                        await GetOneHtmlAsync(sendFunc, localStream).ConfigureAwait(false);
                    }
                }
            }
            finally
            {
                localStream?.Close();
            }
        }
Esempio n. 2
0
        static void ReadConnectRequest(Socket socket, Func <string, TunnelPackAction> func)
        {
            Task.Run(async() =>
            {
                Stream stream = new NetworkStream(socket, true);

                MHttpStream httpStream = new MHttpStream(socket, stream, 1024);


                MHttpRequest request = await MHttpRequest.ReadAsync(httpStream, 1024 * 1024).ConfigureAwait(false);

                MHttpResponse response = MHttpResponse.Create(200);


                await response.SendAsync(httpStream).ConfigureAwait(false);

                Uri uri = new Uri($"http://{request.Path}/");

                func(uri.Host)(uri, new TunnelPack(socket, stream));
            });
        }