Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: expose Server Name Indication to FFI #1895

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,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);

Expand Down
14 changes: 14 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,20 @@ pub extern "C" fn quiche_conn_session(
}
}

#[no_mangle]
pub extern "C" 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 "C" fn quiche_conn_is_established(conn: &Connection) -> bool {
conn.is_established()
Expand Down
Loading