From b65a2a91c6606bd2680b06cab458fb7cff95654f Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 29 May 2023 15:39:40 +0100 Subject: [PATCH 1/3] Adds coloumn for upstream DNS in query log (#2) --- src/fetch/fetch_query_log.rs | 1 + src/widgets/table.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fetch/fetch_query_log.rs b/src/fetch/fetch_query_log.rs index 12186ec..f0de9bf 100644 --- a/src/fetch/fetch_query_log.rs +++ b/src/fetch/fetch_query_log.rs @@ -12,6 +12,7 @@ pub struct QueryResponse { pub struct Query { pub cached: bool, pub client: String, + pub upstream: String, #[serde(rename = "elapsedMs")] pub elapsed_ms: String, pub question: Question, diff --git a/src/widgets/table.rs b/src/widgets/table.rs index 038d11b..905815c 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -14,7 +14,7 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> { let time = Cell::from( time_ago(query.time.as_str()).unwrap_or("unknown".to_string()) ).style(Style::default().fg(Color::Gray)); - + let question = Cell::from(make_request_cell(&query.question).unwrap()) .style(Style::default().add_modifier(Modifier::BOLD)); @@ -27,8 +27,10 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> { let (status_txt, status_color) = block_status_text(&query.reason, query.cached); let status = Cell::from(status_txt).style(Style::default().fg(status_color)); + let upstream = Cell::from(query.upstream.as_str()).style(Style::default().fg(Color::Blue)); + let color = make_row_color(&query.reason); - Row::new(vec![time, question, status, client, elapsed_ms]) + Row::new(vec![time, question, status, client, upstream, elapsed_ms]) .style(Style::default().fg(color)) }).collect::>(); // Clone the data here @@ -38,6 +40,7 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> { Cell::from(Span::raw("Request")), Cell::from(Span::raw("Status")), Cell::from(Span::raw("Client")), + Cell::from(Span::raw("Upstream DNS")), Cell::from(Span::raw("Time Taken")), ])) .block( @@ -50,9 +53,10 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> { .widths(&[ Constraint::Percentage(15), Constraint::Percentage(35), + Constraint::Percentage(10), Constraint::Percentage(15), - Constraint::Percentage(20), Constraint::Percentage(15), + Constraint::Percentage(10), ]); table From 951e5a5be0a7254472806968f4ec718f2058a819 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 29 May 2023 16:07:06 +0100 Subject: [PATCH 2/3] Makes query log responsive, hide upstream dns + cilents on small screens (#2) --- src/ui.rs | 2 +- src/widgets/table.rs | 82 ++++++++++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index db70d7b..7fac6cd 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -64,7 +64,7 @@ pub async fn draw_ui( // Make the charts let gauge = make_gauge(&stats); - let table = make_query_table(&data); + let table = make_query_table(&data, size.width); let graph = make_history_chart(&stats); let paragraph = render_status_paragraph(&status, &stats); let filters = make_filters_list(filters.filters.as_slice(), size.width); diff --git a/src/widgets/table.rs b/src/widgets/table.rs index 905815c..57cbbcb 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -8,8 +8,7 @@ use tui::{ use chrono::{DateTime, Utc}; use crate::fetch::fetch_query_log::{Query, Question}; - -pub fn make_query_table(data: &[Query]) -> Table<'_> { +pub fn make_query_table(data: &[Query], width: u16) -> Table<'_> { let rows = data.iter().map(|query| { let time = Cell::from( time_ago(query.time.as_str()).unwrap_or("unknown".to_string()) @@ -30,36 +29,59 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> { let upstream = Cell::from(query.upstream.as_str()).style(Style::default().fg(Color::Blue)); let color = make_row_color(&query.reason); - Row::new(vec![time, question, status, client, upstream, elapsed_ms]) + Row::new(vec![time, question, status, elapsed_ms, client, upstream]) .style(Style::default().fg(color)) - }).collect::>(); // Clone the data here - - let table = Table::new(rows) // Table now owns its data - .header(Row::new(vec![ - Cell::from(Span::raw("Time")), - Cell::from(Span::raw("Request")), - Cell::from(Span::raw("Status")), - Cell::from(Span::raw("Client")), - Cell::from(Span::raw("Upstream DNS")), - Cell::from(Span::raw("Time Taken")), - ])) - .block( - Block::default() - .title(Span::styled( - "Query Log", - Style::default().add_modifier(Modifier::BOLD), - )) - .borders(Borders::ALL)) - .widths(&[ - Constraint::Percentage(15), - Constraint::Percentage(35), - Constraint::Percentage(10), - Constraint::Percentage(15), - Constraint::Percentage(15), - Constraint::Percentage(10), + }).collect::>(); + + + let title = Span::styled( + "Query Log", + Style::default().add_modifier(Modifier::BOLD), + ); + + let block = Block::default() + .title(title) + .borders(Borders::ALL); + + let mut headers = vec![ + Cell::from(Span::raw("Time")), + Cell::from(Span::raw("Request")), + Cell::from(Span::raw("Status")), + Cell::from(Span::raw("Time Taken")), + ]; + + if width > 120 { + headers.extend(vec![ + Cell::from(Span::raw("Client")), + Cell::from(Span::raw("Upstream DNS")), ]); - - table + + let widths = &[ + Constraint::Percentage(15), + Constraint::Percentage(35), + Constraint::Percentage(10), + Constraint::Percentage(10), + Constraint::Percentage(15), + Constraint::Percentage(15), + ]; + + Table::new(rows) + .header(Row::new(headers)) + .widths(widths) + .block(block) + } else { + let widths = &[ + Constraint::Percentage(20), + Constraint::Percentage(40), + Constraint::Percentage(20), + Constraint::Percentage(20), + ]; + + Table::new(rows) + .header(Row::new(headers)) + .widths(widths) + .block(block) + } } // Given a timestamp, return a string representing how long ago that was From 06e4228c5ebcf1926c9c1c53137c89652b2bc5d1 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 29 May 2023 16:10:07 +0100 Subject: [PATCH 3/3] Bumps version, updates changelog --- .github/CHANGELOG.md | 5 ++--- .github/README.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 6f1d70a..b61fb36 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -1,3 +1,2 @@ -- Improved deployment: 12Mb Docker image, 1-line install script, and publish to crates.io -- Adds documentation -- Faster start-up time +Adds new coloumn to query log, showing the upstream DNS server used for the query (#2) +Also updates the query log table to be responsive, so on smaller screens the upstream DNS and client IP won't be visible. diff --git a/.github/README.md b/.github/README.md index 4ec55b2..c2eb061 100644 --- a/.github/README.md +++ b/.github/README.md @@ -23,6 +23,9 @@ Features: - **Easy and Lightweight**: _AdGuardian can be run either with a super tiny Docker image, or directly with the zero-dependency executable_ - **Good and Safe**: _Written in Rust and unit tested, the app runs locally with no external requests, and (of course) it's fully open source_ +About AdGuard: + +[AdGuard Home](https://github.com/AdguardTeam/AdGuardHome) is a free and open source self-hosted (or managed) network-wide ad + tracker blocker. It operates as a DNS server that re-routes tracking domains to a "black hole", thus preventing your devices from connecting to those servers. It makes your internet, faster, safer and gives you a bunch of useful features, like encrypted DNS (DoH, DoT, DNSCrypt), parental controls, blocking of malware / phishing, per-device configs, custom DNS rules, etc.
Contents diff --git a/Cargo.lock b/Cargo.lock index 69fc732..d7d7009 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "adguardian" -version = "0.9.0" +version = "1.1.0" dependencies = [ "anyhow", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 1faebe3..b522921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "adguardian" -version = "1.0.0" +version = "1.1.0" edition = "2021" authors = ["Alicia Sykes"] description = "Terminal-based, real-time traffic monitoring and statistics for your AdGuard Home instance "