Titanium Web Proxy

Okay so the best way to install a web proxy in windows is, we suppose, within a windows service. So we made such in Visual Studio’s perfect IDE programming C# symptoms. And it works.
Then we installed github nuget titanium web proxy and initiated it according to its installation instruction on project page. But apparently it doesn’t intercept any internet requests yet. Why?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.EventArguments;

namespace WebProxy1{
    public partial class MyNewService : ServiceBase {
        public ProxyServer proxyServer;

        public MyNewService() {
            InitializeComponent();
        }

        protected override void OnStart(string[] args) {
            proxyServer = new ProxyServer(true, true, true);

            proxyServer.BeforeRequest += OnRequest;

            proxyServer.Start();

            WriteToFile("Service is started at " + DateTime.Now);

        }

        protected override void OnStop() {
            proxyServer.Stop();
            WriteToFile("Service is stopped at " + DateTime.Now);
        }
        public void WriteToFile(string Message) {
            string path = "E:\\Downloads\\Logs";
            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }
            string filepath = "E:\\Downloads\\Logs\\ServiceLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".txt";
            if (!File.Exists(filepath)) {
                // Create a file to write to.   
                using (StreamWriter sw = File.CreateText(filepath)) {
                    sw.WriteLine(Message);
                }
            } else {
                using (StreamWriter sw = File.AppendText(filepath)) {
                    sw.WriteLine(Message);
                }
            }
        }

        public async Task OnRequest(object sender, SessionEventArgs e) {
            WriteToFile(e.HttpClient.Request.Url);

            // To cancel a request with a custom HTML content
            // Filter URL
            if (e.HttpClient.Request.Method.ToUpper() == "GET" && e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("google.com")) {
                e.Ok("<!DOCTYPE html>" +
                    "<html><body><h1>" +
                    "Website Blocked" +
                    "</h1>" +
                    "<p>Blocked by titanium web proxy.</p>" +
                    "</body>" +
                    "</html>");
            }

            // Redirect example
            if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org")) {
                e.Redirect("https://www.paypal.com");
            }
        }
    }
}

Thanks for joining the community.

If you’re asking how to use the piece of software that you found in a repository on GitHub, specifically https://github.com/justcoding121/Titanium-Web-Proxy I suspect, the best way to contact the maintainers of that software is to:

  1. Check the README for instructions on how to operate the software, pointers to documentation or troubleshooting info.
  2. Check the SUPPORT file, if one exists for instructions on how to best contact the maintainers for support.
  3. Check the CONTRIBUTING guide, if one exists. Sometimes if there isn’t a SUPPORT file, the CONTRIBUTING guide will give instructions on how to contact the maintainers for support.

All of these documents can be found, if they exist, in the repository where you found the software itself.

I hope that helps!