TrotiNet
Please note! I longer have time to work on this
project. If you are interested in becoming maintainer, please contact
me.
About TrotiNet
TrotiNet is a HTTP proxy library implemented in C#. It aims at delivering a
simple, reusable framework for developing any sort of HTTP proxies.
TrotiNet is distributed under the GNU Lesser General Public License v3.0.
Download
Latest version is 0.8.0. The precompiled library can be found
here.
Source code is available here.
Usage example
using System;
using TrotiNet;
namespace TrotiNet.Example
{
public class TransparentProxy : ProxyLogic
{
public TransparentProxy(HttpSocket clientSocket)
: base(clientSocket) { }
static new public TransparentProxy CreateProxy(HttpSocket clientSocket)
{
return new TransparentProxy(clientSocket);
}
protected override void OnReceiveRequest()
{
Console.WriteLine("-> " + RequestLine + " from HTTP referer " +
RequestHeaders.Referer);
}
protected override void OnReceiveResponse()
{
Console.WriteLine("<- " + ResponseStatusLine +
" with HTTP Content-Length: " +
(ResponseHeaders.ContentLength ?? 0));
}
}
public static class Example
{
public static void Main()
{
int port = 12345;
bool bUseIPv6 = false;
var Server = new TcpServer(port, bUseIPv6);
Server.Start(TransparentProxy.CreateProxy);
Server.InitListenFinished.WaitOne();
if (Server.InitListenException != null)
throw Server.InitListenException;
while (true)
System.Threading.Thread.Sleep(1000);
//Server.Stop();
}
}
}
More examples may be found in the source code (see
Example/Program.cs
).
Comparison with the Mentalis proxy
In 2002, the Mentalis.org team has released an open-source HTTP proxy,
also written in C#.
We believe TrotiNet is a better alternative because:
- There has been no further development of the Mentalis proxy since
2003.
- The Mentalis proxy has a few severe bugs. In particular, it assumes the
same client connection will always request HTTP resources from the same remote
server, which is incorrect.
- The Mentalis code base relies heavily on asynchronous sequence of calls,
leading to "delegate spaghetti code" that is difficult to maintain and
expand.
- TrotiNet supports IPv6.
On the other hand, TrotiNet does not currently support SOCKS5.
Contact
Contact email is available on github project page.
Like TrotiNet? You can tip bitcoin address
15drGS5JTFi5XRymp9YoccTsaBaAWS3KoT
.