Skip to content

Commit fccbfb7

Browse files
authored
Merge pull request Lissy93#3 from Lissy93/FEAT/show-upstream-dns
[Feature] Show upstream DNS in query log Fixes Lissy93#2
2 parents d7f5997 + a203de6 commit fccbfb7

File tree

7 files changed

+64
-35
lines changed

7 files changed

+64
-35
lines changed

.github/CHANGELOG.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
- Improved deployment: 12Mb Docker image, 1-line install script, and publish to crates.io
2-
- Adds documentation
3-
- Faster start-up time
1+
Adds new coloumn to query log, showing the upstream DNS server used for the query (#2)
2+
Also updates the query log table to be responsive, so on smaller screens the upstream DNS and client IP won't be visible.

.github/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Features:
2323
- **Easy and Lightweight**: _AdGuardian can be run either with a super tiny Docker image, or directly with the zero-dependency executable_
2424
- **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_
2525

26+
About AdGuard:
27+
28+
[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.
2629

2730
<details>
2831
<summary><b>Contents</b></summary>

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "adguardian"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
edition = "2021"
55
authors = ["Alicia Sykes"]
66
description = "Terminal-based, real-time traffic monitoring and statistics for your AdGuard Home instance "

src/fetch/fetch_query_log.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub struct QueryResponse {
1212
pub struct Query {
1313
pub cached: bool,
1414
pub client: String,
15+
pub upstream: String,
1516
#[serde(rename = "elapsedMs")]
1617
pub elapsed_ms: String,
1718
pub question: Question,

src/ui.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub async fn draw_ui(
6464

6565
// Make the charts
6666
let gauge = make_gauge(&stats);
67-
let table = make_query_table(&data);
67+
let table = make_query_table(&data, size.width);
6868
let graph = make_history_chart(&stats);
6969
let paragraph = render_status_paragraph(&status, &stats);
7070
let filters = make_filters_list(filters.filters.as_slice(), size.width);

src/widgets/table.rs

+55-29
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ use tui::{
88
use chrono::{DateTime, Utc};
99

1010
use crate::fetch::fetch_query_log::{Query, Question};
11-
12-
pub fn make_query_table(data: &[Query]) -> Table<'_> {
11+
pub fn make_query_table(data: &[Query], width: u16) -> Table<'_> {
1312
let rows = data.iter().map(|query| {
1413
let time = Cell::from(
1514
time_ago(query.time.as_str()).unwrap_or("unknown".to_string())
1615
).style(Style::default().fg(Color::Gray));
17-
16+
1817
let question = Cell::from(make_request_cell(&query.question).unwrap())
1918
.style(Style::default().add_modifier(Modifier::BOLD));
2019

@@ -27,35 +26,62 @@ pub fn make_query_table(data: &[Query]) -> Table<'_> {
2726
let (status_txt, status_color) = block_status_text(&query.reason, query.cached);
2827
let status = Cell::from(status_txt).style(Style::default().fg(status_color));
2928

29+
let upstream = Cell::from(query.upstream.as_str()).style(Style::default().fg(Color::Blue));
30+
3031
let color = make_row_color(&query.reason);
31-
Row::new(vec![time, question, status, client, elapsed_ms])
32+
Row::new(vec![time, question, status, elapsed_ms, client, upstream])
3233
.style(Style::default().fg(color))
33-
}).collect::<Vec<Row>>(); // Clone the data here
34-
35-
let table = Table::new(rows) // Table now owns its data
36-
.header(Row::new(vec![
37-
Cell::from(Span::raw("Time")),
38-
Cell::from(Span::raw("Request")),
39-
Cell::from(Span::raw("Status")),
40-
Cell::from(Span::raw("Client")),
41-
Cell::from(Span::raw("Time Taken")),
42-
]))
43-
.block(
44-
Block::default()
45-
.title(Span::styled(
46-
"Query Log",
47-
Style::default().add_modifier(Modifier::BOLD),
48-
))
49-
.borders(Borders::ALL))
50-
.widths(&[
51-
Constraint::Percentage(15),
52-
Constraint::Percentage(35),
53-
Constraint::Percentage(15),
54-
Constraint::Percentage(20),
55-
Constraint::Percentage(15),
34+
}).collect::<Vec<Row>>();
35+
36+
37+
let title = Span::styled(
38+
"Query Log",
39+
Style::default().add_modifier(Modifier::BOLD),
40+
);
41+
42+
let block = Block::default()
43+
.title(title)
44+
.borders(Borders::ALL);
45+
46+
let mut headers = vec![
47+
Cell::from(Span::raw("Time")),
48+
Cell::from(Span::raw("Request")),
49+
Cell::from(Span::raw("Status")),
50+
Cell::from(Span::raw("Time Taken")),
51+
];
52+
53+
if width > 120 {
54+
headers.extend(vec![
55+
Cell::from(Span::raw("Client")),
56+
Cell::from(Span::raw("Upstream DNS")),
5657
]);
57-
58-
table
58+
59+
let widths = &[
60+
Constraint::Percentage(15),
61+
Constraint::Percentage(35),
62+
Constraint::Percentage(10),
63+
Constraint::Percentage(10),
64+
Constraint::Percentage(15),
65+
Constraint::Percentage(15),
66+
];
67+
68+
Table::new(rows)
69+
.header(Row::new(headers))
70+
.widths(widths)
71+
.block(block)
72+
} else {
73+
let widths = &[
74+
Constraint::Percentage(20),
75+
Constraint::Percentage(40),
76+
Constraint::Percentage(20),
77+
Constraint::Percentage(20),
78+
];
79+
80+
Table::new(rows)
81+
.header(Row::new(headers))
82+
.widths(widths)
83+
.block(block)
84+
}
5985
}
6086

6187
// Given a timestamp, return a string representing how long ago that was

0 commit comments

Comments
 (0)