2019-07-05 07:54:53 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
2019-12-02 13:10:19 +00:00
|
|
|
#include "mtproto/details/mtproto_abstract_socket.h"
|
2019-07-05 07:54:53 +00:00
|
|
|
|
2019-12-02 13:10:19 +00:00
|
|
|
#include "mtproto/details/mtproto_tcp_socket.h"
|
|
|
|
#include "mtproto/details/mtproto_tls_socket.h"
|
2019-07-05 07:54:53 +00:00
|
|
|
|
2019-12-02 13:10:19 +00:00
|
|
|
namespace MTP::details {
|
2019-07-05 07:54:53 +00:00
|
|
|
|
|
|
|
std::unique_ptr<AbstractSocket> AbstractSocket::Create(
|
|
|
|
not_null<QThread*> thread,
|
|
|
|
const bytes::vector &secret,
|
2021-06-15 12:45:48 +00:00
|
|
|
const QNetworkProxy &proxy,
|
|
|
|
bool protocolForFiles) {
|
2019-07-08 16:02:45 +00:00
|
|
|
if (secret.size() >= 21 && secret[0] == bytes::type(0xEE)) {
|
2021-06-15 12:45:48 +00:00
|
|
|
return std::make_unique<TlsSocket>(
|
|
|
|
thread,
|
|
|
|
secret,
|
|
|
|
proxy,
|
|
|
|
protocolForFiles);
|
2019-07-08 13:56:09 +00:00
|
|
|
} else {
|
2021-06-15 12:45:48 +00:00
|
|
|
return std::make_unique<TcpSocket>(thread, proxy, protocolForFiles);
|
2019-07-08 13:56:09 +00:00
|
|
|
}
|
2019-07-05 07:54:53 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:10:19 +00:00
|
|
|
} // namespace MTP::details
|