mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
apply proxy mask to the host only
This commit is contained in:
parent
b9e809fac9
commit
a47abac138
2 changed files with 25 additions and 24 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use gtk::{
|
||||
Align, Box, Button, Entry, Switch,
|
||||
glib::{DateTime, GString},
|
||||
prelude::{BoxExt, ButtonExt, EditableExt, WidgetExt},
|
||||
Align, Box, Button, Entry, Switch,
|
||||
};
|
||||
|
||||
pub struct Row {
|
||||
|
|
@ -35,7 +35,7 @@ impl Row {
|
|||
|
||||
let request = Entry::builder()
|
||||
.hexpand(true)
|
||||
.placeholder_text("Request")
|
||||
.placeholder_text("Host")
|
||||
.text(request.unwrap_or(".*"))
|
||||
.tooltip_text("Supports regex expressions")
|
||||
.build();
|
||||
|
|
@ -79,8 +79,8 @@ impl Row {
|
|||
let c = std::rc::Rc::new(on_delete);
|
||||
move |this| {
|
||||
use adw::{
|
||||
AlertDialog, ResponseAppearance,
|
||||
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
|
||||
AlertDialog, ResponseAppearance,
|
||||
};
|
||||
|
||||
const RESPONSE_CONFIRM: (&str, &str) = ("confirm", "Confirm");
|
||||
|
|
|
|||
|
|
@ -484,26 +484,27 @@ fn refresh_proxy_resolver(
|
|||
) {
|
||||
const NONE: &[&str] = &[];
|
||||
|
||||
let t = entry.text(); // allocate once
|
||||
|
||||
match profile.proxy.matches(&t) {
|
||||
Some(m) => {
|
||||
let (css_classes, tooltip_text) = match m.lookup(&t, Cancellable::NONE) {
|
||||
Ok(h) => (&["accent"], format!("Proxy over {}", h.join(","))),
|
||||
Err(i) => (&["error"], i.to_string()),
|
||||
};
|
||||
entry.set_css_classes(if profile.proxy.misc.is_highlight_request_entry() {
|
||||
css_classes
|
||||
} else {
|
||||
NONE
|
||||
});
|
||||
entry.set_tooltip_text(Some(&tooltip_text));
|
||||
resolver.replace(Some(m));
|
||||
}
|
||||
None => {
|
||||
entry.set_css_classes(NONE);
|
||||
entry.set_tooltip_text(None);
|
||||
resolver.replace(None);
|
||||
}
|
||||
// apply condition only to valid host found in the request entry
|
||||
// * in other case, the raw request string may include just user input
|
||||
// which may contain another 'host' in the request substring after '?'
|
||||
if let Some(u) = uri(entry)
|
||||
&& let Some(h) = u.host()
|
||||
&& let Some(m) = profile.proxy.matches(&h)
|
||||
{
|
||||
let (css_classes, tooltip_text) = match m.lookup(&entry.text(), Cancellable::NONE) {
|
||||
Ok(r) => (&["accent"], format!("Proxy over {}", r.join(","))),
|
||||
Err(i) => (&["error"], i.to_string()),
|
||||
};
|
||||
entry.set_css_classes(if profile.proxy.misc.is_highlight_request_entry() {
|
||||
css_classes
|
||||
} else {
|
||||
NONE
|
||||
});
|
||||
entry.set_tooltip_text(Some(&tooltip_text));
|
||||
resolver.replace(Some(m));
|
||||
} else {
|
||||
entry.set_css_classes(NONE);
|
||||
entry.set_tooltip_text(None);
|
||||
resolver.replace(None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue