Latest update - 9019
This commit is contained in:
@@ -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_chain_t *
|
||||||
ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, uint64_t limit)
|
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:
|
case NGX_QUIC_FT_NEW_TOKEN:
|
||||||
p = ngx_slprintf(p, last, "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;
|
break;
|
||||||
|
|
||||||
case NGX_QUIC_FT_HANDSHAKE_DONE:
|
case NGX_QUIC_FT_HANDSHAKE_DONE:
|
||||||
|
|||||||
@@ -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);
|
ngx_chain_t *ngx_quic_alloc_chain(ngx_connection_t *c);
|
||||||
void ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in);
|
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,
|
ngx_chain_t *ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
|
||||||
uint64_t limit);
|
uint64_t limit);
|
||||||
ngx_chain_t *ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
|
ngx_chain_t *ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb,
|
||||||
|
|||||||
@@ -1076,6 +1076,7 @@ ngx_quic_send_new_token(ngx_connection_t *c, ngx_quic_path_t *path)
|
|||||||
{
|
{
|
||||||
time_t expires;
|
time_t expires;
|
||||||
ngx_str_t token;
|
ngx_str_t token;
|
||||||
|
ngx_chain_t *out;
|
||||||
ngx_quic_frame_t *frame;
|
ngx_quic_frame_t *frame;
|
||||||
ngx_quic_connection_t *qc;
|
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;
|
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);
|
frame = ngx_quic_alloc_frame(c);
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
return NGX_ERROR;
|
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->level = ssl_encryption_application;
|
||||||
frame->type = NGX_QUIC_FT_NEW_TOKEN;
|
frame->type = NGX_QUIC_FT_NEW_TOKEN;
|
||||||
|
frame->data = out;
|
||||||
frame->u.token.length = token.len;
|
frame->u.token.length = token.len;
|
||||||
frame->u.token.data = token.data;
|
|
||||||
|
|
||||||
ngx_quic_queue_frame(qc, frame);
|
ngx_quic_queue_frame(qc, frame);
|
||||||
|
|
||||||
|
|||||||
@@ -160,13 +160,11 @@ ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn,
|
|||||||
{
|
{
|
||||||
u_char *p, *end;
|
u_char *p, *end;
|
||||||
size_t client_params_len;
|
size_t client_params_len;
|
||||||
ngx_buf_t buf;
|
ngx_chain_t *out;
|
||||||
ngx_chain_t *out, cl;
|
|
||||||
const uint8_t *client_params;
|
const uint8_t *client_params;
|
||||||
ngx_quic_tp_t ctp;
|
ngx_quic_tp_t ctp;
|
||||||
ngx_quic_frame_t *frame;
|
ngx_quic_frame_t *frame;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_quic_buffer_t qb;
|
|
||||||
ngx_quic_send_ctx_t *ctx;
|
ngx_quic_send_ctx_t *ctx;
|
||||||
ngx_quic_connection_t *qc;
|
ngx_quic_connection_t *qc;
|
||||||
#if defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
|
#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);
|
ctx = ngx_quic_get_send_ctx(qc, level);
|
||||||
|
|
||||||
ngx_memzero(&buf, sizeof(ngx_buf_t));
|
out = ngx_quic_copy_buffer(c, (u_char *) data, len);
|
||||||
|
|
||||||
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);
|
|
||||||
if (out == NGX_CHAIN_ERROR) {
|
if (out == NGX_CHAIN_ERROR) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_quic_free_buffer(c, &qb);
|
|
||||||
|
|
||||||
frame = ngx_quic_alloc_frame(c);
|
frame = ngx_quic_alloc_frame(c);
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ static size_t ngx_quic_create_crypto(u_char *p,
|
|||||||
ngx_quic_crypto_frame_t *crypto, ngx_chain_t *data);
|
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_hs_done(u_char *p);
|
||||||
static size_t ngx_quic_create_new_token(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,
|
static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf,
|
||||||
ngx_chain_t *data);
|
ngx_chain_t *data);
|
||||||
static size_t ngx_quic_create_max_streams(u_char *p,
|
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);
|
return ngx_quic_create_hs_done(p);
|
||||||
|
|
||||||
case NGX_QUIC_FT_NEW_TOKEN:
|
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:
|
case NGX_QUIC_FT_STREAM:
|
||||||
return ngx_quic_create_stream(p, &f->u.stream, f->data);
|
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
|
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;
|
size_t len;
|
||||||
u_char *start;
|
u_char *start;
|
||||||
|
ngx_buf_t *b;
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
len = ngx_quic_varint_len(NGX_QUIC_FT_NEW_TOKEN);
|
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, NGX_QUIC_FT_NEW_TOKEN);
|
||||||
ngx_quic_build_int(&p, token->length);
|
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;
|
return p - start;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t length;
|
uint64_t length;
|
||||||
u_char *data;
|
|
||||||
} ngx_quic_new_token_frame_t;
|
} ngx_quic_new_token_frame_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user