This commit is contained in:
AJ ONeal 2018-06-01 03:50:27 -06:00
parent 588373e044
commit 4658fa88c6
1 changed files with 25 additions and 1 deletions

View File

@ -120,6 +120,27 @@ module.exports.assign = function (state, tun, cb) {
return conn;
}
function echoTcp(cb) {
var socketPair = require('socket-pair');
var conn = socketPair.create(function (err, other) {
if (err) { cb(err); return; }
other.on('data', function (chunk) {
other.write(chunk);
});
other.on('end', function () {
other.end();
});
cb(null, conn);
other.write("[Telebit Echo Server] v1.0\nPlease edit your config file to port forward somewhere more useful.\n\n");
});
//if (tun.data) { conn.write(tun.data); }
return conn;
}
function defineProps(other, tun) {
Object.defineProperty(other, 'remoteFamily', {
enumerable: false,
@ -316,8 +337,11 @@ module.exports.assign = function (state, tun, cb) {
if ('tcp' === tun.service) {
trySsh(tun, function (err, conn) {
if (conn) { cb(null, conn); return; }
cb(new Error("No TCP handler"));
// TODO add TCP handlers
console.log('Using echo server for tcp');
echoTcp(cb);
});
return;
}
console.warn("Unknown service '" + tun.service + "'");