mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-04-01 01:25:32 +00:00
add to_network_address method
This commit is contained in:
parent
4e712260ff
commit
ffda3d27e3
2 changed files with 16 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
pub mod error;
|
||||
pub use error::Error;
|
||||
|
||||
use crate::client::DEFAULT_PORT;
|
||||
use gio::NetworkAddress;
|
||||
use glib::{GString, Uri, UriFlags, UriHideFlags};
|
||||
|
||||
/// Scope implement path prefix to apply TLS authorization for
|
||||
|
|
@ -38,4 +40,14 @@ impl Scope {
|
|||
self.uri
|
||||
.to_string_partial(UriHideFlags::QUERY | UriHideFlags::FRAGMENT)
|
||||
}
|
||||
|
||||
/// Get [NetworkAddress](https://docs.gtk.org/gio/class.NetworkAddress.html)
|
||||
/// implement [SocketConnectable](https://docs.gtk.org/gio/iface.SocketConnectable.html) interface
|
||||
/// * useful as [SNI](https://geminiprotocol.net/docs/protocol-specification.gmi#server-name-indication) in TLS context
|
||||
pub fn to_network_address(&self) -> Result<NetworkAddress, Error> {
|
||||
match crate::gio::network_address::from_uri(&self.uri, DEFAULT_PORT) {
|
||||
Ok(network_address) => Ok(network_address),
|
||||
Err(reason) => Err(Error::NetworkAddress(reason)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue