2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-04 00:15:42 +00:00

Send different dns requests for simple config.

This commit is contained in:
John Preston
2018-05-03 11:11:07 +03:00
parent ad1f089802
commit db7041f2dc
2 changed files with 183 additions and 103 deletions

View File

@@ -21,13 +21,31 @@ public:
bytes::const_span secret)> callback,
const QString &phone);
~SpecialConfigRequest();
private:
void performAppRequest();
void performDnsRequest();
void appFinished();
void dnsFinished();
enum class Type {
App,
Dns,
};
struct Attempt {
Type type;
QString domain;
};
struct Request {
Request(not_null<QNetworkReply*> reply);
Request(Request &&other);
Request &operator=(Request &&other);
~Request();
void destroy();
QPointer<QNetworkReply> reply;
};
void sendNextRequest();
void performRequest(const Attempt &attempt);
void requestFinished(Type type, not_null<QNetworkReply*> reply);
QByteArray finalizeRequest(not_null<QNetworkReply*> reply);
void handleResponse(const QByteArray &bytes);
bool decryptSimpleConfig(const QByteArray &bytes);
@@ -40,11 +58,8 @@ private:
MTPhelp_ConfigSimple _simpleConfig;
QNetworkAccessManager _manager;
std::unique_ptr<QNetworkReply> _appReply;
std::unique_ptr<QNetworkReply> _dnsReply;
std::unique_ptr<DcOptions> _localOptions;
std::unique_ptr<Instance> _localInstance;
std::vector<Attempt> _attempts;
std::vector<Request> _requests;
};