Implementing a generic TCP/IP socket proxy in ASP.NET
I frequently work in places where I only have access to the internet via a HTTP proxy. E-mail protocols like SMTP, POP3 and IMAP 4 are not proxyable via http (normally) so I download mails via GPRS/UMTS when needed. The problem is that it costs a fortune when someone sends you a gigantic .ZIP file.
I got fed up by wasting time and money this way so I implemented a simple ASP.NET based solution than can proxy any tcp/ip socket via http/https. You can find the binaries, as well as the source code, in the downloads section. I have been dogfooding the last few days, adding features as I need them. The tool is pretty basic but it does what I need:
- it runs as a windows form or a toolbar icon
- it supports an optional upstream http proxy
- all traffic is encrypted with https
- it handles all tcp/ip socket based protocols I have tried so far: smtp, pop3, http, https, Microsoft Terminal Services.(mstsc is slower, but it works like a charm via a https proxy for emergency purposes)
I hope the code is understandable even if it is fruit of late night coding sessions while I am on a tight deadline for not one, but two, releases in the middle of the night next week. Releasing solutions based on Java 1.5/Tomcat 5.5 and .NET/Win2k3 in the same week keeps life -busy- but interesting. At least I learn something new every day. There are a lot of possible improvements like automatically importing the proxy settings from the default browser and adding authentication support but I don't need them (yet)
I've installed your solution on my home system and it works great. One tuning that I suggest to have a good performance for high traffic protocols (like Terminal Server many small packets in stream) is to disable the logging of the virtual directory in which the server part is put.ReplyDelete
Now I have a nice feedback of terminal server over socket proxy.
Most of the hits are to proxy.aspx so you can disable logging to that file only if you want to keep trace of who uses the tunnel.
I have added basic http authentication to the client and I hope to upload the new code tonight.