Skip to content

Commit

Permalink
Tidy up layout, particularly on macOS style. Add some default
Browse files Browse the repository at this point in the history
resolvers from stubby.
  • Loading branch information
wttw committed Jul 9, 2019
1 parent d586919 commit 8d316a2
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 640 deletions.
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -31,15 +31,17 @@ the content of each URL using each resolver to locate it.

## Bugs

Many probably. It's prone to just log and ignore errors rather than
Many, probably. It's prone to just log and ignore errors rather than
displaying them to the end user. This is not the tool you're looking
for as a sysadmin to diagnose a server, nor to show that a DNS resolver
is behavnig correctly.
is behaving correctly.

## TODO

* EDNS client subnet options

* Persuading tdns to add them

* UI, including a sensible default IP

* A better set of default resolvers - possibly snarfed from [stubby](https://github.com/getdnsapi/stubby)

* End user docs
* End user docs
12 changes: 10 additions & 2 deletions defaultResolvers.json
Expand Up @@ -2,8 +2,16 @@
"resolvers": [
{"name": "System resolver", "url": "system"},
{"name": "Google UDP", "url": "udp://8.8.8.8:53"},
{"name": "Google DNS over TLS", "url": "dot://dns.google"},
{"name": "Google over TLS", "url": "dot://dns.google"},
{"name": "Google https POST", "url": "https://dns.google/dns-query"},
{"name": "Google https GET", "url": "https://dns.google/dns-query{?dns}"},
{"name": "Quad9 (secure) over TLS", "url": "dot://9.9.9.9"},
{"name": "Quad9 (insecure) over TLS", "url": "dot://9.9.9.10"},
{"name": "Cloudflare over TLS", "url": "dot://cloudflare-dns.com"},
{"name": "Cloudflare https POST", "url": "https://cloudflare-dns.com/dns-query"},
{"name": "Cloudflare https GET", "url": "https://cloudflare-dns.com/dns-query{?dns}"}
{"name": "Cloudflare https GET", "url": "https://cloudflare-dns.com/dns-query{?dns}"},
{"name": "Uncensored DNS over TLS", "url": "dot://unicast.censurfridns.dk"},
{"name": "Adguard (default) over TLS", "url": "dot://dns.adguard.com"},
{"name": "Adguard (family protection) over TLS", "url": "dot://dns-family.adguard.com"}
]
}
45 changes: 31 additions & 14 deletions ping.cc
Expand Up @@ -15,28 +15,33 @@
#include <QElapsedTimer>
#include <QLineEdit>
#include <QSettings>
#include <QLabel>

/*
* A panel that will look up a site via a given resolver
* then time the round trip for a tcp connection to it.
*/
Ping::Ping(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res), sock(nullptr) {
auto inputForm = new QFormLayout;
inputForm->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);

resolver = new QComboBox;
resolver->setEditable(true);
resolver->setObjectName("query_resolver");
resolver->setObjectName("ping_resolver");
connect(resolvers, &Resolvers::resolversChanged, [=](){
resolvers->populateCombo(resolver);
});
resolvers->populateCombo(resolver);
inputForm->addRow(tr("Resolver"), resolver);
resolverAnno = new QLabel;
inputForm->addRow(QString(), resolverAnno);

name = new QComboBox;
name->setEditable(true);
name->setObjectName("query_name");
name->setObjectName("ping_name");
name->setInsertPolicy(QComboBox::InsertAtTop);
name->lineEdit()->setPlaceholderText(tr("e.g. https://yahoo.com/"));
name->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
inputForm->addRow(tr("Target website"), name);

auto buttonsLayout = new QHBoxLayout;
Expand All @@ -62,6 +67,8 @@ Ping::Ping(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res), s
resolver->setCurrentIndex(s.value("resolver", 0).toInt());
name->setCurrentText(s.value("name").toString());
s.endGroup();
updateResolverAnno();
connect(resolver, &QComboBox::currentTextChanged, this, &Ping::updateResolverAnno);
}

