Latest update - 9019

This commit is contained in:
2023-02-01 15:14:42 +09:00
parent 84e4585013
commit aeed7a64b5
6 changed files with 71 additions and 29 deletions
+47
View File
@@ -386,6 +386,39 @@ ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f, size_t len)
}
ngx_chain_t *
ngx_quic_copy_buffer(ngx_connection_t *c, u_char *data, size_t len)
{
ngx_buf_t buf;
ngx_chain_t cl, *out;
ngx_quic_buffer_t qb;
ngx_memzero(&buf, sizeof(ngx_buf_t));
buf.pos = data;
buf.last = buf.pos + len;
buf.temporary = 1;
cl.buf = &buf;
cl.next = NULL;
ngx_memzero(&qb, sizeof(ngx_quic_buffer_t));
if (ngx_quic_write_buffer(c, &qb, &cl, len, 0) == NGX_CHAIN_ERROR) {
return NGX_CHAIN_ERROR;
}
out = ngx_quic_read_buffer(c, &qb, len);
if (out == NGX_CHAIN_ERROR) {
return NGX_CHAIN_ERROR;
}
ngx_quic_free_buffer(c, &qb);
return out;
}
ngx_chain_t *
ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, uint64_t limit)
{
@@ -825,6 +858,20 @@ ngx_quic_log_frame(ngx_log_t *log, ngx_quic_frame_t *f, ngx_uint_t tx)
case NGX_QUIC_FT_NEW_TOKEN:
p = ngx_slprintf(p, last, "NEW_TOKEN");
#ifdef NGX_QUIC_DEBUG_FRAMES
{
ngx_chain_t *cl;
p = ngx_slprintf(p, last, " token:");
for (cl = f->data; cl; cl = cl->next) {
p = ngx_slprintf(p, last, "%*xs",
cl->buf->last - cl->buf->pos, cl->buf->pos);
}
}
#endif
break;
case NGX_QUIC_FT_HANDSHAKE_DONE:
+2
View File
@@ -26,6 +26,8 @@ ngx_int_t ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f,
ngx_chain_t *ngx_quic_alloc_chain(ngx_connection_t *c);
void ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in);
ngx_chain_t *ngx_quic_copy_buffer(ngx_connection_t *c, u_char *data,
size_t len);
ngx_chain_t *ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
uint64_t limit);
ngx_chain_t *ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
+7 -1
View File
@@ -1076,6 +1076,7 @@ ngx_quic_send_new_token(ngx_connection_t *c, ngx_quic_path_t *path)
{
time_t expires;
ngx_str_t token;
ngx_chain_t *out;
ngx_quic_frame_t *frame;
ngx_quic_connection_t *qc;
@@ -1095,6 +1096,11 @@ ngx_quic_send_new_token(ngx_connection_t *c, ngx_quic_path_t *path)
return NGX_ERROR;
}
out = ngx_quic_copy_buffer(c, token.data, token.len);
if (out == NGX_CHAIN_ERROR) {
return NGX_ERROR;
}
frame = ngx_quic_alloc_frame(c);
if (frame == NULL) {
return NGX_ERROR;
@@ -1102,8 +1108,8 @@ ngx_quic_send_new_token(ngx_connection_t *c, ngx_quic_path_t *path)
frame->level = ssl_encryption_application;
frame->type = NGX_QUIC_FT_NEW_TOKEN;
frame->data = out;
frame->u.token.length = token.len;
frame->u.token.data = token.data;
ngx_quic_queue_frame(qc, frame);
+2 -21
View File
@@ -160,13 +160,11 @@ ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn,
{
u_char *p, *end;
size_t client_params_len;
ngx_buf_t buf;
ngx_chain_t *out, cl;
ngx_chain_t *out;
const uint8_t *client_params;
ngx_quic_tp_t ctp;
ngx_quic_frame_t *frame;
ngx_connection_t *c;
ngx_quic_buffer_t qb;
ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc;
#if defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
@@ -243,28 +241,11 @@ ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn,
ctx = ngx_quic_get_send_ctx(qc, level);
ngx_memzero(&buf, sizeof(ngx_buf_t));
buf.pos = (u_char *) data;
buf.last = buf.pos + len;
buf.temporary = 1;
cl.buf = &buf;
cl.next = NULL;
ngx_memzero(&qb, sizeof(ngx_quic_buffer_t));
if (ngx_quic_write_buffer(c, &qb, &cl, len, 0) == NGX_CHAIN_ERROR) {
return 0;
}
out = ngx_quic_read_buffer(c, &qb, len);
out = ngx_quic_copy_buffer(c, (u_char *) data, len);
if (out == NGX_CHAIN_ERROR) {
return 0;
}
ngx_quic_free_buffer(c, &qb);
frame = ngx_quic_alloc_frame(c);
if (frame == NULL) {
return 0;
+13 -6
View File
@@ -109,7 +109,7 @@ static size_t ngx_quic_create_crypto(u_char *p,
ngx_quic_crypto_frame_t *crypto, ngx_chain_t *data);
static size_t ngx_quic_create_hs_done(u_char *p);
static size_t ngx_quic_create_new_token(u_char *p,
ngx_quic_new_token_frame_t *token);
ngx_quic_new_token_frame_t *token, ngx_chain_t *data);
static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf,
ngx_chain_t *data);
static size_t ngx_quic_create_max_streams(u_char *p,
@@ -1301,7 +1301,7 @@ ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f)
return ngx_quic_create_hs_done(p);
case NGX_QUIC_FT_NEW_TOKEN:
return ngx_quic_create_new_token(p, &f->u.token);
return ngx_quic_create_new_token(p, &f->u.token, f->data);
case NGX_QUIC_FT_STREAM:
return ngx_quic_create_stream(p, &f->u.stream, f->data);
@@ -1491,10 +1491,12 @@ ngx_quic_create_hs_done(u_char *p)
static size_t
ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token)
ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token,
ngx_chain_t *data)
{
size_t len;
u_char *start;
size_t len;
u_char *start;
ngx_buf_t *b;
if (p == NULL) {
len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN);
@@ -1508,7 +1510,12 @@ ngx_quic_create_new_token(u_char *p, ngx_quic_new_token_frame_t *token)
ngx_quic_build_int(&p, NGX_QUIC_FT_NEW_TOKEN);
ngx_quic_build_int(&p, token->length);
p = ngx_cpymem(p, token->data, token->length);
while (data) {
b = data->buf;
p = ngx_cpymem(p, b->pos, b->last - b->pos);
data = data->next;
}
return p - start;
}
@@ -167,7 +167,6 @@ typedef struct {
typedef struct {
uint64_t length;
u_char *data;
} ngx_quic_new_token_frame_t;
/*