Sync local time with HTTP 'Date' header value.

This commit is contained in:
John Preston
2019-07-10 17:03:48 +02:00
parent c894ce30c4
commit 68b1024dd4
24 changed files with 356 additions and 55 deletions
@@ -12,14 +12,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace MTP {
struct ServiceWebRequest {
ServiceWebRequest(not_null<QNetworkReply*> reply);
ServiceWebRequest(ServiceWebRequest &&other);
ServiceWebRequest &operator=(ServiceWebRequest &&other);
~ServiceWebRequest();
ServiceWebRequest(not_null<QNetworkReply*> reply);
ServiceWebRequest(ServiceWebRequest &&other);
ServiceWebRequest &operator=(ServiceWebRequest &&other);
~ServiceWebRequest();
void destroy();
void destroy();
QPointer<QNetworkReply> reply;
QPointer<QNetworkReply> reply;
};
@@ -31,7 +31,9 @@ public:
const std::string &ip,
int port,
bytes::const_span secret)> callback,
Fn<void(TimeId)> timeCallback,
const QString &phone);
explicit SpecialConfigRequest(Fn<void(TimeId)> timeCallback);
private:
enum class Type {
@@ -46,6 +48,7 @@ private:
void sendNextRequest();
void performRequest(const Attempt &attempt);
void requestFinished(Type type, not_null<QNetworkReply*> reply);
void handleHeaderUnixtime(not_null<QNetworkReply*> reply);
QByteArray finalizeRequest(not_null<QNetworkReply*> reply);
void handleResponse(const QByteArray &bytes);
bool decryptSimpleConfig(const QByteArray &bytes);
@@ -55,6 +58,7 @@ private:
const std::string &ip,
int port,
bytes::const_span secret)> _callback;
Fn<void(TimeId)> _timeCallback;
QString _phone;
MTPhelp_ConfigSimple _simpleConfig;