tdesktop/Telegram/SourceFiles/mtproto/mtp_abstract_socket.cpp

30 lines
810 B
C++
Raw Normal View History

/*
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
*/
#include "mtproto/mtp_abstract_socket.h"
#include "mtproto/mtp_tcp_socket.h"
2019-07-08 13:56:09 +00:00
#include "mtproto/mtp_tls_socket.h"
namespace MTP {
namespace internal {
std::unique_ptr<AbstractSocket> AbstractSocket::Create(
not_null<QThread*> thread,
const bytes::vector &secret,
const QNetworkProxy &proxy,
Fn<int32()> unixtime) {
2019-07-08 16:02:45 +00:00
if (secret.size() >= 21 && secret[0] == bytes::type(0xEE)) {
return std::make_unique<TlsSocket>(thread, secret, proxy, unixtime);
2019-07-08 13:56:09 +00:00
} else {
return std::make_unique<TcpSocket>(thread, proxy);
}
}
} // namespace internal
} // namespace MTP