This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const net = require('net'); | |
const LOCAL_PORT = 7358; | |
const REMOTE_PORT = 7357; | |
const REMOTE_ADDR = 'localhost'; | |
const server = net.createServer(function (clientSocket) { | |
const serviceSocket = new net.Socket(); | |
serviceSocket.connect(parseInt(REMOTE_PORT), REMOTE_ADDR, function () { | |
clientSocket.pipe(serviceSocket); | |
serviceSocket.pipe(clientSocket); | |
serviceSocket.on('data', function (data) { | |
const parts = data.toString('binary').split(/\0/); | |
if (parts.length < 1) return; | |
if (parts[0] !== '1') return; | |
process.stdout.write(parts.join(' : ') + '\n\n'); | |
}); | |
}); | |
}); | |
server.listen(LOCAL_PORT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment