mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
hold socket address info
This commit is contained in:
parent
0729c20536
commit
3d7818fbd6
3 changed files with 414 additions and 390 deletions
|
|
@ -176,7 +176,20 @@ fn handle(
|
||||||
let page = page.clone();
|
let page = page.clone();
|
||||||
let redirects = redirects.clone();
|
let redirects = redirects.clone();
|
||||||
move |result| match result {
|
move |result| match result {
|
||||||
Ok((response, connection)) => match response {
|
Ok((response, connection)) => {
|
||||||
|
// Update socket info at the point, where the connection is active yet
|
||||||
|
{
|
||||||
|
use gtk::prelude::SocketConnectionExt;
|
||||||
|
let mut i = page.navigation.request.info.borrow_mut();
|
||||||
|
i.set_socket(
|
||||||
|
connection.socket_connection.local_address().unwrap(),
|
||||||
|
connection.socket_connection.remote_address().unwrap()
|
||||||
|
);
|
||||||
|
// * unwrap fails only on `connection.socket_connection.is_closed()`
|
||||||
|
// drop the panic as unexpected.
|
||||||
|
}
|
||||||
|
// Handle response
|
||||||
|
match response {
|
||||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#input-expected
|
// https://geminiprotocol.net/docs/protocol-specification.gmi#input-expected
|
||||||
Response::Input(input) => {
|
Response::Input(input) => {
|
||||||
let t = input.to_string();
|
let t = input.to_string();
|
||||||
|
|
@ -600,6 +613,7 @@ fn handle(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let s = page.content.to_status_failure();
|
let s = page.content.to_status_failure();
|
||||||
s.set_description(Some(&e.to_string()));
|
s.set_description(Some(&e.to_string()));
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
mod dialog;
|
mod dialog;
|
||||||
|
mod event;
|
||||||
// Public dependencies
|
mod socket;
|
||||||
|
|
||||||
pub mod event;
|
|
||||||
pub use event::Event;
|
|
||||||
|
|
||||||
// Local dependencies
|
|
||||||
|
|
||||||
use dialog::Dialog;
|
use dialog::Dialog;
|
||||||
use gtk::{gio::NetworkAddress, prelude::IsA};
|
use event::Event;
|
||||||
|
use gtk::{gio::SocketAddress, prelude::IsA};
|
||||||
|
use socket::Socket;
|
||||||
|
|
||||||
/// Common, shared `Page` information holder
|
/// Common, shared `Page` information holder
|
||||||
/// * used for the Information dialog window on request indicator activate
|
/// * used for the Information dialog window on request indicator activate
|
||||||
|
|
@ -24,13 +21,13 @@ pub struct Info {
|
||||||
/// Hold redirections chain with handled details
|
/// Hold redirections chain with handled details
|
||||||
/// * the `referrer` member name is reserved for other protocols
|
/// * the `referrer` member name is reserved for other protocols
|
||||||
redirect: Option<Box<Self>>,
|
redirect: Option<Box<Self>>,
|
||||||
/// Optional remote host details
|
|
||||||
/// * useful also for geo-location feature
|
|
||||||
remote: Option<NetworkAddress>,
|
|
||||||
/// Key to relate data collected with the specific request
|
/// Key to relate data collected with the specific request
|
||||||
request: Option<String>,
|
request: Option<String>,
|
||||||
/// Hold page content size
|
/// Hold page content size
|
||||||
size: Option<usize>,
|
size: Option<usize>,
|
||||||
|
/// Optional socket details
|
||||||
|
/// * useful also for geo-location feature
|
||||||
|
socket: Option<Socket>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Info {
|
impl Info {
|
||||||
|
|
@ -43,9 +40,9 @@ impl Info {
|
||||||
is_deprecated: false,
|
is_deprecated: false,
|
||||||
mime: None,
|
mime: None,
|
||||||
redirect: None,
|
redirect: None,
|
||||||
remote: None,
|
|
||||||
request: None,
|
request: None,
|
||||||
size: None,
|
size: None,
|
||||||
|
socket: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,8 +83,15 @@ impl Info {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_remote(&mut self, remote: Option<NetworkAddress>) -> &mut Self {
|
pub fn set_socket(
|
||||||
self.remote = remote;
|
&mut self,
|
||||||
|
local_address: SocketAddress,
|
||||||
|
remote_address: SocketAddress,
|
||||||
|
) -> &mut Self {
|
||||||
|
self.socket = Some(Socket {
|
||||||
|
local_address,
|
||||||
|
remote_address,
|
||||||
|
});
|
||||||
self.is_deprecated = false;
|
self.is_deprecated = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
use gtk::gio::SocketAddress;
|
||||||
|
|
||||||
|
pub struct Socket {
|
||||||
|
pub local_address: SocketAddress,
|
||||||
|
pub remote_address: SocketAddress,
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue