TDLib update to 1.7.10 (#52)

TDLib update to 1.7.10
This commit is contained in:
Infactum 2021-12-10 15:22:19 +03:00 committed by GitHub
parent 6e08102559
commit 99805b7db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 25 deletions

View File

@ -7,7 +7,7 @@ add_subdirectory(libtgvoip)
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package(Td 1.6.0 REQUIRED)
find_package(Td 1.7.10 REQUIRED)
find_package(spdlog 0.17 REQUIRED)
pkg_check_modules(PJSIP libpjproject>=2.8 REQUIRED)
pkg_check_modules(OPUS opus REQUIRED)

View File

@ -14,9 +14,10 @@ RUN wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh \
COPY tdlib_header.patch /
COPY tdlib_threadname.patch /
# TDLib 1.7.10
RUN git clone https://github.com/tdlib/td.git \
&& cd td \
&& git reset --hard v1.6.0 \
&& git reset --hard a53cb30e99f937cfd64e0266fa558785a184a553 \
&& git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \
&& mkdir build \

View File

@ -20,10 +20,11 @@ RUN wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh \
COPY tdlib_header.patch /
COPY tdlib_threadname.patch /
# TDLib 1.7.10
RUN source /opt/rh/devtoolset-7/enable \
&& git clone https://github.com/tdlib/td.git \
&& cd td \
&& git reset --hard v1.6.0 \
&& git reset --hard a53cb30e99f937cfd64e0266fa558785a184a553 \
&& git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \
&& mkdir build \
@ -57,9 +58,10 @@ RUN source /opt/rh/devtoolset-7/enable \
&& rm -rf spdlog
RUN source /opt/rh/devtoolset-7/enable \
&& git clone --recursive https://github.com/linuxdeploy/linuxdeploy.git \
&& git clone https://github.com/linuxdeploy/linuxdeploy.git \
&& cd linuxdeploy \
&& git checkout 557bad2241df2c33972c7e6bdbf0c528cee27cc8 \
&& git submodule update --init --recursive \
&& mkdir build \
&& cd build \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIMG=0 .. \

View File

@ -1,8 +1,8 @@
diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp
index eafec324..3cce46f5 100644
index 0cbcde9c..50e05ffa 100644
--- a/td/telegram/Td.cpp
+++ b/td/telegram/Td.cpp
@@ -4899,10 +4899,10 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
@@ -4419,10 +4419,10 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
if (options_.application_version.empty()) {
return Status::Error(400, "Application version must be non-empty");
}
@ -14,6 +14,6 @@ index eafec324..3cce46f5 100644
+ // options_.application_version += ", TDLib ";
+ // options_.application_version += TDLIB_VERSION;
+ // }
options_.language_pack = "";
options_.language_code = "";
options_.parameters = "";
options_.language_pack = string();
options_.language_code = string();
options_.parameters = string();

View File

@ -25,6 +25,15 @@ namespace td_api = td::td_api;
volatile sig_atomic_t e_flag = 0;
namespace {
vector<string> voip_library_versions() {
// actually we want to provide real tgvoip version from
// tgvoip::VoIPController::GetVersion()
// but telegram servers accepts only this one
return vector<string>{"2.4.4"};
}
}
namespace state_machine::guards {
bool IsIncoming::operator()(const td::td_api::object_ptr<td::td_api::updateCall> &event) const {
return !event->call_->is_outgoing_;
@ -108,6 +117,7 @@ namespace state_machine::actions {
ctx.tg_call_id, /* call_id_ */
false, /* is_disconnected_ */
0, /* duration_ */
false, /* is_video_ */
ctx.tg_call_id /*connection_id */
)).get();
@ -211,7 +221,8 @@ namespace state_machine::actions {
td_api::make_object<td_api::callProtocol>(settings.udp_p2p(),
settings.udp_reflector(),
CALL_PROTO_MIN_LAYER,
tgvoip::VoIPController::GetConnectionMaxLayer())
tgvoip::VoIPController::GetConnectionMaxLayer(),
voip_library_versions())
)).get();
if (response->get_id() == td_api::error::ID) {
@ -337,13 +348,18 @@ namespace state_machine::actions {
voip_controller->SetEncryptionKey(encryption_key, event->call_->is_outgoing_);
vector<Endpoint> endpoints;
for (const auto &connection : state.connections_) {
for (const auto &server : state.servers_) {
if (server->type_->get_id() != td_api::callServerTypeTelegramReflector::ID)
continue;
auto reflector = static_cast<const td_api::callServerTypeTelegramReflector *>(server->type_.get());
unsigned char peer_tag[16];
memcpy(peer_tag, connection->peer_tag_.c_str(), 16);
auto ipv4 = IPv4Address(connection->ip_);
auto ipv6 = IPv6Address(connection->ipv6_);
endpoints.emplace_back(Endpoint(connection->id_,
static_cast<uint16_t>(connection->port_),
memcpy(peer_tag, reflector->peer_tag_.c_str(), 16);
auto ipv4 = IPv4Address(server->ip_address_);
auto ipv6 = IPv6Address(server->ipv6_address_);
endpoints.emplace_back(Endpoint(server->id_,
static_cast<uint16_t>(server->port_),
ipv4,
ipv6,
Endpoint::UDP_RELAY,
@ -419,12 +435,14 @@ namespace state_machine::actions {
}
}
void DialTg::dial_by_id(int32_t id) {
void DialTg::dial_by_id(int64_t id) {
auto response = tg_client_->send_query_async(td_api::make_object<td_api::createCall>(
id /* id */,
td_api::make_object<td_api::callProtocol>(settings_->udp_p2p(), settings_->udp_reflector(),
CALL_PROTO_MIN_LAYER,
tgvoip::VoIPController::GetConnectionMaxLayer()))
tgvoip::VoIPController::GetConnectionMaxLayer(),
voip_library_versions()),
false /* is_video_ */)
).get();
if (response->get_id() == td_api::error::ID) {
@ -535,7 +553,7 @@ namespace state_machine::actions {
return;
}
auto id = static_cast<int32_t>(chat->id_);
auto id = chat->id_;
DEBUG(logger_, "[{}] adding id {} for {} to username cache", ctx_->id(), id, ctx_->ext_username);
cache_->username_cache.emplace(ctx_->ext_username, id);
dial_by_id(id);
@ -835,15 +853,20 @@ void Gateway::process_event(td::td_api::object_ptr<td::td_api::updateCall> updat
void Gateway::process_event(td::td_api::object_ptr<td::td_api::updateNewMessage> update_message) {
auto &sender = update_message->message_->sender_id_;
if (sender->get_id() == td_api::messageSenderUser::ID)
return;
auto user = static_cast<const td_api::messageSenderUser *>(sender.get());
std::vector<Bridge *> matches;
for (auto bridge : bridges) {
if (bridge->ctx->user_id == update_message->message_->sender_user_id_) {
if (bridge->ctx->user_id == user->user_id_) {
matches.emplace_back(bridge);
}
}
if (matches.size() > 1) {
logger_->error("ambiguous message from {}", update_message->message_->sender_user_id_);
logger_->error("ambiguous message from {}", user->user_id_);
return;
} else if (matches.size() == 1) {
TRACE(logger_, "routing message to ctx {}", matches[0]->ctx->id());

View File

@ -170,7 +170,7 @@ namespace state_machine::actions {
void parse_error(td::td_api::object_ptr<td::td_api::error> error);
void dial_by_id(int32_t id);
void dial_by_id(int64_t id);
void dial_by_phone();
@ -226,8 +226,8 @@ namespace state_machine {
}
struct Cache {
std::map<std::string, int32_t> username_cache;
std::map<std::string, int32_t> phone_cache;
std::map<std::string, int64_t> username_cache;
std::map<std::string, int64_t> phone_cache;
};
class Context {
@ -242,7 +242,7 @@ public:
std::string ext_phone;
std::string ext_username;
int32_t user_id{0};
int64_t user_id{0};
pj::CallOpParam hangup_prm;