Hot to use tunnel
Tunnel is a small utility program to expose a client's port on a certain server's port, useful when client doesn't have direct access to internet while the server has and the client can connect to server.
Server configuration
write a server.json
, the content resemble the following structure:
public class Server
{
public int port; // the port to listen to client's tunnelling request
public Dictionary<string, string> safe; // key: service name, value: port configuration..
}
safe's key is to distinguish different client, for example, you can use the following json:
{
"port":30194,
{ "agv":"40000~41000" , "manager":"50000"}
}
this will map "agv" service into 40000~41000 port ( actual port number should view in client ), "manager" service into 50000.
you put the json into the same folder as tunnel.exe, just run it. if on linux, you can use mono tunnel.exe
.
Client configuration
a client configuration is like:
public class Client
{
public string validate;
public string proxy;
public string destination;
}
validate
is "agv"/"manager" in above mentioned example configuration, indicating the service name you want to use. proxy
is the server's ip and port, like 192.168.0.1:30194
. destination
is the IP:port should be tunnelled from the client, like 127.0.0.1:4321
.
you put the json into the same folder as tunnel.exe, just run it. if on linux, you can use mono tunnel.exe
.
Effect
for the above example, let's assume the server has Internet IP address 123.45.6.7, and client's using "manager" as validate
. Then the port 4321 on client computer can be accessed from Internet via 123.45.6.7:50000