2018-12-31 20:04:05 +01:00
|
|
|
//
|
2018-12-31 23:02:34 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
|
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:
|
2018-09-27 03:19:03 +02:00
|
|
|
return td::make_unique<http::Transport>(type.secret);
|
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
|