Reputation: 129
I'm developing a VB.NET server application which allows clients to connect, exchange some data with the server, process them and finally give them back a result. To achieve this I'm using a classic TcpListener like:
Dim server As TcpListener = New TcpListener(PORT)
server.Start()
which waits for pending TcpClient incoming connections with:
Do
If server.Pending() Then
'accept TcpClient connections
'get its Stream
'read from it
'do stuff
'write response
End If
Loop
This simply works with the server's public IP. But what if I want to hide this service behind a different one? I'm thinking about using the Tor network but according to what I've learned so far, I can make it work only using some Web requests, but that's not what I want. I don't want to use the HTTP protocol, but a protocol developed on my own.
So, is there a way to use Tor to route a traffic different from the Web requests?
EDIT: I didn't write that I don't want the clients to use Tor to connect to my server. My bad.
Upvotes: 1
Views: 681
Reputation: 11789
Yes, both of those things are possible.
First, you can use Tor for other protocols besides HTTP - Tor is used for HTTPS, chat, IRC, and even torrents (although latter not recommended). It can tunnel any TCP protocol, as it doesn't look into payload.
Second, you can listen and receive requests on Tor IP address, this is called "hidden service". The way it works, you set up the hidden service configuration in Tor config file. It could look like:
HiddenServiceDir /var/lib/tor/other_hidden_service/
HiddenServicePort 80 127.0.0.1:4567
HiddenServicePort directive here specifies that Tor hidden service would "listen" on port 80, and will redirect any successful connections to 127.0.0.1:4567 - so you can run your TcpListener on localhost, port 4567 - or any other port - and receive Tor communication.
EDIT: a Tor hidden service can only serve the Tor clients. Thus you can do one of the following:
Set up a "Tor forwarder" for your service, which would receive a connection on a public IP, and redirect it to a Tor hidden service. This would have to run Tor, of course, but your users wouldn't have to.
Not use Tor and set up some transparent TCP port redirector; google "TCP port forwarding application".
Upvotes: 1