tdlib update to 1.6.0

This commit is contained in:
infactum 2020-07-25 13:46:31 +03:00 committed by Infactum
parent f4495ede1b
commit b5784d54f9
12 changed files with 121 additions and 83 deletions

View File

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

View File

@ -8,21 +8,21 @@ RUN apt-get update \
zlib1g-dev gperf ccache \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \
&& sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir
RUN wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh \
&& sh cmake-3.18.0-Linux-x86_64.sh --prefix=/usr --exclude-subdir
COPY tdlib_header.patch /
COPY tdlib_threadname.patch /
RUN git clone https://github.com/tdlib/td.git \
&& cd td \
&& git reset --hard v1.2.0 \
&& git reset --hard v1.6.0 \
&& git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf td
@ -33,7 +33,7 @@ RUN git clone https://github.com/pjsip/pjproject.git \
&& git reset --hard 2.9 \
&& cp /config_site.h pjlib/include/pj \
&& ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \
&& make dep && make && make install \
&& make dep && make -j $(grep -c ^processor /proc/cpuinfo) && make install \
&& cd / \
&& rm -rf pjproject
@ -43,6 +43,6 @@ RUN git clone -n https://github.com/gabime/spdlog.git \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf spdlog

View File

@ -7,7 +7,7 @@ RUN yum -y install centos-release-scl yum-utils \
RUN set -xe \
&& yum install -y \
make \
make patch \
git wget \
zlib-devel openssl-devel gperf \
pkgconfig ccache gperf unzip \
@ -15,8 +15,27 @@ RUN set -xe \
epel-release \
&& yum install -y opus-devel patchelf
RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \
&& sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir
RUN wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh \
&& sh cmake-3.18.0-Linux-x86_64.sh --prefix=/usr --exclude-subdir
COPY glibc_gcc.patch /
RUN source /opt/rh/devtoolset-7/enable \
&& wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz \
&& tar zxf glibc-2.14.tar.gz \
&& rm glibc-2.14.tar.gz \
&& cd glibc-2.14 \
&& patch < /glibc_gcc.patch \
&& gcc --version \
&& mkdir build \
&& cd build \
&& ../configure --prefix=/opt/glibc-2.14 \
&& make -j $(grep -c ^processor /proc/cpuinfo) \
&& make install \
&& cd / \
&& rm -rf glibc-2.14 \
ENV LD_LIBRARY_PATH="/opt/glibc-2.14/lib:${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
COPY tdlib_header.patch /
COPY tdlib_threadname.patch /
@ -24,13 +43,14 @@ COPY tdlib_threadname.patch /
RUN source /opt/rh/devtoolset-7/enable \
&& git clone https://github.com/tdlib/td.git \
&& cd td \
&& git reset --hard v1.2.0 \
&& git reset --hard v1.6.0 \
&& git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \
&& mkdir build \
&& cd build \
&& export CPLUS_INCLUDE_PATH="/opt/glibc-2.14/include" \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf td
@ -42,7 +62,7 @@ RUN source /opt/rh/devtoolset-7/enable \
&& git reset --hard 2.9 \
&& cp /config_site.h pjlib/include/pj \
&& ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \
&& make dep && make && make install \
&& make dep && make -j $(grep -c ^processor /proc/cpuinfo) && make install \
&& cd / \
&& rm -rf pjproject
@ -53,7 +73,7 @@ RUN source /opt/rh/devtoolset-7/enable \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf spdlog
@ -64,7 +84,7 @@ RUN source /opt/rh/devtoolset-7/enable \
&& mkdir build \
&& cd build \
&& export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIMG=0 .. \
&& cmake --build . \
&& cmake --build . -j $(grep -c ^processor /proc/cpuinfo) \
&& cp bin/linuxdeploy /usr/local/bin \
&& cd / \
&& rm -rf linuxdeploy

View File

