{ "name": "ttyd", "version": "1.7.7", "summary": "ttyd: shares a terminal program (a shell, htop, tmux) as a web page over HTTP or HTTPS, through WebSockets", "category": "network", "license": "MIT", "homepage": "https://tsl0922.github.io/ttyd/", "source": { "url": "https://deb.debian.org/debian/pool/main/t/ttyd/ttyd_1.7.7.orig.tar.xz", "sha256": "48eba3f76af237f4c09cceb5ddbe0f845832557819f7e5c60c88285f8822af88" }, "watch": {"kind": "index", "url": "https://deb.debian.org/debian/pool/main/t/ttyd/", "regex": "ttyd_([0-9]+(?:\\.[0-9]+)+)\\.orig\\.tar\\.xz"}, "deps": [ "libwebsockets", "libuv", "json-c", "openssl", "zlib" ], "env_packages": [], "static": true, "nss": true, "check": "t=$(mktemp -d) && bin/ttyd --version | has 'ttyd version 1.7.7' && printf '%s\\n' 'import socket, base64, os, sys, json, struct, time' 'p = int(sys.argv[1])' 's = socket.create_connection((\"127.0.0.1\", p), timeout=10)' 's.sendall(b\"GET / HTTP/1.0\\r\\n\\r\\n\")' 'page = b\"\"' 'while True:' ' c = s.recv(65536)' ' if not c:' ' break' ' page += c' 'if b\"ttyd\" not in page.lower():' ' sys.exit(\"no ttyd page\")' 's = socket.create_connection((\"127.0.0.1\", p), timeout=10)' 'key = base64.b64encode(os.urandom(16)).decode()' 's.sendall((\"GET /ws HTTP/1.1\\r\\nHost: 127.0.0.1:%d\\r\\nUpgrade: websocket\\r\\nConnection: Upgrade\\r\\nSec-WebSocket-Key: %s\\r\\nSec-WebSocket-Version: 13\\r\\nSec-WebSocket-Protocol: tty\\r\\n\\r\\n\" % (p, key)).encode())' 'buf = b\"\"' 'while b\"\\r\\n\\r\\n\" not in buf:' ' buf += s.recv(4096)' 'head, buf = buf.split(b\"\\r\\n\\r\\n\", 1)' 'if b\" 101 \" not in head.split(b\"\\r\\n\")[0]:' ' sys.exit(\"no websocket upgrade: %r\" % head)' 'msg = json.dumps({\"AuthToken\": \"\", \"columns\": 80, \"rows\": 24}).encode()' 'm = os.urandom(4)' 's.sendall(bytes([0x81, 0x80 | len(msg)]) + m + bytes(b ^ m[i % 4] for i, b in enumerate(msg)))' 'out, end = b\"\", time.time() + 10' 'while b\"bvs-ttyd-ok\" not in out and time.time() < end:' ' if len(buf) >= 2:' ' n, o = buf[1] & 0x7f, 2' ' if n == 126:' ' n, o = struct.unpack(\">H\", buf[2:4])[0], 4' ' if len(buf) >= o + n:' ' if buf[o:o + 1] == b\"0\":' ' out += buf[o + 1:o + n]' ' buf = buf[o + n:]' ' continue' ' c = s.recv(65536)' ' if not c:' ' break' ' buf += c' 'sys.exit(0 if b\"bvs-ttyd-ok\" in out else \"no output: %r\" % out)' > \"$t/ws.py\" && P=$(free_port) && { bin/ttyd -i 127.0.0.1 -p \"$P\" sh -c 'echo bvs-ttyd-ok; sleep 3' > \"$t/log\" 2>&1 & echo $! > \"$t/pid\"; } && wait_port \"$P\" && python3 \"$t/ws.py\" \"$P\" && echo \"ttyd 1.7.7: its page served on port $P, and a command's output read through the WebSocket\"; r=$?; [ $r = 0 ] || tail -5 \"$t/log\" >&2; [ -f \"$t/pid\" ] && kill \"$(cat \"$t/pid\")\" 2>/dev/null; exit $r" }