-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdns.h
57 lines (47 loc) · 1.33 KB
/
dns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef DOX_DNS_H
#define DOX_DNS_H
#include <QObject>
#include <QHostAddress>
#include <QList>
#include <QString>
class QDnsLookup;
class DnsImplementation : public QObject {
Q_OBJECT
public:
DnsImplementation(QObject *parent);
virtual QString ErrorString() const = 0;
virtual QList<QHostAddress> Addresses() const = 0;
virtual QString PrettyResults() const = 0;
virtual void lookup() = 0;
qint64 responseTime;
signals:
void finished();
};
class BadImplementation : public DnsImplementation {
Q_OBJECT
public:
BadImplementation(const QString& error, QObject *parent=0);
QString ErrorString() const { return errorString ;}
QList<QHostAddress> Addresses() const {return QList<QHostAddress>{}; }
QString PrettyResults() const { return ErrorString(); }
void lookup();
private:
QString errorString;
};
class DnsLookup : public QObject {
Q_OBJECT
public:
DnsLookup(const QString &type, const QString &name, const QString resolver, QObject *parent = nullptr);
QString ErrorString() const;
QList<QHostAddress> Addresses() const;
QString PrettyResults();
qint64 responseTime() { return q->responseTime; }
bool hasError() const { return !ErrorString().isEmpty(); }
signals:
void finished();
public slots:
void lookup();
private:
DnsImplementation *q;
};
#endif