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