Skip to content

Commit

Permalink
record if ESNI was used
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Jul 6, 2018
1 parent 9a80f72 commit 4f699f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/picotls.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ typedef struct st_ptls_handshake_properties_t {
* if retry should be stateless (cookie.key MUST be set when this option is used)
*/
unsigned retry_uses_cookie : 1;
/**
* if esni was used
*/
unsigned esni : 1;
} server;
};
/**
Expand Down
8 changes: 5 additions & 3 deletions lib/picotls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3187,21 +3187,23 @@ static int server_handle_hello(ptls_t *tls, struct st_ptls_message_emitter_t *em
if (!is_second_flight) {
memcpy(tls->client_random, ch.random_bytes, sizeof(tls->client_random));
ptls_iovec_t server_name = {NULL};
int should_free_server_name = 0;
int is_esni = 0;
if (ch.server_name.base != NULL) {
server_name = ch.server_name;
} else if (ch.esni.cipher != NULL && tls->ctx->esni != NULL) {
if ((ret = client_hello_decode_esni(tls->ctx, &key_share.algorithm, &key_share.peer_key, &server_name, &ch)) != 0)
goto Exit;
should_free_server_name = 1;
is_esni = 1;
}
if (properties != NULL)
properties->server.esni = is_esni;
if (tls->ctx->on_client_hello != NULL) {
ret = tls->ctx->on_client_hello->cb(tls->ctx->on_client_hello, tls, server_name, ch.alpn.list, ch.alpn.count,
ch.signature_algorithms.list, ch.signature_algorithms.count);
} else {
ret = 0;
}
if (should_free_server_name)
if (is_esni)
free(server_name.base);
if (ret != 0)
goto Exit;
Expand Down

0 comments on commit 4f699f8

Please sign in to comment.