echo tcp
This commit is contained in:
parent
65b77f994a
commit
a5d3576ab6
|
@ -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 + "'");
|
||||
|
|
Loading…
Reference in New Issue