@ -11,8 +11,8 @@ RUN yum install -y \
zlib-devel opus-devel openssl-devel gperf \
pkgconfig ccache gperf unzip
RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \
&& sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir
RUN wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh \
&& sh cmake-3.18.0-Linux-x86_64.sh --prefix=/usr --exclude-subdir
COPY tdlib_header.patch /
COPY tdlib_threadname.patch /
@ -20,13 +20,13 @@ COPY tdlib_threadname.patch /
RUN source /opt/rh/devtoolset-7/enable \
&& git clone https://github.com/tdlib/td.git \
&& cd td \
&& git reset --hard v1.2.0 \
&& git reset --hard v1.6.0 \
&& git apply /tdlib_header.patch \
&& git apply /tdlib_threadname.patch \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf td
@ -38,7 +38,7 @@ RUN source /opt/rh/devtoolset-7/enable \
&& git reset --hard 2.9 \
&& cp /config_site.h pjlib/include/pj \
&& ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \
&& make dep && make && make install \
&& make dep && make -j $(grep -c ^processor /proc/cpuinfo) && make install \
&& cd / \
&& rm -rf pjproject
@ -49,7 +49,7 @@ RUN source /opt/rh/devtoolset-7/enable \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \
&& cmake --build . --target install \
&& cmake --build . --target install -j $(grep -c ^processor /proc/cpuinfo) \
&& cd / \
&& rm -rf spdlog

17
buildenv/glibc_gcc.patch Normal file
View File

@ -0,0 +1,17 @@
diff --git a/configure b/configure
index 6cf85e5..2613fc4 100755
--- a/configure
+++ b/configure
@@ -4938,10 +4938,10 @@ else
$as_echo_n "checking version of $CC... " >&6; }
ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
- '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=no;;
3.4* | 4.[0-9]* )
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
- *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=no;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5

View File

@ -1,5 +1,7 @@
#!/bin/bash
set -e
DOCKER_IMAGE=infactum/tg2sip-builder
for DOCKER_TAG in bionic centos6 centos7

View File

