witajcie kochani,
chcialem odpalic proxy web titanium paczka Titanium.Web.Proxy. Najnowsza dostępna a wersja 3.0.213.
static void Main(string[] args)
{
var proxyServer = new ProxyServer();
proxyServer.TrustRootCertificate = true;
proxyServer.BeforeRequest += ProxyServer_BeforeRequestAsync;
var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true);
//An explicit endpoint is where the client knows about the existence of a proxy
proxyServer.AddEndPoint(explicitEndPoint);
proxyServer.Start();
foreach (var endPoint in proxyServer.ProxyEndPoints)
Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ",
endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);
proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
//wait here (You can use something else as a wait function, I am using this as a demo)
Console.ReadLine();
proxyServer.BeforeRequest -= ProxyServer_BeforeRequestAsync;
proxyServer.DisableSystemHttpProxy();
proxyServer.DisableSystemHttpsProxy();
proxyServer.Stop();
}
private static async Task ProxyServer_BeforeRequestAsync(object sender, SessionEventArgs e)
{
Console.WriteLine(e.WebSession.Request.Url);
if (e.WebSession.Request.RequestUri.AbsoluteUri.Contains("google.com"))
{
await e.Ok("<!DOCTYPE html><html><body><h1>Website is blocked.</h1></body></html>", null);
}
}
jak uzyskac w Form1 cos takiego, a nie w konsoli, aby po wpisaniu do textbox'a i uzyciu przycisku button blokowalo dany adres?
jak ten kod przeksztalcic? dziekuje za pomoc!!!