The backend for a web-based terminal to run commands and code snippets in a sandboxed environment.
Try it out at liambeckman.com/code/demonic.
Demonic was inspired by the following cool projects:
# get code
git clone https://github.com/lbeckman314/demonic-server
cd demonic-server
# install dependencies
npm install
# copy example config
cp src/config-example.js src/config.js
# edit key, certificate, and passphrase information
vim src/config.js
# run server (if no port number is provided, 12345 in this example, the server will default to port 8181)
npm run start -- 12345
# then you can connect to the server from a demonic client.
# remove this directory
rm -rf demonic-server
- Connection is established between client and server. Client displays user prompt.
user @ demonic >
- Client sends user input to the server.
user @ demonic > echo "Wow, I'm in a shell!"\n
-
Server searches for
echo
in the list of allowed programs. If found, server spawns theecho
process. -
Server sends client the output of the command.
{ out: "Wow, I'm in a shell!" }
- Client displays output of the command to the user.
user @ demonic > echo "Wow, I'm in a shell!"\n
Wow, I'm in a shell!
- Server sends client the exit status of the command.
{ exit: 0 }
- Client displays user prompt on terminal. Ready for next command!