2018-12-31 20:04:05 +01:00
|
|
|
//
|
2020-01-01 02:23:48 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#include "td/mtproto/IStreamTransport.h"
|
|
|
|
|
|
|
|
#include "td/mtproto/HttpTransport.h"
|
|
|
|
#include "td/mtproto/TcpTransport.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
namespace mtproto {
|
2019-01-31 03:13:59 +01:00
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
unique_ptr<IStreamTransport> create_transport(TransportType type) {
|
2018-04-30 19:01:18 +02:00
|
|
|
switch (type.type) {
|
2018-12-31 20:04:05 +01:00
|
|
|
case TransportType::ObfuscatedTcp:
|
2019-06-26 17:27:19 +02:00
|
|
|
return td::make_unique<tcp::ObfuscatedTransport>(type.dc_id, std::move(type.secret));
|
2018-12-31 20:04:05 +01:00
|
|
|
case TransportType::Tcp:
|
2018-09-27 03:19:03 +02:00
|
|
|
return td::make_unique<tcp::OldTransport>();
|
2018-12-31 20:04:05 +01:00
|
|
|
case TransportType::Http:
|
2019-07-09 04:01:12 +02:00
|
|
|
return td::make_unique<http::Transport>(type.secret.get_raw_secret().str());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
2019-01-31 03:13:59 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace mtproto
|
|
|
|
} // namespace td
|