Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iac

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iac

Interface to Telnet's Interpret As Command

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

iac

Node.js interface to Telnet's Interpret As Command

npm version npm downloads license

Install with npm:

$ npm install --save iac

iac relies on es6 Proxy, therefore you must use Node.js version 6.0.0 or above.

Examples

As the server
const net = require('net')
const iac = require('iac')

net
  .createServer(sock => {
    // IAC WILL ECHO
    sock.write(iac.will.echo)

    // Handler for IAC SB NAWS
    iac.on(sock, iac.sb.naws, (width, height) => {
      console.log(`Remote terminal is ${width}x${height}`)
    })
  })
  .listen(3000)
As the client
const net = require('net')
const iac = require('iac')

net
  .createConnection('localhost', 3000)
  .on('connect', conn => {
    // IAC SB NAWS 0 80 0 24 IAC SE
    //  A window 80 characters wide, 24 characters high
    //  See RFC 1073

    conn.write(iac.sb.naws(80, 24))
  })

API

iac.OPERATION.OPTION will always be a Buffer, where:

OPERATION is one of:

OPTION is one of:

  • binary (Binary Transmission)
  • echo
  • suppress (Suppress Go Ahead)
  • status [not fully supported]
  • timing (Timing Mark)
  • terminal (Terminal Type)
  • naws (Negotiate About Window Size)
  • speed (Terminal Speed)
  • flow (Remote Flow Control)
  • linemode
  • env (Environment Variables)

Both OPERATION and OPTION are case insensitive. If either are not one of the operations/options listed then it shall return undefined.

e.g.

const iac = require('iac')

// IAC DONT SUPPRESS-GO-AHEAD
iac.dont.suppress

// IAC WILL LINEMODE
iac.will.linemode 

Subnegotiation

To use subnegotiation, call iac.sb.OPTION():

  • Strings are interpolated into ASCII
  • Numbers are passed directly
  • Passing no arguments implies subnegotiation value required (1).

e.g.

const iac = require('iac')

// IAC SB NAWS 0 80 0 24 IAC SE
iac.sb.naws(80, 24)

// IAC SB TERMINAL-TYPE 1 IAC SE
iac.sb.terminal()

On

iac also provides support for assigning handlers for socket data of specific IAC commands on a socket with iac.on(socket, command, handler). command should be something like iac.do.suppress or iac.sb.status.

e.g.

const net = require('net')
const iac = require('iac')

net
  .createServer(sock => {
    // Do not use `sock.setEncoding` at any point if using `iac.on(sock)`

    // Handlers...
    iac
      .on(sock, iac.will.naws, () => console.log(`Remote will NAWS`))
      .on(sock, iac.wont.naws, () => console.log(`Remote wont NAWS`))
      .on(sock, iac.sb.naws, (width, height) => {
        // Note encoding is operation-specific
        console.log(`Remote terminal size is ${width}x${height}`)
      })

    // Ask socket to negotiate window size
    sock.write(iac.do.naws)
  })
  .listen(3000)

FAQs

Package last updated on 27 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc