Add TransportType.h.

GitOrigin-RevId: 403b10f5dcc161be411710749c70734cf9a4fc62
This commit is contained in:
levlam 2019-01-31 05:13:59 +03:00
parent 7542612098
commit b9fc33b7d1
10 changed files with 36 additions and 15 deletions

View File

@ -453,6 +453,7 @@ set(TDLIB_SOURCE
td/mtproto/SessionConnection.h td/mtproto/SessionConnection.h
td/mtproto/TcpTransport.h td/mtproto/TcpTransport.h
td/mtproto/Transport.h td/mtproto/Transport.h
td/mtproto/TransportType.h
td/mtproto/utils.h td/mtproto/utils.h
td/telegram/AccessRights.h td/telegram/AccessRights.h

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/TransportType.h"
#include "td/net/HttpQuery.h" #include "td/net/HttpQuery.h"
#include "td/net/HttpReader.h" #include "td/net/HttpReader.h"

View File

@ -13,6 +13,7 @@
namespace td { namespace td {
namespace mtproto { namespace mtproto {
unique_ptr<IStreamTransport> create_transport(TransportType type) { unique_ptr<IStreamTransport> create_transport(TransportType type) {
switch (type.type) { switch (type.type) {
case TransportType::ObfuscatedTcp: case TransportType::ObfuscatedTcp:
@ -24,5 +25,6 @@ unique_ptr<IStreamTransport> create_transport(TransportType type) {
} }
UNREACHABLE(); UNREACHABLE();
} }
} // namespace mtproto } // namespace mtproto
} // namespace td } // namespace td

View File

@ -6,6 +6,8 @@
// //
#pragma once #pragma once
#include "td/mtproto/TransportType.h"
#include "td/utils/buffer.h" #include "td/utils/buffer.h"
#include "td/utils/port/detail/PollableFd.h" #include "td/utils/port/detail/PollableFd.h"
#include "td/utils/Status.h" #include "td/utils/Status.h"
@ -13,17 +15,6 @@
namespace td { namespace td {
namespace mtproto { 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 { class IStreamTransport {
public: public:
IStreamTransport() = default; IStreamTransport() = default;

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/TransportType.h"
#include "td/utils/buffer.h" #include "td/utils/buffer.h"
#include "td/utils/BufferedFd.h" #include "td/utils/BufferedFd.h"

View File

@ -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

View File

@ -19,7 +19,6 @@
#include "td/telegram/StateManager.h" #include "td/telegram/StateManager.h"
#include "td/telegram/TdDb.h" #include "td/telegram/TdDb.h"
#include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/PingConnection.h" #include "td/mtproto/PingConnection.h"
#include "td/mtproto/RawConnection.h" #include "td/mtproto/RawConnection.h"

View File

@ -15,7 +15,7 @@
#include "td/telegram/net/NetQuery.h" #include "td/telegram/net/NetQuery.h"
#include "td/telegram/StateManager.h" #include "td/telegram/StateManager.h"
#include "td/mtproto/IStreamTransport.h" #include "td/mtproto/TransportType.h"
#include "td/actor/actor.h" #include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h" #include "td/actor/PromiseFuture.h"

View File

@ -20,9 +20,9 @@
#include "td/mtproto/crypto.h" #include "td/mtproto/crypto.h"
#include "td/mtproto/Handshake.h" #include "td/mtproto/Handshake.h"
#include "td/mtproto/HandshakeActor.h" #include "td/mtproto/HandshakeActor.h"
#include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/RawConnection.h" #include "td/mtproto/RawConnection.h"
#include "td/mtproto/SessionConnection.h" #include "td/mtproto/SessionConnection.h"
#include "td/mtproto/TransportType.h"
#include "td/utils/format.h" #include "td/utils/format.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"

View File

@ -12,10 +12,10 @@
#include "td/mtproto/crypto.h" #include "td/mtproto/crypto.h"
#include "td/mtproto/Handshake.h" #include "td/mtproto/Handshake.h"
#include "td/mtproto/HandshakeActor.h" #include "td/mtproto/HandshakeActor.h"
#include "td/mtproto/IStreamTransport.h"
#include "td/mtproto/PingConnection.h" #include "td/mtproto/PingConnection.h"
#include "td/mtproto/RawConnection.h" #include "td/mtproto/RawConnection.h"
#include "td/mtproto/Transport.h" #include "td/mtproto/Transport.h"
#include "td/mtproto/TransportType.h"
#include "td/net/GetHostByNameActor.h" #include "td/net/GetHostByNameActor.h"
#include "td/net/Socks5.h" #include "td/net/Socks5.h"