hold NetworkAddress and SocketConnection as the Connection members

This commit is contained in:
yggverse 2025-03-22 19:03:42 +02:00
parent 2102d8887a
commit a12a73d311
2 changed files with 9 additions and 5 deletions

View file

@ -74,8 +74,8 @@ impl Client {
Ok(socket_connection) => { Ok(socket_connection) => {
match Connection::build( match Connection::build(
socket_connection, socket_connection,
network_address,
certificate, certificate,
Some(network_address),
is_session_resumption, is_session_resumption,
) { ) {
Ok(connection) => connection.request_async( Ok(connection) => connection.request_async(

View file

@ -18,6 +18,8 @@ use glib::{
}; };
pub struct Connection { pub struct Connection {
pub network_address: NetworkAddress,
pub socket_connection: SocketConnection,
pub tls_client_connection: TlsClientConnection, pub tls_client_connection: TlsClientConnection,
} }
@ -27,24 +29,26 @@ impl Connection {
/// Create new `Self` /// Create new `Self`
pub fn build( pub fn build(
socket_connection: SocketConnection, socket_connection: SocketConnection,
network_address: NetworkAddress,
certificate: Option<TlsCertificate>, certificate: Option<TlsCertificate>,
server_identity: Option<NetworkAddress>,
is_session_resumption: bool, is_session_resumption: bool,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
Ok(Self { Ok(Self {
tls_client_connection: match new_tls_client_connection( tls_client_connection: match new_tls_client_connection(
&socket_connection, &socket_connection,
server_identity.as_ref(), Some(&network_address),
is_session_resumption, is_session_resumption,
) { ) {
Ok(tls_client_connection) => { Ok(tls_client_connection) => {
if let Some(ref certificate) = certificate { if let Some(ref c) = certificate {
tls_client_connection.set_certificate(certificate); tls_client_connection.set_certificate(c);
} }
tls_client_connection tls_client_connection
} }
Err(e) => return Err(e), Err(e) => return Err(e),
}, },
network_address,
socket_connection,
}) })
} }