mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
define SocketConnectable to resolve SNI requirement
This commit is contained in:
parent
69142fa60f
commit
3ca06362ed
@ -21,8 +21,8 @@ use crate::Profile;
|
||||
use gtk::{
|
||||
gdk_pixbuf::Pixbuf,
|
||||
gio::{
|
||||
Cancellable, IOStream, SocketClient, SocketClientEvent, SocketConnectable, SocketProtocol,
|
||||
TlsCertificate, TlsClientConnection,
|
||||
Cancellable, IOStream, NetworkAddress, SocketClient, SocketClientEvent, SocketConnectable,
|
||||
SocketProtocol, TlsCertificate, TlsClientConnection,
|
||||
},
|
||||
glib::{
|
||||
gformat, Bytes, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri,
|
||||
@ -428,11 +428,12 @@ impl Page {
|
||||
// Stream wrapper for TLS connections
|
||||
fn auth(
|
||||
connection: impl IsA<IOStream>,
|
||||
connectable: impl IsA<SocketConnectable>,
|
||||
certificate: Option<TlsCertificate>,
|
||||
) -> impl IsA<IOStream> {
|
||||
if let Some(certificate) = certificate {
|
||||
let tls_connection =
|
||||
TlsClientConnection::new(&connection, None::<&SocketConnectable>).unwrap(); // @TODO handle
|
||||
TlsClientConnection::new(&connection, Some(&connectable)).unwrap(); // @TODO handle
|
||||
tls_connection.set_certificate(&certificate);
|
||||
tls_connection.connect_accept_certificate(move |_, _, _| true); // @TODO manual validation
|
||||
tls_connection.upcast::<IOStream>()
|
||||
@ -504,15 +505,18 @@ impl Page {
|
||||
}
|
||||
});
|
||||
|
||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#server-name-indication
|
||||
let connectable = NetworkAddress::new(&uri.host().unwrap(), 1965);
|
||||
|
||||
// Create connection
|
||||
client.clone().connect_to_uri_async(
|
||||
url.clone().as_str(),
|
||||
1965,
|
||||
client.clone().connect_async(
|
||||
&connectable.clone(),
|
||||
Some(&cancellable.clone()),
|
||||
move |connect| match connect {
|
||||
Ok(connection) => {
|
||||
|
||||
// Encrypt stream using authorization TLS
|
||||
let stream = auth(connection, certificate);
|
||||
let stream = auth(connection, connectable, certificate);
|
||||
|
||||
// Send request
|
||||
stream.output_stream().write_bytes_async(
|
||||
|
Loading…
x
Reference in New Issue
Block a user