Skip to content

Commit db77fde

Browse files
flpanbintsl0922
authored andcommitted
add --srv-buf-size option
1 parent f3fe06a commit db77fde

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

man/ttyd.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Cross platform: macOS, Linux, FreeBSD/OpenBSD, OpenWrt/LEDE, Windows
121121
-P, --ping-interval
122122
Websocket ping interval(sec) (default: 5)
123123

124+
.PP
125+
-f, --srv-buf-size
126+
Maximum chunk of file (in bytes) that can be sent at once, a larger value may improve throughput (default: 4096)
127+
124128
.PP
125129
-6, --ipv6
126130
Enable IPv6 support

man/ttyd.man.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ ttyd 1 "September 2016" ttyd "User Manual"
8383
-P, --ping-interval
8484
Websocket ping interval(sec) (default: 5)
8585

86+
-f, --srv-buf-size
87+
Maximum chunk of file (in bytes) that can be sent at once, a larger value may improve throughput (default: 4096)
88+
8689
-6, --ipv6
8790
Enable IPv6 support
8891

src/server.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static const struct option options[] = {{"port", required_argument, NULL, 'p'},
6565
#if LWS_LIBRARY_VERSION_NUMBER >= 4000000
6666
{"ping-interval", required_argument, NULL, 'P'},
6767
#endif
68+
{"srv-buf-size", required_argument, NULL, 'f'},
6869
{"ipv6", no_argument, NULL, '6'},
6970
{"ssl", no_argument, NULL, 'S'},
7071
{"ssl-cert", required_argument, NULL, 'C'},
@@ -83,7 +84,7 @@ static const struct option options[] = {{"port", required_argument, NULL, 'p'},
8384
{"version", no_argument, NULL, 'v'},
8485
{"help", no_argument, NULL, 'h'},
8586
{NULL, 0, 0, 0}};
86-
static const char *opt_string = "p:i:U:c:H:u:g:s:w:I:b:P:6aSC:K:A:Wt:T:Om:oqBd:vh";
87+
static const char *opt_string = "p:i:U:c:H:u:g:s:w:I:b:P:f:6aSC:K:A:Wt:T:Om:oqBd:vh";
8788

8889
static void print_help() {
8990
// clang-format off
@@ -116,6 +117,7 @@ static void print_help() {
116117
#if LWS_LIBRARY_VERSION_NUMBER >= 4000000
117118
" -P, --ping-interval Websocket ping interval(sec) (default: 5)\n"
118119
#endif
120+
" -f, --srv-buf-size Maximum chunk of file (in bytes) that can be sent at once, a larger value may improve throughput (default: 4096)\n"
119121
#ifdef LWS_WITH_IPV6
120122
" -6, --ipv6 Enable IPv6 support\n"
121123
#endif
@@ -463,6 +465,14 @@ int main(int argc, char **argv) {
463465
retry.secs_since_valid_hangup = interval + 7;
464466
} break;
465467
#endif
468+
case 'f': {
469+
int serv_buf_size = parse_int("srv-buf-size", optarg);
470+
if (serv_buf_size < 0) {
471+
fprintf(stderr, "ttyd: invalid srv-buf-size: %s\n", optarg);
472+
return -1;
473+
}
474+
info.pt_serv_buf_size = serv_buf_size;
475+
} break;
466476
case '6':
467477
info.options &= ~(LWS_SERVER_OPTION_DISABLE_IPV6);
468478
break;
@@ -553,9 +563,9 @@ int main(int argc, char **argv) {
553563
if (ssl) {
554564
info.ssl_cert_filepath = cert_path;
555565
info.ssl_private_key_filepath = key_path;
556-
#ifndef LWS_WITH_MBEDTLS
566+
#ifndef LWS_WITH_MBEDTLS
557567
info.ssl_options_set = SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
558-
#endif
568+
#endif
559569
if (strlen(ca_path) > 0) {
560570
info.ssl_ca_filepath = ca_path;
561571
info.options |= LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT;

0 commit comments

Comments
 (0)