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(PkgConfig REQUIRED)
find_package(Threads 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) find_package(spdlog 0.17 REQUIRED)
pkg_check_modules(PJSIP libpjproject>=2.8 REQUIRED) pkg_check_modules(PJSIP libpjproject>=2.8 REQUIRED)
pkg_check_modules(OPUS opus 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_header.patch /
COPY tdlib_threadname.patch / COPY tdlib_threadname.patch /
# TDLib 1.7.10
RUN git clone https://github.com/tdlib/td.git \ RUN git clone https://github.com/tdlib/td.git \
&& cd td \ && cd td \
&& git reset --hard v1.6.0 \ && git reset --hard a53cb30e99f937cfd64e0266fa558785a184a553 \
&& git apply /tdlib_header.patch \ && git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \ && git apply /tdlib_threadname.patch \
&& mkdir build \ && 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_header.patch /
COPY tdlib_threadname.patch / COPY tdlib_threadname.patch /
# TDLib 1.7.10
RUN source /opt/rh/devtoolset-7/enable \ RUN source /opt/rh/devtoolset-7/enable \
&& git clone https://github.com/tdlib/td.git \ && git clone https://github.com/tdlib/td.git \
&& cd td \ && cd td \
&& git reset --hard v1.6.0 \ && git reset --hard a53cb30e99f937cfd64e0266fa558785a184a553 \
&& git apply /tdlib_header.patch \ && git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \ && git apply /tdlib_threadname.patch \
&& mkdir build \ && mkdir build \
@ -57,9 +58,10 @@ RUN source /opt/rh/devtoolset-7/enable \
&& rm -rf spdlog && rm -rf spdlog
RUN source /opt/rh/devtoolset-7/enable \ 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 \ && cd linuxdeploy \
&& git checkout 557bad2241df2c33972c7e6bdbf0c528cee27cc8 \ && git checkout 557bad2241df2c33972c7e6bdbf0c528cee27cc8 \
&& git submodule update --init --recursive \
&& mkdir build \ && mkdir build \
&& cd build \ && cd build \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIMG=0 .. \ && 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 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 --- a/td/telegram/Td.cpp
+++ b/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()) { if (options_.application_version.empty()) {
return Status::Error(400, "Application version must be non-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 ";
+ // options_.application_version += TDLIB_VERSION; + // options_.application_version += TDLIB_VERSION;
+ // } + // }
options_.language_pack = ""; options_.language_pack = string();
options_.language_code = ""; options_.language_code = string();
options_.parameters = ""; options_.parameters = string();

View File

@ -25,6 +25,15 @@ namespace td_api = td::td_api;
volatile sig_atomic_t e_flag = 0; 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 { namespace state_machine::guards {
bool IsIncoming::operator()(const td::td_api::object_ptr<td::td_api::updateCall> &event) const { bool IsIncoming::operator()(const td::td_api::object_ptr<td::td_api::updateCall> &event) const {
return !event->call_->is_outgoing_; return !event->call_->is_outgoing_;
@ -108,6 +117,7 @@ namespace state_machine::actions {
ctx.tg_call_id, /* call_id_ */ ctx.tg_call_id, /* call_id_ */
false, /* is_disconnected_ */ false, /* is_disconnected_ */
0, /* duration_ */ 0, /* duration_ */
false, /* is_video_ */
ctx.tg_call_id /*connection_id */ ctx.tg_call_id /*connection_id */
)).get(); )).get();
@ -211,7 +221,8 @@ namespace state_machine::actions {
td_api::make_object<td_api::callProtocol>(settings.udp_p2p(), td_api::make_object<td_api::callProtocol>(settings.udp_p2p(),
settings.udp_reflector(), settings.udp_reflector(),
CALL_PROTO_MIN_LAYER, CALL_PROTO_MIN_LAYER,
tgvoip::VoIPController::GetConnectionMaxLayer()) tgvoip::VoIPController::GetConnectionMaxLayer(),
voip_library_versions())
)).get(); )).get();
if (response->get_id() == td_api::error::ID) { 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_); voip_controller->SetEncryptionKey(encryption_key, event->call_->is_outgoing_);
vector<Endpoint> endpoints; 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]; unsigned char peer_tag[16];
memcpy(peer_tag, connection->peer_tag_.c_str(), 16); memcpy(peer_tag, reflector->peer_tag_.c_str(), 16);
auto ipv4 = IPv4Address(connection->ip_); auto ipv4 = IPv4Address(server->ip_address_);
auto ipv6 = IPv6Address(connection->ipv6_); auto ipv6 = IPv6Address(server->ipv6_address_);
endpoints.emplace_back(Endpoint(connection->id_, endpoints.emplace_back(Endpoint(server->id_,
static_cast<uint16_t>(connection->port_), static_cast<uint16_t>(server->port_),
ipv4, ipv4,
ipv6, ipv6,
Endpoint::UDP_RELAY, 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>( auto response = tg_client_->send_query_async(td_api::make_object<td_api::createCall>(
id /* id */, id /* id */,
td_api::make_object<td_api::callProtocol>(settings_->udp_p2p(), settings_->udp_reflector(), td_api::make_object<td_api::callProtocol>(settings_->udp_p2p(), settings_->udp_reflector(),
CALL_PROTO_MIN_LAYER, CALL_PROTO_MIN_LAYER,
tgvoip::VoIPController::GetConnectionMaxLayer())) tgvoip::VoIPController::GetConnectionMaxLayer(),
voip_library_versions()),
false /* is_video_ */)
).get(); ).get();
if (response->get_id() == td_api::error::ID) { if (response->get_id() == td_api::error::ID) {
@ -535,7 +553,7 @@ namespace state_machine::actions {
return; 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); DEBUG(logger_, "[{}] adding id {} for {} to username cache", ctx_->id(), id, ctx_->ext_username);
cache_->username_cache.emplace(ctx_->ext_username, id); cache_->username_cache.emplace(ctx_->ext_username, id);
dial_by_id(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) { 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; std::vector<Bridge *> matches;
for (auto bridge : bridges) { 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); matches.emplace_back(bridge);
} }
} }
if (matches.size() > 1) { if (matches.size() > 1) {
logger_->error("ambiguous message from {}", update_message->message_->sender_user_id_); logger_->error("ambiguous message from {}", user->user_id_);
return; return;
} else if (matches.size() == 1) { } else if (matches.size() == 1) {
TRACE(logger_, "routing message to ctx {}", matches[0]->ctx->id()); 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 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(); void dial_by_phone();
@ -226,8 +226,8 @@ namespace state_machine {
} }
struct Cache { struct Cache {
std::map<std::string, int32_t> username_cache; std::map<std::string, int64_t> username_cache;
std::map<std::string, int32_t> phone_cache; std::map<std::string, int64_t> phone_cache;
}; };
class Context { class Context {
@ -242,7 +242,7 @@ public:
std::string ext_phone; std::string ext_phone;
std::string ext_username; std::string ext_username;
int32_t user_id{0}; int64_t user_id{0};
pj::CallOpParam hangup_prm; pj::CallOpParam hangup_prm;