Ich versuche den von meinem node.js-Server empfangenen Verkehr zu einer TLS-Verbindung zu tunneln. Ich habe einige Code wie folgt aus:So erstellen Sie einen TLS-Tunnel in Node.js
function tunnel() {
var c = tls.connect(443, 'myhost', {rejectUnauthorized: false});
var server = net.createServer(function (socket) {
socket.addListener("connect", function() {
console.log("Connection from " + socket.remoteAddress);
//sync the file descriptors, so that the socket data structures are the same
c.fd = socket.fd;
//pipe the incoming data from the client directly onto the server
c.pipe(socket);
//and the response from the server back to the client
socket.pipe(c);
});
socket.addListener("data", function (data) {
console.log("Data received from client");
});
socket.addListener("close", function() {
server.close();
});
});
server.listen(7000);
}
Wenn ich es laufen und testen Sie es, ich sehe in meinem Terminal:
$ curl --insecure https://myhost:443
hello world
$ curl --insecure https://localhost:7000
# nothing... just hangs
In der Server-Konsole, ich sehe Data received from client
, aber nie die connect
Rückruf .
Bin ich auf dem richtigen Weg?