@@ -27,18 +27,18 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
27
27
28
28
--- a/src/event/ngx_event_openssl.c
29
29
+++ b/src/event/ngx_event_openssl.c
30
- @@ -1131 ,6 +1131 ,7 @@
31
-
30
+ @@ -1239 ,6 +1239 ,7 @@ ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c, ngx_uint_t flags)
31
+
32
32
sc->buffer = ((flags & NGX_SSL_BUFFER) != 0);
33
33
sc->buffer_size = ssl->buffer_size;
34
34
+ sc->dyn_rec = ssl->dyn_rec;
35
-
35
+
36
36
sc->session_ctx = ssl->ctx;
37
-
38
- @@ -1669 ,6 +1670 ,41 @@
39
-
37
+
38
+ @@ -1806 ,6 +1807 ,41 @@ ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
39
+
40
40
for ( ;; ) {
41
-
41
+
42
42
+ /* Dynamic record resizing:
43
43
+ We want the initial records to fit into one TCP segment
44
44
+ so we don't get TCP HoL blocking due to TCP Slow Start.
@@ -77,22 +77,22 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
77
77
while (in && buf->last < buf->end && send < limit) {
78
78
if (in->buf->last_buf || in->buf->flush) {
79
79
flush = 1;
80
- @@ -1770 ,6 +1806 ,9 @@
81
-
80
+ @@ -1907 ,6 +1943 ,9 @@ ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size)
81
+
82
82
if (n > 0) {
83
-
83
+
84
84
+ c->ssl->dyn_rec_records_sent++;
85
85
+ c->ssl->dyn_rec_last_write = ngx_current_msec;
86
86
+
87
87
if (c->ssl->saved_read_handler) {
88
-
88
+
89
89
c->read->handler = c->ssl->saved_read_handler;
90
90
--- a/src/event/ngx_event_openssl.h
91
91
+++ b/src/event/ngx_event_openssl.h
92
92
@@ -64,10 +64,19 @@
93
93
#endif
94
-
95
-
94
+
95
+
96
96
+ typedef struct {
97
97
+ ngx_msec_t timeout;
98
98
+ ngx_uint_t threshold;
@@ -107,35 +107,34 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
107
107
size_t buffer_size;
108
108
+ ngx_ssl_dyn_rec_t dyn_rec;
109
109
};
110
-
111
-
112
- @@ -95 ,6 +104,11 @@
110
+
111
+
112
+ @@ -93 ,6 +102,10 @@ struct ngx_ssl_connection_s {
113
113
unsigned no_wait_shutdown:1;
114
114
unsigned no_send_shutdown:1;
115
115
unsigned handshake_buffer_set:1;
116
116
+
117
117
+ ngx_ssl_dyn_rec_t dyn_rec;
118
118
+ ngx_msec_t dyn_rec_last_write;
119
119
+ ngx_uint_t dyn_rec_records_sent;
120
- +
121
- unsigned try_early_data:1;
122
- unsigned in_early:1;
123
- unsigned early_preread:1;
124
- @@ -107,7 +121,7 @@
120
+ };
121
+
122
+
123
+ @@ -102,7 +115,7 @@ struct ngx_ssl_connection_s {
125
124
#define NGX_SSL_DFLT_BUILTIN_SCACHE -5
126
-
127
-
125
+
126
+
128
127
- #define NGX_SSL_MAX_SESSION_SIZE 4096
129
128
+ #define NGX_SSL_MAX_SESSION_SIZE 16384
130
-
129
+
131
130
typedef struct ngx_ssl_sess_id_s ngx_ssl_sess_id_t;
132
-
131
+
133
132
--- a/src/http/modules/ngx_http_ssl_module.c
134
133
+++ b/src/http/modules/ngx_http_ssl_module.c
135
- @@ -233 ,6 +233 ,41 @@
136
- offsetof(ngx_http_ssl_srv_conf_t, stapling_verify ),
134
+ @@ -246 ,6 +246 ,41 @@ static ngx_command_t ngx_http_ssl_commands[] = {
135
+ offsetof(ngx_http_ssl_srv_conf_t, early_data ),
137
136
NULL },
138
-
137
+
139
138
+ { ngx_string("ssl_dyn_rec_enable"),
140
139
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
141
140
+ ngx_conf_set_flag_slot,
@@ -173,8 +172,8 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
173
172
+
174
173
ngx_null_command
175
174
};
176
-
177
- @@ -533 ,6 +568 ,11 @@
175
+
176
+ @@ -576 ,6 +611 ,11 @@ ngx_http_ssl_create_srv_conf(ngx_conf_t *cf)
178
177
sscf->session_ticket_keys = NGX_CONF_UNSET_PTR;
179
178
sscf->stapling = NGX_CONF_UNSET;
180
179
sscf->stapling_verify = NGX_CONF_UNSET;
@@ -183,13 +182,13 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
183
182
+ sscf->dyn_rec_size_lo = NGX_CONF_UNSET_SIZE;
184
183
+ sscf->dyn_rec_size_hi = NGX_CONF_UNSET_SIZE;
185
184
+ sscf->dyn_rec_threshold = NGX_CONF_UNSET_UINT;
186
-
185
+
187
186
return sscf;
188
187
}
189
- @@ -598 ,6 +638 ,20 @@
188
+ @@ -643 ,6 +683 ,20 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
190
189
ngx_conf_merge_str_value(conf->stapling_responder,
191
190
prev->stapling_responder, "");
192
-
191
+
193
192
+ ngx_conf_merge_value(conf->dyn_rec_enable, prev->dyn_rec_enable, 0);
194
193
+ ngx_conf_merge_msec_value(conf->dyn_rec_timeout, prev->dyn_rec_timeout,
195
194
+ 1000);
@@ -205,12 +204,12 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
205
204
+ 40);
206
205
+
207
206
conf->ssl.log = cf->log;
208
-
207
+
209
208
if (conf->enable) {
210
- @@ -778 ,6 +832 ,28 @@
211
-
209
+ @@ -827 ,6 +881 ,28 @@ ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
210
+ return NGX_CONF_ERROR;
212
211
}
213
-
212
+
214
213
+ if (conf->dyn_rec_enable) {
215
214
+ conf->ssl.dyn_rec.timeout = conf->dyn_rec_timeout;
216
215
+ conf->ssl.dyn_rec.threshold = conf->dyn_rec_threshold;
@@ -235,11 +234,11 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
235
234
+
236
235
return NGX_CONF_OK;
237
236
}
238
-
237
+
239
238
--- a/src/http/modules/ngx_http_ssl_module.h
240
239
+++ b/src/http/modules/ngx_http_ssl_module.h
241
- @@ -57 ,6 +57 ,12 @@
242
-
240
+ @@ -58 ,6 +58 ,12 @@ typedef struct {
241
+
243
242
u_char *file;
244
243
ngx_uint_t line;
245
244
+
@@ -249,4 +248,5 @@ https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_r
249
248
+ size_t dyn_rec_size_hi;
250
249
+ ngx_uint_t dyn_rec_threshold;
251
250
} ngx_http_ssl_srv_conf_t;
252
-
251
+
252
+
0 commit comments