2018-12-31 20:04:05 +01:00
|
|
|
//
|
2018-01-02 14:42:31 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2018-05-08 14:50:33 +02:00
|
|
|
#include "td/telegram/net/ConnectionCreator.h"
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Slice.h"
|
|
|
|
|
|
|
|
namespace td {
|
2018-04-24 18:21:47 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class MtprotoHeader {
|
|
|
|
public:
|
|
|
|
struct Options {
|
|
|
|
int32 api_id;
|
|
|
|
string system_language_code;
|
|
|
|
string device_model;
|
|
|
|
string system_version;
|
|
|
|
string application_version;
|
2018-05-08 14:50:33 +02:00
|
|
|
Proxy proxy;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2018-05-08 22:02:15 +02:00
|
|
|
explicit MtprotoHeader(const Options &options) : options_(options) {
|
|
|
|
gen_headers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_proxy(Proxy proxy) {
|
|
|
|
options_.proxy = proxy;
|
|
|
|
default_header_ = gen_header(options_, false);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Slice get_default_header() const {
|
|
|
|
return default_header_;
|
|
|
|
}
|
|
|
|
Slice get_anonymous_header() const {
|
|
|
|
return anonymous_header_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-05-08 22:02:15 +02:00
|
|
|
Options options_;
|
2018-12-31 20:04:05 +01:00
|
|
|
string default_header_;
|
|
|
|
string anonymous_header_;
|
|
|
|
|
2018-05-08 22:02:15 +02:00
|
|
|
void gen_headers() {
|
|
|
|
default_header_ = gen_header(options_, false);
|
|
|
|
anonymous_header_ = gen_header(options_, true);
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static string gen_header(const Options &options, bool is_anonymous);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|