🌴 Sync 2026-09-19 18:46:44

This commit is contained in:
github-actions[bot] committed 2026-09-19 18:46:44 +08:00
1 parent 0f624def4e
commit abba0cfa22
30 files changed
+322 -1252

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#
# Copyright (C) 2016 Shuanglei Tao <tsl0922@gmail.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ttyd
PKG_VERSION:=1.7.7
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/tsl0922/ttyd/tar.gz/$(PKG_VERSION)?
PKG_HASH:=skip
PKG_MAINTAINER:=Shuanglei Tao <tsl0922@gmail.com>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_CPE_ID:=cpe:/a:ttyd_project:ttyd
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/ttyd
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Command-line tool for sharing terminal over the web
DEPENDS:=+libcap +libopenssl +libjson-c +libuv +zlib +libwebsockets-full
URL:=https://github.com/tsl0922/ttyd
SUBMENU:=Terminal
endef
define Package/ttyd/description
ttyd is a command-line tool for sharing terminal over the web.
endef
define Package/ttyd/conffiles
/etc/config/ttyd
endef
define Package/ttyd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ttyd $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) ./files/ttyd.config $(1)/etc/config/ttyd
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/ttyd.init $(1)/etc/init.d/ttyd
endef
$(eval $(call BuildPackage,ttyd))
+4
View File
@@ -0,0 +1,4 @@
config ttyd
option command '/bin/login'
+102
View File
@@ -0,0 +1,102 @@
#!/bin/sh /etc/rc.common
START=99
STOP=50
USE_PROCD=1
NAME=ttyd
PROG=/usr/bin/$NAME
validate_section_ttyd()
{
uci_load_validate ttyd ttyd "$1" "$2" \
'enable:bool:1' \
'port:port' \
'interface:string' \
'credential:string' \
'uid:uinteger' \
'gid:uinteger' \
'signal:uinteger' \
'url_arg:bool' \
'readonly:bool:0' \
'client_option:list(string)' \
'terminal_type:string' \
'check_origin:bool' \
'max_clients:uinteger' \
'once:bool' \
'index:string' \
'ipv6:bool' \
'ssl:bool' \
'ssl_cert:file' \
'ssl_key:file' \
'ssl_ca:file' \
'debug:uinteger' \
'command:string'
}
ttyd_instance()
{
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
[ "$enable" = 0 ] && return 1
[ -z "$command" ] && return 1
[ "${interface::1}" = @ ] && {
interface=$(
. /lib/functions/network.sh
network_get_device device "${interface:1}"
echo -n "$device"
)
}
[ "$url_arg" = 0 ] && url_arg=""
[ "$readonly" = 0 ] && readonly="-W"
[ "$check_origin" = 0 ] && check_origin=""
[ "$once" = 0 ] && once=""
[ "$ipv6" = 0 ] && ipv6=""
[ "$ssl" = 0 ] && ssl=""
procd_open_instance
procd_set_param command "$PROG" \
${port:+-p $port} \
${interface:+-i $interface} \
${credential:+-c $credential} \
${uid:+-u $uid} \
${gid:+-g $gid} \
${signal:+-s $signal} \
${url_arg:+-a} \
${readonly:-} \
${terminal_type:+-T $terminal_type} \
${check_origin:+-O} \
${max_clients:+-m $max_clients} \
${once:+-o} \
${index:+-I $index} \
${ipv6:+-6} \
${ssl:+-S} \
${ssl_cert:+-C $ssl_cert} \
${ssl_key:+-K $ssl_key} \
${ssl_ca:+-A $ssl_ca} \
${debug:+-d $debug}
config_list_foreach "$1" client_option "procd_append_param command -t"
procd_append_param command $command
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
start_service() {
config_load "$NAME"
config_foreach validate_section_ttyd ttyd ttyd_instance
}
shutdown() {
# close all open connections
killall "$NAME"
}
service_triggers() {
procd_add_reload_trigger "$NAME"
}
+20
View File
@@ -0,0 +1,20 @@
--- a/src/server.c
+++ b/src/server.c
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <syslog.h>
#include "utils.h"
@@ -520,7 +521,8 @@ int main(int argc, char **argv) {
return -1;
}
- lws_set_log_level(debug_level, NULL);
+ openlog("ttyd", LOG_NDELAY | LOG_PID, LOG_DAEMON);
+ lws_set_log_level(debug_level, lwsl_emit_syslog);
char server_hdr[128] = "";
sprintf(server_hdr, "ttyd/%s (libwebsockets/%s)", TTYD_VERSION, LWS_LIBRARY_VERSION);