Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ngrokify (server) {
if (typeof server === 'function') server = http.createServer(server)
// let ngroked = Object.create(server)
let ngrokURL
server.once('close', function () {
console.log('Closing time :)')
ngrokURL && ngrok.disconnect(ngrokURL)
})
let addr = server.address()
if (!addr) server.listen(0)
addr = server.address()
console.log('Using Port ' + addr.port)
return ngrok.connect(addr.port).then(function (url) {
ngrokURL = url
return url
})
}
module.exports = ngrokify
cp.kill('SIGTERM');
cp = createProcess();
});
const useTypeScript = false; // FIXME
if (useTypeScript) {
// watch js and run cp
// watch ts and compile to dist
} else {
// watch all and run cp
}
if (!isConsole) {
const url = await ngrok.connect(port);
Object.entries(channels || {})
.filter(([, { enabled }]) => enabled)
.forEach(([channel, { path: webhookPath }]) => {
const routePath = webhookPath || `/webhooks/${channel}`;
console.log(`${channel} webhook url: ${url}${routePath}`);
});
}
};
srv.listen(function(){
ngrok(srv.address().port, function(err, url){
if (err) {
console.error('… error setting up reverse tunnel');
console.error(err.stack);
return;
}
console.log('… booting up \u001b[96m'
+ browser + '\u001b[39m (' + (version || 'latest')
+ ') on ' + platform);
spawn(url);
});
// let `error` throw
});
}
console.log("Setting up ngrok", this.argv.ngrokRegion ? `(region: ${this.argv.ngrokRegion})` : "");
}
// 1. start local server on random port
this.ngrokServer = http.createServer(this.ngrokHandler.bind(this));
// turn server.listen() into promise so we can await
const listen = util.promisify( this.ngrokServer.listen.bind(this.ngrokServer) );
await listen(0, '127.0.0.1');
// 2. start ngrok tunnel connected to that port
this.ngrokServerPort = this.ngrokServer.address().port;
// create a unique authorization token that we check on our local instance later
// this adds extra protection on top of the uniquely generated ngrok subdomain (e.g. a01ae275.ngrok.io)
this.ngrokAuth = crypto.randomBytes(32).toString("hex");
const ngrokUrl = await ngrok.connect({
addr: this.ngrokServerPort,
region: this.argv.ngrokRegion
});
// 3. pass on public ngrok url to agent
action.parameters.push({
key: "$ngrokUrl",
value: url.parse(ngrokUrl).host
});
action.parameters.push({
key: "$ngrokAuth",
value: this.ngrokAuth
});
console.log(`Ngrok forwarding: ${ngrokUrl} => http://localhost:${this.ngrokServerPort} (auth: ${this.ngrokAuth})`);
const server = app.listen(8088, () => {
ngrok.connect(8088).then(ngrokUrl => {
endpoint = ngrokUrl
console.log(`Requestor Service running, open at ${endpoint}`)
})
})
app.listen(3002, function() {
console.log('Token provider listening on port 3002!');
var ngrokOptions = {
proto: 'http',
addr: 3002
};
if (config.ngrokSubdomain) {
ngrokOptions.subdomain = config.ngrokSubdomain
}
ngrok.connect(ngrokOptions).then(function(url) {
console.log('ngrok url is ' + url);
});
});
gulp.task('ngrok-url', function(cb) {
return ngrok.connect(3000, function(err, url) {
site = url;
console.log('serving your tunnel from: ' + site);
cb();
});
});
this.nuxt.hook('build:done', async () => {
if (!connectedUrl) {
try {
const url = await ngrok.connect(opts)
connectedUrl = url
return console.log(chalk.bgGreen.black(' OPEN ') + chalk.green(` ${connectedUrl} for external access`))
} catch (err) {
return console.error('[nuxt][ngrok] ' + chalk.red(err.details.err))
}
}
connectedUrl &&
console.log(chalk.bgGreen.black(' OPEN ') + chalk.green(` ${connectedUrl} for external access`))
})
var ngRockTunnel = function(cb){
ngrok.connect({ port: 3001 }, cb);
};
server.listen(config.port, function(){
log('running on port', server.address().port)
!config.notunnel && require('ngrok').connect(server.address().port, function(e, url){
log('tunnelling', url && url.magenta)
return e ? err('error setting up reverse tunnel', e.stack)
: (config.browsers || [])
.map(canonical)
.filter(Boolean)
.forEach(boot(url))
})
})
}