سلام اگه ip و port رو برای کانکشنتون به صورت 127.0.0.1:8080 تنظیم کنید هر آدرسی که تو IE بنویسید رو میگیره ولی برای RESPONSE کردن چون پ-ر-و-ک-س-ی وجود داره گیر میکنه.خودم فک میکنم برای اینکه نرم افزارم کار کنه باید دوتا کامپیوتر به اینترنت وصل باشن و به همدیگه هم متصل باشن نرم افزار من باید آدرس سایت رو از کامپیوتر 1(پ-ر-و-ک-س-ی داره) بگیره و بفرسته به کامپیوتر 2 که پ-ر-و-ک-س-ی نداره و اطلاعات دریافت شده رو برگردونه به کامپیوتر 1 ،یعنی کامپیوتر 2 مثل سرور عمل کنه.دقیقا شبیه ف-ی-ل-ت-ر ایران
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Threading;
using System.IO;
using System.Reflection;
using System.Collections.Specialized;
using System.Collections;
using Microsoft.Win32;
namespace hproxy
{
class Program
{
static void Main(string[] args)
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add("http://*:8080/");
listener.Start();
Console.WriteLine("Listening...");
for (; ; )
{
HttpListenerContext ctx = listener.GetContext();
new Thread(new Worker(ctx).ProcessRequest).Start();
}
}
class Worker
{
private HttpListenerContext context;
public Worker(HttpListenerContext context)
{
this.context = context;
}
public void ProcessRequest()
{
string msg = context.Request.HttpMethod + " " + context.Request.Url;
string url = context.Request.RawUrl;
Console.WriteLine(msg);
Console.WriteLine("url: " + url);
StringBuilder sb = new StringBuilder();
if (context.Request.Url.ToString().Contains("red") == true)
{
sb.Append("<html><body><h1>" + "site shoma filter shod" + "</h1>");
sb.Append("</body></html>");
}
else
{
/*WebRequest wer; in ghesmat ro az ye site gereftam ke neveshte bod mishe request ro ba proxy ham javab dad vali kar nemikoneh
wer = WebRequest.Create(url);
wer.Proxy = WebProxy.GetDefaultProxy();
Stream objstream = wer.GetResponse().GetResponseStream();
StreamReader reader = new StreamReader(objstream);
string sLine = "";
sLine = reader.ReadLine();
Console.WriteLine(sLine);*/
}
byte[] b = Encoding.UTF8.GetBytes(sb.ToString());
context.Response.ContentLength64 = b.Length ;
context.Response.OutputStream.Write(b, 0, b.Length);
context.Response.OutputStream.Close();
}
}
}
}