您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
liam beckman c8664c1932
Update with support for toml configuration.
1年前
.#code.org Update with binary deserialization. 2 年前
.gitignore Add color support. 2 年前
.npmignore Add color support. 2 年前
LICENSE.md Create LICENSE.md 2 年前
README.html Add color support. 2 年前
README.md Update with support for toml configuration. 1年前
config-example.js Misc. updates. 2 年前
package-lock.json Update with support for toml configuration. 1年前
package.json Update with support for toml configuration. 1年前
process.js Update with support for toml configuration. 1年前
process.toml Update with support for toml configuration. 1年前
server.js Update with support for toml configuration. 1年前

README.md

demonic server

A fake terminal cleans up user input and sends it to the server. The server then parses the input, and if it matches a predefined command, spawns a child process of that command/program. I really liked the ability to try out haskell interactively here and here, so this is something like that.

Try it out here.

<img src="demo.png"/>

Installation and Running

# install dependencies
npm install

# copy example config
cp config-example.js config.js

# edit key, certificate, and passphrase information
nano config.js

# run server (if no port number is provided, 12345 in this example, the server will default to port 8181)
node server.js 12345

# edit server information
nano demo.js

# then you can connect to the server from a client (e.g. client-example.html)

Uninstallation

# remove this directory
rm -rfI demo

Message Protocol

  • Connection is established between client and server.

  • Client sends server the command mode (and language if mode is set to ‘code’).

{
    "mode": "shell",
}
{
    "mode": "code",
    "lang": "ruby",
}
  • Client sends server data on every keypress.

  • Server buffers the incoming data until a ‘newline’ charcter is received.

  • Server finds the program named in the input, and sends the contents of the input buffer to that program.

  • Server sends client the output of the command.

{
    "out": "Wow, I'm in a shell!"
}
  • Client displays output on terminal.

  • Server sends client the exit status of the command.

{
    "exit": 0
}
  • Client displays user prompt on terminal.

Client to Server

mode: Keyword to inform server of expected behavior. Possible options are ‘shell’ and ‘code’. lang: If mode is set to ‘code’, language specifies the respective programming language. content: The commands or code sent by the user to be evaulted by the server.

Server to Client

exit: Exit status of spawned process. control: Keyword to inform client that spawned process will handle output of characters (e.g. vim). Disables writing client-side as well as buffering server-side. out: STDOUT of the spawned process. err: STDERR of the spawned process.