Search code examples
c#proxypactitanium-web-proxy

Titanium Web Proxy : How to run it only for one specific domain


I tried Titanium C# Web Prox, and I am very happy with it. The only point is about to know how can I configure the Web Proxy to handle only web traffic that concerns a specific domain, let say contoso.org. In fact, this custom web proxy is created only to manage related traffic to this domain, and does not have to handle the web request from other domains.

I saw that an ExplicitEndpoint is configured and applied to SystemHttpsProxy on the windows internet options, but I didnt find any options to apply it only to my domain, contoso.org

  1. Is there a way by C# config on Titanium library to configure this behaviour ?
  2. If not possible by C#, maybe another way ? I tried to deal with PAC file on Internet Options, but it's seems to not working, maybe I did it wrong. Or any other solutions ?

Thanks a lot.


Solution

  • If i understand well you want to capture the traffic to specific domain. You could try this:

    explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true);
    explicitEndPoint.BeforeTunnelConnectRequest += ExplicitEndPoint_BeforeTunnelConnectRequest;
    proxyServer.AddEndPoint(explicitEndPoint);            
    
    private Task ExplicitEndPoint_BeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
    {
         var hostName = e.HttpClient.Request.RequestUri.Host;
         if (!hostName.Contains("contoso.org"))
         {
            e.DecryptSsl = false;
         }
    
         return Task.CompletedTask;
    }