Skip to content
基哥科技 edited this page Oct 17, 2023 · 4 revisions

centos7.9

yum install -y epel-release
yum install -y zlib-devel libuv-devel glibc-devel json-c-devel libwebsockets-devel
yum install -y gcc patch

ttyd<=1.6.3

mkdir b
cd b
cc -std=gnu99 -o pty.c.o -c ../src/pty.c
cc -std=gnu99 -o http.c.o -c ../src/http.c
cc -std=gnu99 -o utils.c.o -c ../src/utils.c
cc -std=gnu99 -o terminal.c.o -c ../src/terminal.c
cc -std=gnu99 -o protocol.c.o -c ../src/protocol.c -I/usr/include/json-c
cc -std=gnu99 -o server.c.o   -c ../src/server.c   -I/usr/include/json-c -DTTYD_VERSION=\"1.6.3-j8\" 
cc utils.c.o terminal.c.o protocol.c.o http.c.o server.c.o  -o ttyd  -lz  -luv -lutil -ljson-c -lwebsockets -lssl -lcrypto
\cp ttyd /bin

ttyd>=1.7.0

loss patch:

cat <<j8 |patch -p0
+++ src/http.c
@@ -29,4 +28,0 @@
-  if (server->auth_header != NULL) {
-    if (lws_hdr_custom_length(wsi, server->auth_header, strlen(server->auth_header)) > 0) return AUTH_OK;
-    return send_unauthorized(wsi, HTTP_STATUS_PROXY_AUTH_REQUIRED, WSI_TOKEN_HTTP_PROXY_AUTHENTICATE);
-  }
+++ src/protocol.c
@@ -184,3 +183,0 @@
-  if (server->auth_header != NULL) {
-    return lws_hdr_custom_copy(wsi, pss->user, sizeof(pss->user), server->auth_header, strlen(server->auth_header)) > 0;
-  }
j8
mkdir b
cd b
cc -std=gnu99 -o pty.c.o -c ../src/pty.c
cc -std=gnu99 -o http.c.o -c ../src/http.c
cc -std=gnu99 -o utils.c.o -c ../src/utils.c
cc -std=gnu99 -o protocol.c.o -c ../src/protocol.c -I/usr/include/json-c
cc -std=gnu99 -o server.c.o   -c ../src/server.c   -I/usr/include/json-c -DTTYD_VERSION=\"1.7.4-j8\" 
cc utils.c.o pty.c.o protocol.c.o http.c.o server.c.o  -o ttyd  -lz  -luv -lutil -ljson-c -lwebsockets -lssl -lcrypto
\cp ttyd /bin

patch >=1.7.4

cat <<j8 |patch -p0
+++ src/server.c
@@ -325 +325,2 @@
-  info.max_http_header_data = 65535;
+  info.max_http_header_data = 32767;
+printf("ttyd lws max_http_header_data %d\n", info.max_http_header_data);

j8

lossless patch

cat <<j8 |patch -p0
+++ src/http.c
@@ -28,0 +29 @@
+#ifdef _NEW_LWS
@@ -32,0 +34 @@
+#endif
+++ src/protocol.c
@@ -183,0 +184 @@
+#ifdef _NEW_LWS
@@ -186,0 +188 @@
+#endif
+++ src/server.c
@@ -325,0 +326 @@
+  if(info.max_http_header_data < 0) info.max_http_header_data = 32767;
j8

use new lws : cc append -D_NEW_LWS

about old lws

Clone this wiki locally