@statezero/statezero-tunnel
Version:
Tunnelmole client for StateZero users to create secure tunnels to their local services.
24 lines • 1.21 kB
JavaScript
import { eventHandler, URL_ASSIGNED } from '../events/event-handler.js';
import chalk from 'chalk';
export default async function hostnameAssigned(message, websocket, options) {
const port = options.port;
if (typeof port === 'undefined') {
console.error('Please specify a port e.g. run "tmole 80"');
process.exit(1);
}
const httpsUrl = `https://${message.hostname}`;
const httpUrl = `http://${message.hostname}`;
const destinationUrl = `http://localhost:${port}`;
const encodedHttpsUrl = Buffer.from(httpsUrl).toString('base64');
if (process.env.TUNNELMOLE_QUIET_MODE !== '1') {
console.info('='.repeat(process.stdout.columns));
console.info('Your Public URLs are below and are accessible internet wide. Always use HTTPs for the best security');
console.info('');
console.info(`${chalk.greenBright.bold(httpsUrl)} ⟶ ${chalk.bold(destinationUrl)}`);
console.info(`${chalk.greenBright.bold(httpUrl)} ⟶ ${chalk.bold(destinationUrl)}`);
console.info('');
console.info('='.repeat(process.stdout.columns));
}
eventHandler.emit(URL_ASSIGNED, httpsUrl);
}
//# sourceMappingURL=hostname-assigned.js.map