node.jsサーバーが受信したトラフィックをTLS接続にトンネルしようとしています。私はそれを実行し、それをテストするとき、私は私の端末でこれを参照してください、Node.jsでTLSトンネルを作成する方法
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);
}
::私はData received from client
を参照して、サーバコンソールで
$ curl --insecure https://myhost:443
hello world
$ curl --insecure https://localhost:7000
# nothing... just hangs
、決してconnect
コールバック私はこのようないくつかのコードを持っています。
私は適切なトラックにいますか?サーバーのconnection
イベントハンドラ(あなたがcreateServer()
に渡すコールバック)に渡さ