UNPKG

@thgh/tunnelmole

Version:

Tunnelmole, an open source ngrok alternative. Instant public URLs for any http/https based application. Available as a command line application or as an NPM dependency for your code. Stable and maintained. Good test coverage. Works behind firewalls

19 lines (15 loc) 821 B
import HostnameAssignedMessage from '../messages/hostname-assigned-message.js'; import HostipWebSocket from '../websocket/host-ip-websocket.js'; import { Options } from '../options.js'; import { eventHandler, URL_ASSIGNED } from '../events/event-handler.js'; export default async function hostnameAssigned(message: HostnameAssignedMessage, websocket: HostipWebSocket, options: Options) { const port = options.port; if (typeof port === 'undefined') { console.error('Please specify a port e.g. run "tmole 80"'); } const httpUrl = `http://${message.hostname}`; const httpsUrl = `https://${message.hostname}`; console.info(`${httpUrl} is forwarding to localhost:${port}`); console.info(`${httpsUrl} is forwarding to localhost:${port}`); eventHandler.emit(URL_ASSIGNED, httpsUrl); }