diff --git a/CMakeLists.txt b/CMakeLists.txt index 60317188..ae72f910 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -453,6 +453,7 @@ set(TDLIB_SOURCE td/mtproto/SessionConnection.h td/mtproto/TcpTransport.h td/mtproto/Transport.h + td/mtproto/TransportType.h td/mtproto/utils.h td/telegram/AccessRights.h diff --git a/td/mtproto/HttpTransport.h b/td/mtproto/HttpTransport.h index 98cfd54b..ea333e70 100644 --- a/td/mtproto/HttpTransport.h +++ b/td/mtproto/HttpTransport.h @@ -7,6 +7,7 @@ #pragma once #include "td/mtproto/IStreamTransport.h" +#include "td/mtproto/TransportType.h" #include "td/net/HttpQuery.h" #include "td/net/HttpReader.h" diff --git a/td/mtproto/IStreamTransport.cpp b/td/mtproto/IStreamTransport.cpp index 334fc186..ca1d4cfc 100644 --- a/td/mtproto/IStreamTransport.cpp +++ b/td/mtproto/IStreamTransport.cpp @@ -13,6 +13,7 @@ namespace td { namespace mtproto { + unique_ptr create_transport(TransportType type) { switch (type.type) { case TransportType::ObfuscatedTcp: @@ -24,5 +25,6 @@ unique_ptr create_transport(TransportType type) { } UNREACHABLE(); } + } // namespace mtproto } // namespace td diff --git a/td/mtproto/IStreamTransport.h b/td/mtproto/IStreamTransport.h index 1e7be807..23827ace 100644 --- a/td/mtproto/IStreamTransport.h +++ b/td/mtproto/IStreamTransport.h @@ -6,6 +6,8 @@ // #pragma once +#include "td/mtproto/TransportType.h" + #include "td/utils/buffer.h" #include "td/utils/port/detail/PollableFd.h" #include "td/utils/Status.h" @@ -13,17 +15,6 @@ namespace td { namespace mtproto { -struct TransportType { - enum Type { Tcp, ObfuscatedTcp, Http } type; - int16 dc_id; - string secret; - - TransportType() : type(Tcp), dc_id(0), secret() { - } - TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) { - } -}; - class IStreamTransport { public: IStreamTransport() = default; diff --git a/td/mtproto/RawConnection.h b/td/mtproto/RawConnection.h index f8e26160..7773ae15 100644 --- a/td/mtproto/RawConnection.h +++ b/td/mtproto/RawConnection.h @@ -7,6 +7,7 @@ #pragma once #include "td/mtproto/IStreamTransport.h" +#include "td/mtproto/TransportType.h" #include "td/utils/buffer.h" #include "td/utils/BufferedFd.h" diff --git a/td/mtproto/TransportType.h b/td/mtproto/TransportType.h new file mode 100644 index 00000000..e5323da4 --- /dev/null +++ b/td/mtproto/TransportType.h @@ -0,0 +1,26 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019 +// +// 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 + +#include "td/utils/common.h" + +namespace td { +namespace mtproto { + +struct TransportType { + enum Type { Tcp, ObfuscatedTcp, Http } type; + int16 dc_id; + string secret; + + TransportType() : type(Tcp), dc_id(0), secret() { + } + TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) { + } +}; + +} // namespace mtproto +} // namespace td diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index 7c1d31f3..5b6dded3 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -19,7 +19,6 @@ #include "td/telegram/StateManager.h" #include "td/telegram/TdDb.h" -#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/PingConnection.h" #include "td/mtproto/RawConnection.h" diff --git a/td/telegram/net/ConnectionCreator.h b/td/telegram/net/ConnectionCreator.h index 41cafe4a..1d0a2d3e 100644 --- a/td/telegram/net/ConnectionCreator.h +++ b/td/telegram/net/ConnectionCreator.h @@ -15,7 +15,7 @@ #include "td/telegram/net/NetQuery.h" #include "td/telegram/StateManager.h" -#include "td/mtproto/IStreamTransport.h" +#include "td/mtproto/TransportType.h" #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 25c115b2..c77664eb 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -20,9 +20,9 @@ #include "td/mtproto/crypto.h" #include "td/mtproto/Handshake.h" #include "td/mtproto/HandshakeActor.h" -#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/RawConnection.h" #include "td/mtproto/SessionConnection.h" +#include "td/mtproto/TransportType.h" #include "td/utils/format.h" #include "td/utils/logging.h" diff --git a/test/mtproto.cpp b/test/mtproto.cpp index bd8ad897..2b280596 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -12,10 +12,10 @@ #include "td/mtproto/crypto.h" #include "td/mtproto/Handshake.h" #include "td/mtproto/HandshakeActor.h" -#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/PingConnection.h" #include "td/mtproto/RawConnection.h" #include "td/mtproto/Transport.h" +#include "td/mtproto/TransportType.h" #include "td/net/GetHostByNameActor.h" #include "td/net/Socks5.h"