Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before('set up localtunnel client', function(done) {
var opt = {
host: 'http://localhost:' + lt_server_port,
};
localtunnel(test._fake_port, opt, function(err, tunnel) {
assert.ifError(err);
var url = tunnel.url;
assert.ok(new RegExp('^http:\/\/.*localhost:' + lt_server_port + '$').test(url));
test._fake_url = url;
done(err);
});
});
before('set up localtunnel client', function(done) {
var opt = {
host: 'http://localhost:' + lt_server_port,
};
localtunnel(test._fake_port, opt, function(err, tunnel) {
assert.ifError(err);
var url = tunnel.url;
assert.ok(new RegExp('^http:\/\/.*localhost:' + lt_server_port + '$').test(url));
test._fake_url = url;
done(err);
});
});
test('set up localtunnel client', function(done) {
var opt = {
host: 'http://localhost:' + lt_server_port,
};
localtunnel(test._fake_port, opt, function(err, tunnel) {
assert.ifError(err);
var url = tunnel.url;
assert.ok(new RegExp('^http:\/\/.*localhost:' + lt_server_port + '$').test(url));
test._fake_url = url;
done(err);
});
});
before('set up localtunnel client', function(done) {
var opt = {
host: 'http://localhost:' + lt_server_port,
};
localtunnel(test._fake_port, opt, function(err, tunnel) {
assert.ifError(err);
var url = tunnel.url;
assert.ok(new RegExp('^http:\/\/.*localhost:' + lt_server_port + '$').test(url));
test._fake_url = url;
done(err);
});
});
test('setup browser, server & tunnel', function* () {
yield server.listen.bind(server, 0)
tunnel = yield localtunnel.bind(localtunnel, server.address().port)
tunnel.tunnel_cluster.on('error', function (err) {
if (!err.code || err.code !== 'ETIMEDOUT') {
throw err
}
})
server.url = tunnel.url
yield browser.init(config)
})
function tunnel(port, fn) {
var client = localtunnel.connect({
host: 'http://localtunnel.me',
port: port
});
client.on('url', function(url) {
fn(null, url);
});
return client;
}
function startLocalTunnel() {
const tunnel = localtunnel(3000, {subdomain: 'radioactive-kittens'}, (err, tunnel) => {
console.log(tunnel.url);
})
tunnel.on('close', function() {
console.log('tunnel closed :(');
});
}
return new Promise((resolve, reject) => {
const tunnel = localtunnel(port, (err, {url}) => {
if (err) {
reject({err})
}
resolve({url})
})
this.tunnel = tunnel
})
}
module.exports = function(port, cb) {
debug('tunnel requested to port %d', port);
var client = localtunnel.connect({
host: 'http://localtunnel.me',
port: port
});
client.on('url', function(url) {
cb(null, url);
});
return client;
};