From 73e8059bf4ee71bb3f783feff1c43551f4f5bd8b Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 7 Jan 2025 17:47:22 +0100 Subject: [PATCH] ffi: expose Server Name Indication to FFI --- quiche/include/quiche.h | 3 +++ quiche/src/ffi.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/quiche/include/quiche.h b/quiche/include/quiche.h index 2d0a74dae2..59cd71fd9f 100644 --- a/quiche/include/quiche.h +++ b/quiche/include/quiche.h @@ -485,6 +485,9 @@ void quiche_conn_peer_cert(const quiche_conn *conn, const uint8_t **out, size_t // Returns the serialized cryptographic session for the connection. void quiche_conn_session(const quiche_conn *conn, const uint8_t **out, size_t *out_len); +// Returns the server name requested by the client. +void quiche_conn_server_name(const quiche_conn *conn, const uint8_t **out, size_t *out_len); + // Returns true if the connection handshake is complete. bool quiche_conn_is_established(const quiche_conn *conn); diff --git a/quiche/src/ffi.rs b/quiche/src/ffi.rs index d081911a86..4e158c4e80 100644 --- a/quiche/src/ffi.rs +++ b/quiche/src/ffi.rs @@ -1117,6 +1117,20 @@ pub extern fn quiche_conn_session( } } +#[no_mangle] +pub extern fn quiche_conn_server_name( + conn: &Connection, out: &mut *const u8, out_len: &mut size_t, +) { + match conn.server_name() { + Some(server_name) => { + *out = server_name.as_ptr(); + *out_len = server_name.len(); + }, + + None => *out_len = 0, + } +} + #[no_mangle] pub extern fn quiche_conn_is_established(conn: &Connection) -> bool { conn.is_established()