void Ping::saveState() {
Expand All @@ -72,6 +79,27 @@ void Ping::saveState() {
s.endGroup();
}

QString Ping::url() {
// We pull the resolver URL from the userdata for preloaded
// resolvers. But if the user has entered something manually
// then we use that instead. There's no great way to detect
// that, so we look to see if the displayed text is the same
// as the text that was set at this index.
if (!resolver->currentData().isNull() && resolver->currentText() == resolver->itemText(resolver->currentIndex())) {
return resolver->currentData().toString();
}
return resolver->currentText();
}

void Ping::updateResolverAnno() {
QString u = url();
if (u == resolver->currentText()) {
resolverAnno->clear();
return;
}
resolverAnno->setText(tr("<small>(%1)</small>").arg(u.toHtmlEscaped()));
}

void Ping::run() {
stop();
QUrl u = QUrl::fromUserInput(name->currentText());
Expand All @@ -82,18 +110,7 @@ void Ping::run() {

port = u.port(443);

QString resolverUrl;

// We pull the resolver URL from the userdata for preloaded
// resolvers. But if the user has entered something manually
// then we use that instead. There's no great way to detect
// that, so we look to see if the displayed text is the same
// as the text that was set at this index.
if (!resolver->currentData().isNull() && resolver->currentText() == resolver->itemText(resolver->currentIndex())) {
resolverUrl = resolver->currentData().toString();
} else {
resolverUrl = resolver->currentText();
}
QString resolverUrl = url();

auto qa = new DnsLookup("A", u.host(), resolverUrl, this);
auto qaaaa = new DnsLookup("AAAA", u.host(), resolverUrl, this);
Expand Down
6 changes: 5 additions & 1 deletion ping.h
Expand Up @@ -11,20 +11,24 @@ class QTextEdit;
class QTcpSocket;
class QElapsedTimer;
class Resolvers;
class QLabel;

class Ping : public QWidget {
Q_OBJECT
public:
Ping(Resolvers *res, QWidget *parent=0);
Ping(Resolvers *res, QWidget *parent=nullptr);
void saveState();
protected slots:
void run();
void pingQueue();
void stop();
void updateResolverAnno();
private:
QString url();
Resolvers *resolvers;
int port;
QComboBox *resolver;
QLabel *resolverAnno;
QComboBox *name;
QPushButton *go;
QTextEdit *results;
Expand Down
42 changes: 30 additions & 12 deletions query.cc
Expand Up @@ -12,13 +12,16 @@
#include <QFormLayout>
#include <QSettings>
#include <QLineEdit>
#include <QLabel>
#include <QSizePolicy>

/*
* A panel that'll lookup a DNS record via a chosen
* resolver and display it prettily.
*/
Query::Query(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res) {
auto inputForm = new QFormLayout;
inputForm->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);

resolver = new QComboBox;
resolver->setEditable(true);
Expand All @@ -27,7 +30,9 @@ Query::Query(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res)
resolvers->populateCombo(resolver);
});
resolvers->populateCombo(resolver);
resolverAnno = new QLabel;
inputForm->addRow(tr("Resolver"), resolver);
inputForm->addRow(QString(), resolverAnno);
type = new QComboBox;
type->setEditable(true);
type->setObjectName("query_type");
Expand All @@ -46,6 +51,7 @@ Query::Query(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res)
name->setObjectName("query_name");
name->setInsertPolicy(QComboBox::InsertAtTop);
name->lineEdit()->setPlaceholderText(tr("e.g. github.com"));
name->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
inputForm->addRow(tr("Query name"), name);

auto buttonsLayout = new QHBoxLayout;
Expand All @@ -69,6 +75,8 @@ Query::Query(Resolvers *res, QWidget *parent) : QWidget(parent), resolvers(res)
type->setCurrentIndex(s.value("type", 0).toInt());
name->setEditText(s.value("name").toString());
s.endGroup();
updateResolverAnno();
connect(resolver, &QComboBox::currentTextChanged, this, &Query::updateResolverAnno);
}

void Query::saveState() {
Expand All @@ -80,19 +88,29 @@ void Query::saveState() {
s.endGroup();
}

void Query::run() {
QString resolverUrl;
void Query::updateResolverAnno() {
QString u = url();
if (u == resolver->currentText()) {
resolverAnno->clear();
return;
}
resolverAnno->setText(tr("<small>(%1)</small>").arg(u.toHtmlEscaped()));
}

// We pull the resolver URL from the userdata for preloaded
// resolvers. But if the user has entered something manually
// then we use that instead. There's no great way to detect
// that, so we look to see if the displayed text is the same
// as the text that was set at this index.
if (!resolver->currentData().isNull() && resolver->currentText() == resolver->itemText(resolver->currentIndex())) {
resolverUrl = resolver->currentData().toString();
} else {
resolverUrl = resolver->currentText();
}
QString Query::url() {
// We pull the resolver URL from the userdata for preloaded
// resolvers. But if the user has entered something manually
// then we use that instead. There's no great way to detect
// that, so we look to see if the displayed text is the same
// as the text that was set at this index.
if (!resolver->currentData().isNull() && resolver->currentText() == resolver->itemText(resolver->currentIndex())) {
return resolver->currentData().toString();
}
return resolver->currentText();
}

void Query::run() {
QString resolverUrl = url();

QString queryType = type->currentText();
if (!type->currentData().isNull()) {
Expand Down
6 changes: 5 additions & 1 deletion query.h
Expand Up @@ -6,17 +6,21 @@ class QComboBox;
class QPushButton;
class QTextEdit;
class Resolvers;
class QLabel;

class Query : public QWidget {
Q_OBJECT
public:
Query(Resolvers *res, QWidget *parent=0);
Query(Resolvers *res, QWidget *parent=nullptr);
void saveState();
protected slots:
void run();
void updateResolverAnno();
private:
QString url();
Resolvers *resolvers;
QComboBox *resolver;
QLabel *resolverAnno;
QComboBox *type;
QComboBox *name;
QPushButton *go;
Expand Down
5 changes: 1 addition & 4 deletions thirdparty/README
Expand Up @@ -15,8 +15,5 @@ https://github.com/ahupowerdns/hello-dns
Lightly modified to remove dependency on simplesocket
by replacing ComboAddress with QHostAddress

## simplesocket

C++ helpers for sockets

https://github.com/ahupowerdns/simplesocket

108 changes: 0 additions & 108 deletions thirdparty/simplesocket/comboaddress.cc

This file was deleted.

0 comments on commit 8d316a2

Please sign in to comment.