@ -1,19 +1,19 @@
diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp
index a150e6c..cd66d91 100644
index eafec324..3cce46f5 100644
--- a/td/telegram/Td.cpp
+++ b/td/telegram/Td.cpp
@@ -4827,10 +4827,10 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
if (options.application_version.empty()) {
@@ -4899,10 +4899,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");
}
- if (options.api_id != 21724) {
- options.application_version += ", TDLib ";
- options.application_version += TDLIB_VERSION;
- if (options_.api_id != 21724) {
- options_.application_version += ", TDLib ";
- options_.application_version += TDLIB_VERSION;
- }
+ // if (options.api_id != 21724) {
+ // options.application_version += ", TDLib ";
+ // options.application_version += TDLIB_VERSION;
+ // if (options_.api_id != 21724) {
+ // options_.application_version += ", TDLib ";
+ // options_.application_version += TDLIB_VERSION;
+ // }
G()->set_mtproto_header(std::make_unique<MtprotoHeader>(options));
state_ = State::Decrypt;
options_.language_pack = "";
options_.language_code = "";
options_.parameters = "";

View File

@ -1,8 +1,8 @@
diff --git a/tdutils/td/utils/port/detail/ThreadStl.h b/tdutils/td/utils/port/detail/ThreadStl.h
index 64bf321..68d3bf6 100644
index ef6ff475..c0e18ee4 100644
--- a/tdutils/td/utils/port/detail/ThreadStl.h
+++ b/tdutils/td/utils/port/detail/ThreadStl.h
@@ -37,6 +37,7 @@ class ThreadStl {
@@ -41,6 +41,7 @@ class ThreadStl {
invoke_tuple(std::move(args));
clear_thread_locals();
});

View File

@ -57,12 +57,9 @@ namespace state_machine::guards {
// the event type 16 (flash) as stated in RFC 4730.
// PJSUA maximum number of characters are 32.
auto content = td_api::move_object_as<td_api::messageText>(event->message_->content_);
auto text = static_cast<const td_api::messageText &>(*event->message_->content_).text_->text_;
const std::regex dtmf_regex("^[0-9A-D*#]{1,32}$");
auto result = regex_match(content->text_->text_, dtmf_regex);
// Don't forget to put data back!
event->message_->content_ = td_api::move_object_as<td_api::MessageContent>(content);
auto result = regex_match(text, dtmf_regex);
return result;
}
@ -312,7 +309,7 @@ namespace state_machine::actions {
using namespace tgvoip;
auto state = td_api::move_object_as<td_api::callStateReady>(event->call_->state_);
const auto &state = static_cast<const td_api::callStateReady &>(*event->call_->state_);
auto voip_controller = std::make_shared<VoIPController>();
static auto config = VoIPController::Config(
@ -336,11 +333,11 @@ namespace state_machine::actions {
}
char encryption_key[256];
memcpy(encryption_key, state->encryption_key_.c_str(), 256);
memcpy(encryption_key, state.encryption_key_.c_str(), 256);
voip_controller->SetEncryptionKey(encryption_key, event->call_->is_outgoing_);
vector<Endpoint> endpoints;
for (auto &connection : state->connections_) {
for (const auto &connection : state.connections_) {
unsigned char peer_tag[16];
memcpy(peer_tag, connection->peer_tag_.c_str(), 16);
auto ipv4 = IPv4Address(connection->ip_);
@ -566,10 +563,10 @@ namespace state_machine::actions {
const td_api::object_ptr<td::td_api::updateNewMessage> &event,
std::shared_ptr<spdlog::logger> logger) const {
auto content = td_api::move_object_as<td_api::messageText>(event->message_->content_);
DEBUG(logger, "[{}] sending DTMF {}", ctx.id(), content->text_->text_);
auto text = static_cast<const td_api::messageText &>(*event->message_->content_).text_->text_;
DEBUG(logger, "[{}] sending DTMF {}", ctx.id(), text);
try {
sip_client.DialDtmf(ctx.sip_call_id, content->text_->text_);
sip_client.DialDtmf(ctx.sip_call_id, text);
} catch (const pj::Error &error) {
logger->error(error.reason);
}

View File

@ -152,20 +152,21 @@ private:
sequence_done = true;
std::cerr << "Terminated" << std::endl;
},
[this](td_api::authorizationStateWaitCode &wait_code) {
std::string first_name;
std::string last_name;
if (!wait_code.is_registered_) {
std::cerr << "Enter your first name: ";
std::cin >> first_name;
std::cerr << "Enter your last name: ";
std::cin >> last_name;
}
std::cerr << "Enter authentication code: ";
[this](td_api::authorizationStateWaitCode &) {
std::cout << "Enter authentication code: " << std::flush;
std::string code;
std::cin >> code;
send_query(
td_api::make_object<td_api::checkAuthenticationCode>(code, first_name, last_name),
send_query(td_api::make_object<td_api::checkAuthenticationCode>(code),
create_authentication_query_handler());
},
[this](td_api::authorizationStateWaitRegistration &) {
std::string first_name;
std::string last_name;
std::cout << "Enter your first name: " << std::flush;
std::cin >> first_name;
std::cout << "Enter your last name: " << std::flush;
std::cin >> last_name;
send_query(td_api::make_object<td_api::registerUser>(first_name, last_name),
create_authentication_query_handler());
},
[this](td_api::authorizationStateWaitPassword &) {
@ -175,34 +176,35 @@ private:
send_query(td_api::make_object<td_api::checkAuthenticationPassword>(password),
create_authentication_query_handler());
},
[this](td_api::authorizationStateWaitOtherDeviceConfirmation &state) {
std::cout << "Confirm this login link on another device: " << state.link_ << std::endl;
},
[this](td_api::authorizationStateWaitPhoneNumber &) {
std::cerr << "Enter phone number: ";
std::cout << "Enter phone number: " << std::flush;
std::string phone_number;
std::cin >> phone_number;
send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>(
phone_number, false /*allow_flash_calls*/, false /*is_current_phone_number*/),
send_query(td_api::make_object<td_api::setAuthenticationPhoneNumber>(phone_number, nullptr),
create_authentication_query_handler());
},
[this](td_api::authorizationStateWaitEncryptionKey &) {
send_query(td_api::make_object<td_api::checkDatabaseEncryptionKey>(""),
create_authentication_query_handler());
td_api::object_ptr<td_api::Proxy> proxy;
if (settings.proxy_enabled()) {
auto socks_proxy = td_api::make_object<td_api::proxySocks5>(
settings.proxy_address(),
settings.proxy_port(),
auto socks_proxy_type = td_api::make_object<td_api::proxyTypeSocks5>(
settings.proxy_username(),
settings.proxy_password()
);
proxy = td_api::move_object_as<td_api::Proxy>(socks_proxy);
} else {
auto empty_proxy = td_api::make_object<td_api::proxyEmpty>();
proxy = td_api::move_object_as<td_api::Proxy>(empty_proxy);
}
send_query(td_api::make_object<td_api::setProxy>(
td_api::move_object_as<td_api::Proxy>(proxy)),
send_query(td_api::make_object<td_api::addProxy>(
settings.proxy_address(),
settings.proxy_port(),
true,
td_api::move_object_as<td_api::ProxyType>(socks_proxy_type)),
[](Object) {});
} else {
send_query(td_api::make_object<td_api::disableProxy>(), [](Object) {});
}
},
[this](td_api::authorizationStateWaitTdlibParameters &) {
auto lib_parameters = td_api::make_object<td_api::tdlibParameters>();

View File

@ -60,16 +60,17 @@ void Client::init_lib_parameters(Settings &settings) {
void Client::init_proxy(Settings &settings) {
if (settings.proxy_enabled()) {
auto socks_proxy = td_api::make_object<td_api::proxySocks5>(
settings.proxy_address(),
settings.proxy_port(),
auto socks_proxy_type = td_api::make_object<td_api::proxyTypeSocks5>(
settings.proxy_username(),
settings.proxy_password()
);
proxy = td_api::move_object_as<td_api::Proxy>(socks_proxy);
set_proxy = td_api::make_object<td_api::addProxy>(
settings.proxy_address(),
settings.proxy_port(),
true,
td_api::move_object_as<td_api::ProxyType>(socks_proxy_type));
} else {
auto empty_proxy = td_api::make_object<td_api::proxyEmpty>();
proxy = td_api::move_object_as<td_api::Proxy>(empty_proxy);
set_proxy = td_api::make_object<td_api::disableProxy>();
}
}
@ -186,8 +187,7 @@ void Client::on_authorization_state_update(td_api::object_ptr<td_api::Authorizat
case td_api::authorizationStateWaitEncryptionKey::ID:
send_query(td_api::make_object<td_api::checkDatabaseEncryptionKey>(),
create_authentication_query_handler());
send_query(td_api::make_object<td_api::setProxy>(td_api::move_object_as<td_api::Proxy>(proxy)),
create_authentication_query_handler());
send_query(std::move(set_proxy), create_authentication_query_handler());
break;
case td_api::authorizationStateWaitTdlibParameters::ID: {
send_query(td_api::make_object<td_api::setTdlibParameters>(

View File

@ -57,8 +57,8 @@ namespace tg {
const double WAIT_TIMEOUT = 10;
std::unique_ptr<td::Client> client;
std::unique_ptr<td_api::tdlibParameters> lib_parameters;
td_api::object_ptr<td_api::Proxy> proxy;
td::tl::unique_ptr<td_api::tdlibParameters> lib_parameters;
td_api::object_ptr<td_api::Function> set_proxy;
std::thread thread_;