I would like to realize a proof of concept TCP transparent proxy in Vert.x.
A verticle that listens on port X and when somebody connects and sends data it opens a client connection towards a preconfigured TCP server. From this moment until any of the peers closes the connection, a bidirectional channel is kept and data flows up and down the channel from client to server and viceversa.
Here's my attempt which is not working.
vertx.createNetServer().connectHandler(new Handler<NetSocket>() {
public void handle(final NetSocket socket) {
vertx.createNetClient().connect(6367, "localhost", new Handler<NetSocket>() {
@Override
public void handle(NetSocket cliSocket) {
Pump.createPump(socket, cliSocket);
Pump.createPump(cliSocket, socket);
}
});
}
}).listen(3000);
}
At least this is how I understood the meaning of the Pump class:
http://vertx.io/core_manual_java.html#pump
Where's my error?
I just was missing to start the pumps. Then it worked.
Pump.createPump(socket, cliSocket).start();
Pump.createPump(cliSocket, socket).start();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.