npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

telnet-console

v1.0.5

Published

Node.js Runtime Console

Downloads

225

Readme

Telnet Console for NodeJS

A library for implementing runtime consoles in Node applications. This library allows you to trivially build a telnet daemon for your application that can buffer/intercept console log messages and connect a REPL within a given execution context (usually the main program).

Security Notes - IMPORTANT!!!

Telnet is unencrypted and unauthenticated by default. You should not expose it to the internet, or any other network where you do not trust 100% of the hosts. Anything typed, including authentication credentials, can be seen by sniffing the network traffic.

Additionally, making the REPL available allows anyone who can connect to it to do anything at all with the same privileges as your application -- so even if you are limiting connections to localhost, you must also trust every single user on your machine.

We recommend only enabling a telnet console under controlled debugging conditions.

How To Use

tldr;

in your code:

require('telnet-console').start();

shell command:

telnet localhost 2323

More info in examples/ directory; use the source, Luke!

API

start(options, ...replHelpers): Start the daemon with the given options object, returning an instance of ConsoleInterceptor

options

| option | default | details |:----------------|:--------|:------------------------------------------------------------------------------------- | port | 2323 | port number to listen on; false to disable | callbackTelnet | | callback to invoke when telnet daemon has started; receives (port, server, registry). | callbackStdio | | callback to invoke when stdio repl has started | histfile | | filename to REPL history into; understands ~, falsey to disable | stdio | false | if not false, start a REPL on stdio also | eval | | evaluator function to use with REPL. Use to get specific scope instead of global. | logOff | | true to not display log messages by default | bufferLines | 1000 | number of log lines to keep in memory for log command | users | | a function which returns true for a valid login/password pair, or an object whose keys are logins and values are passwords

Note: all standard Node REPL options are also supported. See NodeJS docs.

replHelpers

You can specify zero or more "helpers" to add custom commands to your server. Each helper object can implement any number of new commands. The property name becomes the command word, and the value of the property becomes the function which is executed.

Each function which is executed receives the parameters arg, client, and options. The arg parameter is the string that was typed after the command word. The client parameter is a handle to the output stream (i.e. the connection to the remote end). The options parameter is the options argument that was passed to start().

Each function should return undefined, which is ignored, or an object or string which will be displayed to the remote user. Using the client output stream is possible, but discouraged. If it is used, it is very important to send \r\n instead of \n, and all output must end with \r\n to avoid corrupting the REPL.

ConsoleIntercetor::reintercept(): re-establish console.log (etc) interception if some other library intercepted it.

Commands

  • help - online help
  • log on - console messages show in telnet client (default)
  • log off - console messages don't show in telnet client
  • log N - show the last N messages in the telnet client
  • log - show entire log (up to options.bufferLines lines)
  • last - last result evaluated (also variable _)
  • keys - show Object.keys of argument
  • uptime - show system uptime, load average
  • ifconfig - show network interfaces
  • whoami - show os-level info about running process
  • who - show who is conneted to this process
  • wall - write a message to all connected users
  • stat - show os-level statitics about running process
  • raise - send a signal to this process
  • flush - flush a module from the require cache (potentially very dangerous!!!)

Debugging Tips

keep

Every command entered in the REPL is evaluated in such a way as to minimize the possibility of having unintended side-effects in the program under test. One side effect of this is that you can declare variable in the REPL. A special variable, keep, is an object which has been provided so you have a place to stash things.

Release Notes

  • Jan 4 2021: Initial Release

Supported Platforms

  • Everything, >= current Node 12 LTS

Related Products

  • niim - a command-line debugger for Node.js (fork of node-inspect) which can debug programs that need stdin connected to a terminal (eg REPLs).