Spawners

Spawners are a type of stream that connects the input and output data for a stream and abstracts it to a common interfaces. Spawners are used by a tube to handle communications with other processes.

Command Spawner

A command spawner launches an application or binary program and binds itself to the output and input.

new hakkit.spawn.cmd(cmd, <args>, <fd>, <env>, <cwd>, [options])

new hakkit.spawn.cmd(cmd, args, fd, env, cwd, options) will create a new process with the given options and pipe its output into a tube

Network Spawner

A network spawner connects to a remote TCP server and streams data between the server and the tube

new hakkit.spawn.net(address, port)

new hakkit.spawn.net(address, port) will create a new TCP connection to address:port and stream incoming and outgoing data through it

SSH Spawner

An SSH spawner uses SSH to either connect a remote shell on a server, or to execute a binary on it

Credentials {user, <password>, <privateKey>, <host>, <port>}

SSH credentials take the form of an object with a mandatory user field, and any of the other four options. If neither password nor privateKey are provided, then hakkit will prompt the user to input a password for authentication.

new hakkit.spawn.ssh.cmd(creds, cmd, <args>, <env>)

new hakkit.spawn.ssh.cmd(creds, cmd, args, env) will create an SSH connection to creds.host:creds.port and run the command cmd args in the environment specified by env. Unlike with hakkit.spawn.cmd, both STDOUT and STDIN will be piped out of the tube.

new hakkit.spawn.ssh.shell(creds)

new hakkit.spawn.ssh.shell(creds) will create an SSH connection to creds.host:creds.port and open a shell. This can be used for running multiple commands in succession. Note, all output from the shell will be piped through the tube, including all data presented in the new command prompt. As such, it is recommended to use tube.recv() to flush unwanted output before running a new command.