summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-10-17 19:44:38 +0200
committerGitHub <noreply@github.com>2019-10-17 19:44:38 +0200
commit0226ba98052dc85d6a3c55a037ad96fe5d5b9908 (patch)
tree46f5ae33faf37b776dff9d6c9c1e5f5e5e20d7c9 /applications
parentb3965b9f53b945e1e5488b69955b0c354cb82d3f (diff)
parent1c9a06ea2b8829bee9d4149f118bd8c0d863c081 (diff)
Merge pull request #3202 from ysc3839/ttyd
[RFC] luci-app-ttyd: add new package
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-app-ttyd/Makefile10
-rw-r--r--applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/config.js79
-rw-r--r--applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/term.js21
-rw-r--r--applications/luci-app-ttyd/luasrc/controller/ttyd.lua13
4 files changed, 123 insertions, 0 deletions
diff --git a/applications/luci-app-ttyd/Makefile b/applications/luci-app-ttyd/Makefile
new file mode 100644
index 000000000..65ec02710
--- /dev/null
+++ b/applications/luci-app-ttyd/Makefile
@@ -0,0 +1,10 @@
+# This is free software, licensed under the Apache License, Version 2.0 .
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=ttyd - Command-line tool for sharing terminal over the web
+LUCI_DEPENDS:=+ttyd
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/config.js b/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/config.js
new file mode 100644
index 000000000..e92880d53
--- /dev/null
+++ b/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/config.js
@@ -0,0 +1,79 @@
+'use strict';
+'require form';
+'require tools.widgets as widgets';
+
+return L.view.extend({
+ render: function() {
+ var m, s, o;
+
+ m = new form.Map('ttyd');
+
+ s = m.section(form.TypedSection, 'ttyd', _('ttyd Instance'));
+ s.anonymous = true;
+ s.addremove = true;
+ s.addbtntitle = _('Add instance');
+
+ o = s.option(form.Flag, 'enable', _('Enable'));
+ o.default = true;
+
+ o = s.option(form.Value, 'port', _('Port'), _('Port to listen (default: 7681, use `0` for random port)'));
+ o.datatype = 'port';
+ o.placeholder = 7681;
+
+ o = s.option(widgets.DeviceSelect, 'interface', _('Interface'), _('Network interface to bind (eg: eth0), or UNIX domain socket path (eg: /var/run/ttyd.sock)'));
+ o.nocreate = true;
+ o.unspecified = true;
+
+ o = s.option(form.Value, 'credential', _('Credential'), _('Credential for Basic Authentication'));
+ o.placeholder = 'username:password';
+
+ o = s.option(form.Value, 'uid', _('User ID'), _('User id to run with'));
+ o.datatype = 'uinteger';
+
+ o = s.option(form.Value, 'gid', _('Group ID'), _('Group id to run with'));
+ o.datatype = 'uinteger';
+
+ o = s.option(form.Value, 'signal', _('Signal'), _('Signal to send to the command when exit it (default: 1, SIGHUP)'));
+ o.datatype = 'uinteger';
+
+ s.option(form.Flag, 'url_arg', _('Allow URL args'), _('Allow client to send command line arguments in URL (eg: http://localhost:7681?arg=foo&arg=bar)'));
+
+ s.option(form.Flag, 'readonly', _('Read-only'), _('Do not allow clients to write to the TTY'));
+
+ o = s.option(form.DynamicList, 'client_option', _('Client option'), _('Send option to client'));
+ o.placeholder = 'key=value';
+
+ o = s.option(form.Value, 'terminal_type', _('Terminal type'), _('Terminal type to report (default: xterm-256color)'));
+ o.placeholder = 'xterm-256color';
+
+ s.option(form.Flag, 'check_origin', _('Check origin'), _('Do not allow websocket connection from different origin'));
+
+ o = s.option(form.Value, 'max_clients', _('Max clients'), _('Maximum clients to support (default: 0, no limit)'));
+ o.datatype = 'uinteger';
+ o.placeholder = '0';
+
+ s.option(form.Flag, 'once', _('Once'), _('Accept only one client and exit on disconnection'));
+
+ o = s.option(form.Value, 'index', _('Index'), _('Custom index.html path'));
+
+ s.option(form.Flag, 'ipv6', _('IPv6'), _('Enable IPv6 support'));
+
+ s.option(form.Flag, 'ssl', _('SSL'), _('Enable SSL'));
+
+ o = s.option(form.Value, 'ssl_cert', _('SSL cert'), _('SSL certificate file path'));
+ o.depends('ssl', '1');
+
+ o = s.option(form.Value, 'ssl_key', _('SSL key'), _('SSL key file path'));
+ o.depends('ssl', '1');
+
+ o = s.option(form.Value, 'ssl_ca', _('SSL ca'), _('SSL CA file path for client certificate verification'));
+ o.depends('ssl', '1');
+
+ o = s.option(form.Value, 'debug', _('Debug'), _('Set log level (default: 7)'));
+ o.placeholder = '7';
+
+ s.option(form.Value, 'command', _('Command'));
+
+ return m.render();
+ }
+});
diff --git a/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/term.js b/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/term.js
new file mode 100644
index 000000000..4725f7a5b
--- /dev/null
+++ b/applications/luci-app-ttyd/htdocs/luci-static/resources/view/ttyd/term.js
@@ -0,0 +1,21 @@
+'use strict';
+'require uci';
+
+return L.view.extend({
+ load: function() {
+ return uci.load('ttyd');
+ },
+ render: function() {
+ var port = uci.get_first('ttyd', 'ttyd', 'port') || '7681';
+ if (port === '0')
+ return E('div', { class: 'alert-message warning' },
+ _('Random ttyd port (port=0) is not supported.<br>Change to a fixed port and try again.'));
+ return E('iframe', {
+ src: window.location.protocol + '//' + window.location.hostname + ':' + port,
+ style: 'width: 100%; min-height: 500px; border: none; border-radius: 3px; resize: vertical;'
+ });
+ },
+ handleSaveApply: null,
+ handleSave: null,
+ handleReset: null
+});
diff --git a/applications/luci-app-ttyd/luasrc/controller/ttyd.lua b/applications/luci-app-ttyd/luasrc/controller/ttyd.lua
new file mode 100644
index 000000000..5a7344d84
--- /dev/null
+++ b/applications/luci-app-ttyd/luasrc/controller/ttyd.lua
@@ -0,0 +1,13 @@
+-- Licensed to the public under the Apache License 2.0.
+
+module("luci.controller.ttyd", package.seeall)
+
+function index()
+ if not nixio.fs.access("/etc/config/ttyd") then
+ return
+ end
+
+ entry({"admin", "services", "ttyd"}, firstchild(), _("ttyd"))
+ entry({"admin", "services", "ttyd", "ttyd"}, view("ttyd/term"), _("Terminal"), 1)
+ entry({"admin", "services", "ttyd", "config"}, view("ttyd/config"), _("Config"), 2)
+end