diff --git a/package.json b/package.json index eeea489..de20eae 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@types/ws": "^7.2.4", "axios": "^1.3.5", "commander": "^5.1.0", + "chalk": "4.1.2", "deep-equal": "^2.0.3", "deepmerge": "^4.2.2", "detect-port": "^2.1.0", diff --git a/src/message-handlers/hostname-assigned.ts b/src/message-handlers/hostname-assigned.ts index 33edd15..7c4b263 100644 --- a/src/message-handlers/hostname-assigned.ts +++ b/src/message-handlers/hostname-assigned.ts @@ -2,6 +2,7 @@ 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'; +import chalk from 'chalk'; export default async function hostnameAssigned(message: HostnameAssignedMessage, websocket: HostipWebSocket, options: Options) { const port = options.port; @@ -10,13 +11,18 @@ export default async function hostnameAssigned(message: HostnameAssignedMessage, console.error('Please specify a port e.g. run "tmole 80"'); } - const httpUrl = `http://${message.hostname}`; - const httpsUrl = `https://${message.hostname}`; + const httpsUrl = `https://${message.hostname}`; + const httpUrl = `http://${message.hostname}`; + const destinationUrl = `http://localhost:${port}`; if (process.env.TUNNELMOLE_QUIET_MODE !== '1') { - console.info(`${httpUrl} is forwarding to localhost:${port}`); - console.info(`${httpsUrl} is forwarding to localhost:${port}`); + console.info('='.repeat(process.stdout.columns)); + console.info('Your URLs are below. 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('='.repeat(process.stdout.columns)); } eventHandler.emit(URL_ASSIGNED, httpsUrl); diff --git a/src/tunnelmole.ts b/src/tunnelmole.ts index 5071b74..0118c03 100644 --- a/src/tunnelmole.ts +++ b/src/tunnelmole.ts @@ -6,6 +6,7 @@ import { setUpAutoReconnect } from './websocket/setup-auto-reconnect.js'; import { connect } from './websocket/connect.js'; import { setIsCli } from './websocket/connection-info-service.js'; import detectPort from 'detect-port'; +import chalk from 'chalk'; export default async function tunnelmole( options: Options, @@ -30,9 +31,7 @@ export default async function tunnelmole( if (availablePort == options.port) { console.warn( ` -Warning: You currently don't have anything running on port ${port}, which means you might get the standard 503 gateway timeout error when you make a request, since your service is not reachable. - -Please start your service on port ${port} so that requests can reach your service. +${chalk.yellow.bold(`You currently don't have anything running on port ${port}`)}. Please start your service on port ${chalk.bold(port)} so that requests can reach your service. You may have also chosen the wrong port, in which case, find out what port your service is actually running on. ` ); diff --git a/version.ts b/version.ts index 4b2c074..253457b 100644 --- a/version.ts +++ b/version.ts @@ -1,2 +1,2 @@ -const version = '2.3.4'; +const version = '2.3.5'; export { version }