transform Host header when local-host is defined explicitly

This commit is contained in:
Tymoteusz Paszun
2014-05-09 15:07:38 +02:00
parent 8768329fdd
commit 828cb2afcb
3 changed files with 53 additions and 8 deletions

View File

@@ -60,7 +60,7 @@ TunnelCluster.prototype.open = function() {
var remote_host = opt.remote_host;
var remote_port = opt.remote_port;
var local_host = opt.local_host;
var local_host = opt.local_host || 'localhost';
var local_port = opt.local_port;
debug('establishing tunnel %s:%s <> %s:%s', local_host, local_port, remote_host, remote_port);
@@ -133,10 +133,11 @@ TunnelCluster.prototype.open = function() {
var stream = remote;
// if user requested something other than localhost
// if user requested specific local host
// then we use host header transform to replace the host header
if (local_host !== 'localhost') {
stream = remote.pipe(HeaderHostTransformer({ host: local_host }));
if (opt.local_host) {
debug('transform Host header to %s', opt.local_host);
stream = remote.pipe(HeaderHostTransformer({ host: opt.local_host }));
}
stream.pipe(local).pipe(remote);
@@ -224,7 +225,7 @@ Tunnel.prototype._establish = function(info) {
var self = this;
var opt = self._opt;
info.local_host = opt.local_host || 'localhost';
info.local_host = opt.local_host;
info.local_port = opt.port;
var tunnels = self.tunnel_cluster = TunnelCluster(info);