1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// Take a look at the license at the top of the repository in the LICENSE file.
use glib::{prelude::*, translate::*, IntoStrV};
use crate::{ProxyResolver, SimpleProxyResolver};
impl SimpleProxyResolver {
/// Creates a new [`SimpleProxyResolver`][crate::SimpleProxyResolver]. See
/// [`default-proxy`][struct@crate::SimpleProxyResolver#default-proxy] and
/// [`ignore-hosts`][struct@crate::SimpleProxyResolver#ignore-hosts] for more details on how the
/// arguments are interpreted.
/// ## `default_proxy`
/// the default proxy to use, eg
/// "socks://192.168.1.1"
/// ## `ignore_hosts`
/// an optional list of hosts/IP addresses
/// to not use a proxy for.
///
/// # Returns
///
/// a new [`SimpleProxyResolver`][crate::SimpleProxyResolver]
#[doc(alias = "g_simple_proxy_resolver_new")]
#[allow(clippy::new_ret_no_self)]
pub fn new(default_proxy: Option<&str>, ignore_hosts: impl IntoStrV) -> ProxyResolver {
unsafe {
ignore_hosts.run_with_strv(|ignore_hosts| {
from_glib_full(ffi::g_simple_proxy_resolver_new(
default_proxy.to_glib_none().0,
ignore_hosts.as_ptr() as *mut _,
))
})
}
}
}
pub trait SimpleProxyResolverExtManual: 'static {
/// Sets the list of ignored hosts.
///
/// See [`ignore-hosts`][struct@crate::SimpleProxyResolver#ignore-hosts] for more details on how the
/// `ignore_hosts` argument is interpreted.
/// ## `ignore_hosts`
/// [`None`]-terminated list of hosts/IP addresses
/// to not use a proxy for
#[doc(alias = "g_simple_proxy_resolver_set_ignore_hosts")]
fn set_ignore_hosts(&self, ignore_hosts: impl IntoStrV);
}
impl<O: IsA<SimpleProxyResolver>> SimpleProxyResolverExtManual for O {
fn set_ignore_hosts(&self, ignore_hosts: impl IntoStrV) {
unsafe {
ignore_hosts.run_with_strv(|ignore_hosts| {
ffi::g_simple_proxy_resolver_set_ignore_hosts(
self.as_ref().to_glib_none().0,
ignore_hosts.as_ptr() as *mut _,
);
})
}
}
}