Skip to content

Commit

Permalink
Update tquic version to v0.9.0 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofei0800 authored Apr 25, 2024
1 parent bd0e03a commit 6031a45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
7 changes: 6 additions & 1 deletion simple_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct simple_client {
struct sockaddr_storage local_addr;
socklen_t local_addr_len;
SSL_CTX *ssl_ctx;
struct quic_tls_config_t *tls_config;
struct quic_conn_t *conn;
struct ev_loop *loop;
};
Expand Down Expand Up @@ -146,6 +147,7 @@ int client_load_ssl_ctx(struct simple_client *client) {
fprintf(stderr, "set alpn failed\n");
return -1;
}
client->tls_config = quic_tls_config_new_with_ssl_ctx(client->ssl_ctx);

return 0;
}
Expand Down Expand Up @@ -295,7 +297,7 @@ int main(int argc, char *argv[]) {
ret = -1;
goto EXIT;
}
quic_config_set_tls_config(config, client.ssl_ctx);
quic_config_set_tls_config(config, client.tls_config);

// Create quic endpoint
client.quic_endpoint =
Expand Down Expand Up @@ -340,6 +342,9 @@ int main(int argc, char *argv[]) {
if (client.ssl_ctx != NULL) {
SSL_CTX_free(client.ssl_ctx);
}
if (client.tls_config != NULL) {
quic_tls_config_free(client.tls_config);
}
if (client.sock > 0) {
close(client.sock);
}
Expand Down
16 changes: 11 additions & 5 deletions simple_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct simple_server {
struct sockaddr_storage local_addr;
socklen_t local_addr_len;
SSL_CTX *ssl_ctx;
struct quic_tls_config_t *tls_config;
struct ev_loop *loop;
};

Expand Down Expand Up @@ -121,15 +122,16 @@ int server_on_packets_send(void *psctx, struct quic_packet_out_spec_t *pkts,
return sent_count;
}

SSL_CTX *server_get_default_tls_config(void *ctx) {
struct quic_tls_config_t *server_get_default_tls_config(void *ctx) {
struct simple_server *server = ctx;
return server->ssl_ctx;
return server->tls_config;
}

SSL_CTX *server_select_tls_config(void *ctx, const uint8_t *server_name,
size_t server_name_len) {
struct quic_tls_config_t *server_select_tls_config(void *ctx,
const uint8_t *server_name,
size_t server_name_len) {
struct simple_server *server = ctx;
return server->ssl_ctx;
return server->tls_config;
}

static char s_alpn[0x100];
Expand Down Expand Up @@ -179,6 +181,7 @@ int server_load_ssl_ctx(struct simple_server *server) {
return -1;
}
SSL_CTX_set_alpn_select_cb(server->ssl_ctx, select_alpn, NULL);
server->tls_config = quic_tls_config_new_with_ssl_ctx(server->ssl_ctx);

return 0;
}
Expand Down Expand Up @@ -370,6 +373,9 @@ int main(int argc, char *argv[]) {
if (server.ssl_ctx != NULL) {
SSL_CTX_free(server.ssl_ctx);
}
if (server.tls_config != NULL) {
quic_tls_config_free(server.tls_config);
}
if (server.sock > 0) {
close(server.sock);
}
Expand Down

0 comments on commit 6031a45

Please sign in to comment.